Decal system (TODO: add decals for explosions and fire), moved some of the client-specific Hull update logic to the client project

This commit is contained in:
Joonas Rikkonen
2017-07-06 21:38:32 +03:00
parent 90a584d122
commit 4d2e7c33b1
11 changed files with 391 additions and 93 deletions
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma.Particles
{
class DecalManager
{
private Dictionary<string, DecalPrefab> prefabs;
public DecalManager(string configFile)
{
XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null || doc.Root == null) return;
prefabs = new Dictionary<string, DecalPrefab>();
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);
}
}
}