Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaClient/Source/Particles/DecalManager.cs
Joonas Rikkonen 9e2966e9cb - Fixed creature disable list only taking config files in the Content/Characters folder into account (making it impossible to disable spawning of custom monsters outside the folder)
- Removed hard-coded ruin structure, particle & decal config paths and moved them to content package (custom ones can be added now without modifying the original files).
2018-02-25 15:03:29 +02:00

47 lines
1.5 KiB
C#

using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma.Particles
{
class DecalManager
{
private Dictionary<string, DecalPrefab> prefabs;
public DecalManager()
{
prefabs = new Dictionary<string, DecalPrefab>();
foreach (string configFile in GameMain.Config.SelectedContentPackage.GetFilesOfType(ContentType.Decals))
{
XDocument doc = XMLExtensions.TryLoadXml(configFile);
if (doc == null || doc.Root == null) continue;
foreach (XElement element in doc.Root.Elements())
{
if (prefabs.ContainsKey(element.Name.ToString()))
{
DebugConsole.ThrowError("Error in " + configFile + "! Each decal prefab must have a unique name.");
continue;
}
prefabs.Add(element.Name.ToString(), new DecalPrefab(element));
}
}
}
public Decal CreateDecal(string decalName, float scale, Vector2 worldPosition, Hull hull)
{
DecalPrefab prefab;
prefabs.TryGetValue(decalName, out prefab);
if (prefab == null)
{
DebugConsole.ThrowError("Decal prefab " + decalName + " not found!");
return null;
}
return new Decal(prefab, scale, worldPosition, hull);
}
}
}