diff --git a/DepthsBelow/DepthsBelow/Component/PathFinder.cs b/DepthsBelow/DepthsBelow/Component/PathFinder.cs
index a0f19c5..def0eef 100755
--- a/DepthsBelow/DepthsBelow/Component/PathFinder.cs
+++ b/DepthsBelow/DepthsBelow/Component/PathFinder.cs
@@ -152,6 +152,8 @@ namespace DepthsBelow.Component
{
byte[,] mapCollisionMap = Core.Map.GetCollisionMap();
+ // Add solid collision component entities
+
if (appendCollisionMap != null)
foreach (var point in appendCollisionMap)
mapCollisionMap[point.X, point.Y] = 0;
diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs
index 6a0420e..4f3e788 100755
--- a/DepthsBelow/DepthsBelow/Core.cs
+++ b/DepthsBelow/DepthsBelow/Core.cs
@@ -27,7 +27,6 @@ namespace DepthsBelow
public Lua Lua;
- public EntityManager EntityManager;
public TurnManager TurnManager;
public Camera Camera;
@@ -76,7 +75,6 @@ namespace DepthsBelow
Lua = new Lua();
- EntityManager = new EntityManager();
TurnManager = new TurnManager(new string[] { "Player", "Computer" });
Camera = new Camera(this);
@@ -124,7 +122,7 @@ namespace DepthsBelow
MouseInput.LoadContent();
KeyboardInput = new KeyboardInput(this);
- TestMonster = new SmallEnemy(EntityManager, ref Swarm);
+ TestMonster = new SmallEnemy(ref Swarm);
TestMonster.X = 12;
TestMonster.Y = 4;
Swarm.Add(TestMonster);
diff --git a/DepthsBelow/DepthsBelow/Entity.cs b/DepthsBelow/DepthsBelow/Entity.cs
index 15ac841..d6852d3 100755
--- a/DepthsBelow/DepthsBelow/Entity.cs
+++ b/DepthsBelow/DepthsBelow/Entity.cs
@@ -18,8 +18,6 @@ namespace DepthsBelow
///
public Component.Transform Transform;
- protected EntityManager entityManager;
-
///
/// Shorthand to the grid transform position.
///
@@ -61,11 +59,10 @@ namespace DepthsBelow
///
/// Creates a game object and adds it to the referenced entity manager.
///
- /// An instance of EntityManager to add the entity to.
- public Entity(EntityManager entityManager)
+ ///
+ public Entity()
{
- this.entityManager = entityManager;
- entityManager.Add(this);
+ EntityManager.Add(this);
Components = new List();
@@ -88,7 +85,7 @@ namespace DepthsBelow
///
public virtual void Remove()
{
- entityManager.Remove(this);
+ EntityManager.Remove(this);
Dispose();
}
diff --git a/DepthsBelow/DepthsBelow/EntityManager.cs b/DepthsBelow/DepthsBelow/EntityManager.cs
index 4e1bca6..41cce90 100755
--- a/DepthsBelow/DepthsBelow/EntityManager.cs
+++ b/DepthsBelow/DepthsBelow/EntityManager.cs
@@ -10,20 +10,15 @@ namespace DepthsBelow
///
/// Manages a group of entities.
///
- public class EntityManager : IDisposable
+ public static class EntityManager
{
- public List Entities;
-
- public EntityManager()
- {
- Entities = new List();
- }
+ public static List Entities = new List();
///
/// Implementation of IDisposable.
/// Dispose of the entity manager, and all entities it contains.
///
- public void Dispose()
+ public static void Dispose()
{
foreach (var entity in Entities)
entity.Dispose();
@@ -35,7 +30,7 @@ namespace DepthsBelow
/// Add an entity to the entity manager.
///
/// The entity to add.
- public void Add(Entity entity)
+ public static void Add(Entity entity)
{
Entities.Add(entity);
}
@@ -44,7 +39,7 @@ namespace DepthsBelow
/// Remove an entity from the entity manager.
///
/// The entity to remove.
- public void Remove(Entity entity)
+ public static void Remove(Entity entity)
{
Entities.Remove(entity);
}
@@ -52,7 +47,7 @@ namespace DepthsBelow
///
/// Reset the entity manager, disposing any entities it contains.
///
- public void Reset()
+ public static void Reset()
{
foreach (var entity in Entities)
entity.Dispose();
@@ -65,7 +60,7 @@ namespace DepthsBelow
///
/// The component type.
/// Returns the component of requested type.
- public List GetComponents() where T : Component.Component
+ public static List GetComponents() where T : Component.Component
{
List components = new List();
@@ -83,7 +78,7 @@ namespace DepthsBelow
/// Update all entities handled by the entity manager.
///
///
- public void Update(GameTime gameTime)
+ public static void Update(GameTime gameTime)
{
foreach (var entity in Entities.ToList())
entity.Update(gameTime);
@@ -93,7 +88,7 @@ namespace DepthsBelow
/// Draw all entities handled by the entity manager.
///
///
- public void Draw(SpriteBatch spriteBatch)
+ public static void Draw(SpriteBatch spriteBatch)
{
foreach (var entity in Entities)
{
diff --git a/DepthsBelow/DepthsBelow/KeyboardInput.cs b/DepthsBelow/DepthsBelow/KeyboardInput.cs
index 0d740d3..eac839a 100755
--- a/DepthsBelow/DepthsBelow/KeyboardInput.cs
+++ b/DepthsBelow/DepthsBelow/KeyboardInput.cs
@@ -229,7 +229,7 @@ namespace DepthsBelow
}
if (soldier.AP >= cost)
{
- core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), type));
+ core.Volley.Add(new Shot(soldier.GetComponent(), type));
soldier.AP -= cost;
soldier.Fired = true;
}
@@ -297,7 +297,7 @@ namespace DepthsBelow
current = 0;
if (soldier.Selected == true && soldier.Fired == false && hit == true)
{
- core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), "Bullet"));
+ core.Volley.Add(new Shot(soldier.GetComponent(), "Bullet"));
soldier.Fired = true;
foreach (var shot in core.Volley)
{
diff --git a/DepthsBelow/DepthsBelow/Map.cs b/DepthsBelow/DepthsBelow/Map.cs
index a5c25da..958b855 100755
--- a/DepthsBelow/DepthsBelow/Map.cs
+++ b/DepthsBelow/DepthsBelow/Map.cs
@@ -72,7 +72,7 @@ namespace DepthsBelow
{
if (mapObject.Type == "SquadStart")
{
- var soldier = new Soldier(core.EntityManager, ref core.Squad);
+ var soldier = new Soldier(ref core.Squad);
soldier.Name = "Derp";
// HACK: For some reason, the tile object coordinates are offset by one tile on the Y-axis in the Tiled map file (https://github.com/bjorn/tiled/issues/91)
var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y - Grid.TileSize);
@@ -84,7 +84,7 @@ namespace DepthsBelow
}
if (mapObject.Type == "MonsterSpawn")
{
- var enemy = new MonsterSpawn(core.EntityManager, ref core.Swarm);
+ var enemy = new MonsterSpawn(ref core.Swarm);
var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y - Grid.TileSize);
var mapObjectGridPos = Grid.WorldToGrid(mapObjectPos);
enemy.X = mapObjectGridPos.X;
diff --git a/DepthsBelow/DepthsBelow/MonsterSpawn.cs b/DepthsBelow/DepthsBelow/MonsterSpawn.cs
index 1ad98df..2cd33a6 100755
--- a/DepthsBelow/DepthsBelow/MonsterSpawn.cs
+++ b/DepthsBelow/DepthsBelow/MonsterSpawn.cs
@@ -15,8 +15,8 @@ namespace DepthsBelow
List swarm;
- public MonsterSpawn(EntityManager entityManager, ref List Swarm)
- : base(entityManager)
+ public MonsterSpawn(ref List Swarm)
+ : base()
{
//this.entityManager = entityManager;
swarm = Swarm;
@@ -24,9 +24,9 @@ namespace DepthsBelow
public override void Update(GameTime gameTime)
{
- for (int index = 0; index < entityManager.Entities.Count; index++)
+ for (int index = 0; index < EntityManager.Entities.Count; index++)
{
- var entity = entityManager.Entities[index];
+ var entity = EntityManager.Entities[index];
if (entity is Soldier)
{
Vector2 distance1 = new Vector2(this.GetComponent().Grid.Position.X,
@@ -35,7 +35,7 @@ namespace DepthsBelow
entity.GetComponent().Grid.Position.Y);
if (Vector2.Distance(distance1, distance2) < wakingDistance)
{
- var enemy = new SmallEnemy(entityManager, ref swarm);
+ var enemy = new SmallEnemy(ref swarm);
enemy.X = this.X;
enemy.Y = this.Y;
swarm.Add(enemy);
diff --git a/DepthsBelow/DepthsBelow/Shot.cs b/DepthsBelow/DepthsBelow/Shot.cs
index 9287a64..d623b5b 100755
--- a/DepthsBelow/DepthsBelow/Shot.cs
+++ b/DepthsBelow/DepthsBelow/Shot.cs
@@ -38,8 +38,8 @@ namespace DepthsBelow
public Vector2 direction = Vector2.Zero;
- public Shot(EntityManager entityManager, Stat _soldierStat, string _type)
- : base(entityManager)
+ public Shot(Stat _soldierStat, string _type)
+ : base()
{
type = _type;
@@ -80,7 +80,7 @@ namespace DepthsBelow
float speed = 4f;
Transform.World.Position += speed * direction;
- foreach (var entity in entityManager.Entities)
+ foreach (var entity in EntityManager.Entities)
{
if (entity is SmallEnemy)
{
diff --git a/DepthsBelow/DepthsBelow/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs
index e47a19f..c22b4ad 100755
--- a/DepthsBelow/DepthsBelow/SmallEnemy.cs
+++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs
@@ -31,8 +31,8 @@ namespace DepthsBelow
}
}
- public SmallEnemy(EntityManager entityManager, ref List swarm)
- : base(entityManager)
+ public SmallEnemy(ref List swarm)
+ : base()
{
if (Texture == null)
LoadContent();
@@ -150,7 +150,7 @@ namespace DepthsBelow
GetComponent().Stop();
}
- foreach (var entity in entityManager.Entities)
+ foreach (var entity in EntityManager.Entities)
{
if (entity is Soldier)
{
diff --git a/DepthsBelow/DepthsBelow/Soldier.cs b/DepthsBelow/DepthsBelow/Soldier.cs
index 38f1b32..ab6ed91 100755
--- a/DepthsBelow/DepthsBelow/Soldier.cs
+++ b/DepthsBelow/DepthsBelow/Soldier.cs
@@ -48,8 +48,8 @@ namespace DepthsBelow
}
}
- public Soldier(EntityManager entityManager, ref List squad)
- : base(entityManager)
+ public Soldier(ref List squad)
+ : base()
{
if (Texture == null)
LoadContent();