Пример #1
0
        public void OnVoxelDestroyed(VoxelHandle V)
        {
            if (!V.IsValid)
            {
                return;
            }
            RoomBuilder.OnVoxelDestroyed(V);

            var toRemove = new List <Stockpile>();

            foreach (var s in new List <Stockpile>(Stockpiles).Where(stockpile => stockpile.IsBuilt))
            {
                if (s.ContainsVoxel(V))
                {
                    s.RemoveVoxel(V);
                }

                if (s.Voxels.Count == 0)
                {
                    toRemove.Add(s);
                }
            }

            foreach (Stockpile s in toRemove)
            {
                Stockpiles.Remove(s);
                s.Destroy();
            }
        }
Пример #2
0
        public void OnVoxelDestroyed(Voxel v)
        {
            if (v.IsEmpty)
            {
                return;
            }

            Voxel Voxel = v;

            RoomBuilder.OnVoxelDestroyed(v);

            List <Stockpile> toRemove          = new List <Stockpile>();
            List <Stockpile> currentStockpiles = new List <Stockpile>();

            currentStockpiles.AddRange(Stockpiles);
            foreach (Stockpile s in currentStockpiles)
            {
                if (s.ContainsVoxel(Voxel))
                {
                    s.RemoveVoxel(Voxel);
                }

                if (s.Voxels.Count == 0)
                {
                    toRemove.Add(s);
                }
            }

            foreach (Stockpile s in toRemove)
            {
                Stockpiles.Remove(s);
                s.Destroy();
            }
        }
Пример #3
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.Faction = this;
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);

            if (this == World.PlayerFaction)
            {
                foreach (var m in Minions.Where(c => !SelectedMinions.Contains(c)))
                {
                    if (m.Creature.SelectionCircle != null)
                    {
                        m.Creature.DeleteSelectionCircle();
                    }
                    m.Creature.Sprite.DrawSilhouette = false;
                }
                ;

                foreach (CreatureAI creature in SelectedMinions)
                {
                    if (creature.Creature.SelectionCircle == null)
                    {
                        creature.Creature.Physics.AddChild(new SelectionCircle(creature.Manager));
                    }
                    creature.Creature.SelectionCircle.SetFlagRecursive(GameComponent.Flag.Visible, true);
                    creature.Creature.Sprite.DrawSilhouette = true;
                }
            }

            foreach (Room zone in GetRooms())
            {
                zone.ZoneBodies.RemoveAll(body => body.IsDead);
            }

            Designations.CleanupDesignations();

            foreach (var zone in RoomBuilder.DesignatedRooms)
            {
                zone.Update();
            }

            if (HandleThreatsTimer == null)
            {
                HandleThreatsTimer = new Timer(1.0f, false, Timer.TimerMode.Real
                                               );
            }

            HandleThreatsTimer.Update(time);
            if (HandleThreatsTimer.HasTriggered)
            {
                HandleThreats();
            }

            OwnedObjects.RemoveAll(obj => obj.IsDead);
        }
Пример #4
0
 public Faction(WorldManager world)
 {
     HandleThreatsTimer = new Timer(1.0f, false, Timer.TimerMode.Real);
     World           = world;
     Threats         = new List <Creature>();
     Minions         = new List <CreatureAI>();
     SelectedMinions = new List <CreatureAI>();
     Stockpiles      = new List <Stockpile>();
     TradeEnvoys     = new List <TradeEnvoy>();
     WarParties      = new List <WarParty>();
     OwnedObjects    = new List <Body>();
     RoomBuilder     = new RoomBuilder(this, world);
     IsRaceFaction   = false;
     TradeMoney      = 0.0m;
     GoodWill        = 0.0f;
 }
Пример #5
0
 public Faction()
 {
     Threats            = new List <Creature>();
     Minions            = new List <CreatureAI>();
     SelectedMinions    = new List <CreatureAI>();
     TaskManager        = new TaskManager(this);
     Stockpiles         = new List <Stockpile>();
     DigDesignations    = new List <BuildOrder>();
     GuardDesignations  = new List <BuildOrder>();
     ChopDesignations   = new List <Body>();
     AttackDesignations = new List <Body>();
     ShipDesignations   = new List <ShipOrder>();
     GatherDesignations = new List <Body>();
     RoomBuilder        = new RoomBuilder(this);
     WallBuilder        = new PutDesignator(this, TextureManager.GetTexture(ContentPaths.Terrain.terrain_tiles));
     CraftBuilder       = new CraftBuilder(this);
 }
Пример #6
0
 public Faction()
 {
     Threats = new List<Creature>();
     Minions = new List<CreatureAI>();
     SelectedMinions = new List<CreatureAI>();
     TaskManager = new TaskManager(this);
     Stockpiles = new List<Stockpile>();
     DigDesignations = new List<BuildOrder>();
     GuardDesignations = new List<BuildOrder>();
     ChopDesignations = new List<Body>();
     AttackDesignations = new List<Body>();
     ShipDesignations = new List<ShipOrder>();
     GatherDesignations = new List<Body>();
     RoomBuilder = new RoomBuilder(this);
     WallBuilder = new PutDesignator(this, TextureManager.GetTexture(ContentPaths.Terrain.terrain_tiles));
     CraftBuilder = new CraftBuilder(this);
 }
Пример #7
0
        public void OnVoxelDestroyed(VoxelHandle V)
        {
            if (!V.IsValid)
            {
                return;
            }
            RoomBuilder.OnVoxelDestroyed(V);

            var toRemove = new List <Stockpile>();

            foreach (var s in new List <Stockpile>(Stockpiles).Where(stockpile => stockpile.IsBuilt))
            {
                if (s.ContainsVoxel(V))
                {
                    s.RemoveVoxel(V);
                }

                if (s.Voxels.Count == 0)
                {
                    toRemove.Add(s);
                }
            }

            foreach (Stockpile s in toRemove)
            {
                foreach (var resource in s.Resources)
                {
                    var resourceType = ResourceLibrary.GetResourceByName(resource.ResourceType);

                    foreach (var tag in resourceType.Tags)
                    {
                        if (CachedResourceTagCounts.ContainsKey(tag))
                        {
                            CachedResourceTagCounts[tag] -= resource.NumResources;
                            Trace.Assert(CachedResourceTagCounts[tag] >= 0);
                        }
                    }
                }
                RecomputeCachedVoxelstate();
                Stockpiles.Remove(s);
                s.Destroy();
            }
        }
Пример #8
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.Faction  = this;
            CraftBuilder.Faction = this;
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);

            foreach (var m in Minions)
            {
                m.Creature.SelectionCircle.SetFlagRecursive(GameComponent.Flag.Visible, false);
                m.Creature.Sprite.DrawSilhouette = false;
            }
            ;

            foreach (CreatureAI creature in SelectedMinions)
            {
                creature.Creature.SelectionCircle.SetFlagRecursive(GameComponent.Flag.Visible, true);
                creature.Creature.Sprite.DrawSilhouette = true;
            }

            foreach (Room zone in GetRooms())
            {
                zone.ZoneBodies.RemoveAll(body => body.IsDead);
            }

            Designations.CleanupDesignations();

            foreach (var zone in RoomBuilder.DesignatedRooms)
            {
                zone.Update();
            }

            HandleThreatsTimer.Update(time);
            if (HandleThreatsTimer.HasTriggered)
            {
                HandleThreats();
            }

            OwnedObjects.RemoveAll(obj => obj.IsDead);
        }
Пример #9
0
 public Faction()
 {
     Threats            = new List <Creature>();
     Minions            = new List <CreatureAI>();
     SelectedMinions    = new List <CreatureAI>();
     TaskManager        = new TaskManager(this);
     Stockpiles         = new List <Stockpile>();
     DigDesignations    = new List <BuildOrder>();
     GuardDesignations  = new List <BuildOrder>();
     ChopDesignations   = new List <Body>();
     AttackDesignations = new List <Body>();
     GatherDesignations = new List <Body>();
     TradeEnvoys        = new List <TradeEnvoy>();
     WarParties         = new List <WarParty>();
     RoomBuilder        = new RoomBuilder(this);
     WallBuilder        = new PutDesignator(this, TextureManager.GetTexture(ContentPaths.Terrain.terrain_tiles));
     CraftBuilder       = new CraftBuilder(this);
     IsRaceFaction      = false;
     TradeMoney         = 0.0f;
 }
Пример #10
0
 public Faction(WorldManager world)
 {
     World              = world;
     Threats            = new List <Creature>();
     Minions            = new List <CreatureAI>();
     SelectedMinions    = new List <CreatureAI>();
     TaskManager        = new TaskManager();
     Stockpiles         = new List <Stockpile>();
     DigDesignations    = new Dictionary <ulong, BuildOrder>();
     GuardDesignations  = new List <BuildOrder>();
     ChopDesignations   = new List <Body>();
     AttackDesignations = new List <Body>();
     GatherDesignations = new List <Body>();
     TradeEnvoys        = new List <TradeEnvoy>();
     WarParties         = new List <WarParty>();
     RoomBuilder        = new RoomBuilder(this, world);
     WallBuilder        = new PutDesignator(this, world);
     CraftBuilder       = new CraftBuilder(this, world);
     IsRaceFaction      = false;
     TradeMoney         = 0.0f;
 }
Пример #11
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.Faction  = this;
            CraftBuilder.Faction = this;
            WallBuilder.Faction  = this;
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);
            Minions.ForEach(m =>
            {
                m.Creature.SelectionCircle.IsVisible = false;
                m.Creature.Sprite.DrawSilhouette     = false;
            });
            SelectedMinions.ForEach(m => {
                m.Creature.SelectionCircle.IsVisible = true;
                m.Creature.Sprite.DrawSilhouette     = true;
            }

                                    );

            // Turned off until a non-O(n^2) collision method is create.
            //CollideMinions(time);

            List <ulong> removalKeys = new List <ulong>();

            foreach (KeyValuePair <ulong, BuildOrder> kvp in DigDesignations)
            {
                Voxel v = kvp.Value.Vox;
                if (v.IsEmpty || v.Health <= 0.0f || v.Type.Name == "empty" || v.Type.IsInvincible)
                {
                    removalKeys.Add(kvp.Key);
                }
            }

            for (int i = 0; i < removalKeys.Count; i++)
            {
                DigDesignations.Remove(removalKeys[i]);
            }

            List <Body> gatherRemovals = (from b in GatherDesignations
                                          where b == null || b.IsDead
                                          select b).ToList();

            foreach (Body b in gatherRemovals)
            {
                GatherDesignations.Remove(b);
            }


            List <BuildOrder> removals = new List <BuildOrder>();

            foreach (BuildOrder d in GuardDesignations)
            {
                Voxel v = d.Vox;

                if (!v.IsEmpty && !(v.Health <= 0.0f) && v.Type.Name != "empty")
                {
                    continue;
                }

                removals.Add(d);

                if (!v.IsEmpty)
                {
                    v.Kill();
                }
            }

            foreach (BuildOrder v in removals)
            {
                GuardDesignations.Remove(v);
            }

            List <Body> treesToRemove = ChopDesignations.Where(tree => tree.IsDead).ToList();

            foreach (Body tree in treesToRemove)
            {
                ChopDesignations.Remove(tree);
            }

            List <Body> attacksToRemove = AttackDesignations.Where(body => body.IsDead).ToList();

            foreach (Body body in attacksToRemove)
            {
                AttackDesignations.Remove(body);
            }

            HandleThreats();
        }
Пример #12
0
        /// <summary>
        /// Creates a flat, wooden balloon port for the balloon to land on, and Dwarves to sit on.
        /// </summary>
        /// <param name="roomDes">The player's BuildRoom designator (so that we can create a balloon port)</param>
        /// <param name="chunkManager">The terrain handler</param>
        /// <param name="x">The position of the center of the balloon port</param>
        /// <param name="z">The position of the center of the balloon port</param>
        /// <param name="size">The size of the (square) balloon port in voxels on a side</param>
        public Room GenerateInitialBalloonPort(RoomBuilder roomDes, ChunkManager chunkManager, float x, float z,
                                               int size)
        {
            var centerCoordinate = GlobalVoxelCoordinate.FromVector3(new Vector3(x, VoxelConstants.ChunkSizeY - 1, z));

            var accumulator = 0;
            var count       = 0;

            for (var offsetX = -size; offsetX <= size; ++offsetX)
            {
                for (var offsetY = -size; offsetY <= size; ++offsetY)
                {
                    var topVoxel = VoxelHelpers.FindFirstVoxelBelowIncludeWater(
                        new VoxelHandle(chunkManager.ChunkData,
                                        centerCoordinate + new GlobalVoxelOffset(offsetX, 0, offsetY)));

                    if (topVoxel.Coordinate.Y > 0)
                    {
                        accumulator += topVoxel.Coordinate.Y + 1;
                        count       += 1;
                    }
                }
            }

            var averageHeight = (int)Math.Round(((float)accumulator / (float)count));

            if (StartUnderground)
            {
                accumulator = 0;
                count       = 0;
                List <string> illegalTypes = new List <string>()
                {
                    "Sand", "Dirt", "DarkDirt", "Ice"
                };
                for (var offsetX = -size; offsetX <= size; ++offsetX)
                {
                    for (var offsetY = -size; offsetY <= size; ++offsetY)
                    {
                        var topVoxel = VoxelHelpers.FindFirstVoxelBelow(
                            new VoxelHandle(chunkManager.ChunkData,
                                            centerCoordinate + new GlobalVoxelOffset(offsetX, 0, offsetY)));

                        if (topVoxel.Coordinate.Y > 0)
                        {
                            var vox = topVoxel;
                            for (int dy = topVoxel.Coordinate.Y; dy > 0; dy--)
                            {
                                vox = new VoxelHandle(chunkManager.ChunkData, new GlobalVoxelCoordinate(topVoxel.Coordinate.X, dy, topVoxel.Coordinate.Z));
                                if (vox.IsValid && !vox.IsEmpty && !illegalTypes.Contains(vox.Type.Name))
                                {
                                    break;
                                }
                            }
                            accumulator += vox.Coordinate.Y + 1;
                            count       += 1;
                        }
                    }
                }
                averageHeight = Math.Max((int)Math.Round(((float)accumulator / (float)count)) - 5, 0);
            }

            // Next, create the balloon port by deciding which voxels to fill.
            var balloonPortDesignations = new List <VoxelHandle>();
            var treasuryDesignations    = new List <VoxelHandle>();

            for (int dx = -size; dx <= size; dx++)
            {
                for (int dz = -size; dz <= size; dz++)
                {
                    Vector3 worldPos = new Vector3(centerCoordinate.X + dx, centerCoordinate.Y, centerCoordinate.Z + dz);

                    var baseVoxel = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle(
                                                                         chunkManager.ChunkData, GlobalVoxelCoordinate.FromVector3(worldPos)));

                    if (!baseVoxel.IsValid)
                    {
                        continue;
                    }

                    var h          = baseVoxel.Coordinate.Y + 1;
                    var localCoord = baseVoxel.Coordinate.GetLocalVoxelCoordinate();

                    for (int y = averageHeight; y < (StartUnderground ? averageHeight + 2 : h); y++)
                    {
                        var v = new VoxelHandle(baseVoxel.Chunk,
                                                new LocalVoxelCoordinate((int)localCoord.X, y, (int)localCoord.Z));
                        v.RawSetType(VoxelLibrary.GetVoxelType(0));
                        v.RawSetIsExplored();
                        v.QuickSetLiquid(LiquidType.None, 0);
                    }

                    if (averageHeight < h)
                    {
                        h = averageHeight;
                    }

                    bool isPosX = (dx == size && dz == 0);
                    bool isPosZ = (dz == size & dx == 0);
                    bool isNegX = (dx == -size && dz == 0);
                    bool isNegZ = (dz == -size && dz == 0);
                    bool isSide = (isPosX || isNegX || isPosZ || isNegZ);

                    Vector3 offset = Vector3.Zero;

                    if (isSide)
                    {
                        if (isPosX)
                        {
                            offset = Vector3.UnitX;
                        }
                        else if (isPosZ)
                        {
                            offset = Vector3.UnitZ;
                        }
                        else if (isNegX)
                        {
                            offset = -Vector3.UnitX;
                        }
                        else if (isNegZ)
                        {
                            offset = -Vector3.UnitZ;
                        }
                    }

                    bool encounteredFilled = false;
                    // Fill from the top height down to the bottom.
                    for (int y = Math.Min(0, h - 1); y < averageHeight && y < VoxelConstants.ChunkSizeY; y++)
                    {
                        var v = new VoxelHandle(baseVoxel.Chunk,
                                                new LocalVoxelCoordinate((int)localCoord.X, y, (int)localCoord.Z));
                        if (!v.IsValid)
                        {
                            throw new InvalidProgramException("Voxel was invalid while creating a new game's initial zones. This should not happen.");
                        }

                        v.RawSetType(VoxelLibrary.GetVoxelType("Scaffold"));
                        v.IsPlayerBuilt = true;
                        v.QuickSetLiquid(LiquidType.None, 0);

                        if (y == averageHeight - 1)
                        {
                            v.RawSetIsExplored();

                            if (dz >= 0)
                            {
                                balloonPortDesignations.Add(v);
                            }
                            else
                            {
                                treasuryDesignations.Add(v);
                            }
                        }

                        if (isSide && !encounteredFilled)
                        {
                            var ladderPos = new Vector3(worldPos.X, y, worldPos.Z) + offset +
                                            Vector3.One * 0.5f;
                            var ladderVox = new VoxelHandle(chunkManager.ChunkData,
                                                            GlobalVoxelCoordinate.FromVector3(ladderPos));
                            if (ladderVox.IsValid && ladderVox.IsEmpty)
                            {
                                var ladder = EntityFactory.CreateEntity <Ladder>("Ladder", ladderPos);
                                Master.Faction.OwnedObjects.Add(ladder);
                                ladder.Tags.Add("Moveable");
                                ladder.Tags.Add("Deconstructable");
                            }
                            else
                            {
                                encounteredFilled = true;
                            }
                        }
                    }
                }
            }

            // Actually create the BuildRoom.
            var toBuild = RoomLibrary.CreateRoom(PlayerFaction, "Balloon Port", this);

            roomDes.DesignatedRooms.Add(toBuild);
            RoomLibrary.CompleteRoomImmediately(toBuild, balloonPortDesignations);

            // Also add a treasury
            var treasury = RoomLibrary.CreateRoom(PlayerFaction, "Treasury", this);

            roomDes.DesignatedRooms.Add(treasury);
            RoomLibrary.CompleteRoomImmediately(treasury, treasuryDesignations);

            return(toBuild);
        }
Пример #13
0
        /// <summary>
        /// Creates a flat, wooden balloon port for the balloon to land on, and Dwarves to sit on.
        /// </summary>
        /// <param name="roomDes">The player's BuildRoom designator (so that we can create a balloon port)</param>
        /// <param name="chunkManager">The terrain handler</param>
        /// <param name="x">The position of the center of the balloon port</param>
        /// <param name="z">The position of the center of the balloon port</param>
        /// <param name="size">The size of the (square) balloon port in voxels on a side</param>
        public BalloonPort GenerateInitialBalloonPort(RoomBuilder roomDes, ChunkManager chunkManager, float x, float z,
                                                      int size)
        {
            var centerCoordinate = GlobalVoxelCoordinate.FromVector3(new Vector3(x, VoxelConstants.ChunkSizeY - 1, z));

            var accumulator = 0;
            var count       = 0;

            for (var offsetX = -size; offsetX <= size; ++offsetX)
            {
                for (var offsetY = -size; offsetY <= size; ++offsetY)
                {
                    var topVoxel = VoxelHelpers.FindFirstVoxelBelowIncludeWater(
                        new VoxelHandle(chunkManager.ChunkData,
                                        centerCoordinate + new GlobalVoxelOffset(offsetX, 0, offsetY)));

                    if (topVoxel.Coordinate.Y > 0)
                    {
                        accumulator += topVoxel.Coordinate.Y + 1;
                        count       += 1;
                    }
                }
            }

            var averageHeight = (int)Math.Round(((float)accumulator / (float)count));

            // Next, create the balloon port by deciding which voxels to fill.
            var balloonPortDesignations = new List <VoxelHandle>();
            var treasuryDesignations    = new List <VoxelHandle>();

            for (int dx = -size; dx <= size; dx++)
            {
                for (int dz = -size; dz <= size; dz++)
                {
                    Vector3 worldPos = new Vector3(centerCoordinate.X + dx, centerCoordinate.Y, centerCoordinate.Z + dz);

                    var baseVoxel = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle(
                                                                         chunkManager.ChunkData, GlobalVoxelCoordinate.FromVector3(worldPos)));

                    if (!baseVoxel.IsValid)
                    {
                        continue;
                    }

                    var h          = baseVoxel.Coordinate.Y + 1;
                    var localCoord = baseVoxel.Coordinate.GetLocalVoxelCoordinate();

                    for (int y = averageHeight; y < h; y++)
                    {
                        var v = new VoxelHandle(baseVoxel.Chunk,
                                                new LocalVoxelCoordinate((int)localCoord.X, y, (int)localCoord.Z));
                        v.RawSetType(VoxelLibrary.GetVoxelType(0));
                        v.QuickSetLiquid(LiquidType.None, 0);
                    }

                    if (averageHeight < h)
                    {
                        h = averageHeight;
                    }

                    bool isPosX = (dx == size && dz == 0);
                    bool isPosZ = (dz == size & dx == 0);
                    bool isNegX = (dx == -size && dz == 0);
                    bool isNegZ = (dz == -size && dz == 0);
                    bool isSide = (isPosX || isNegX || isPosZ || isNegZ);

                    Vector3 offset = Vector3.Zero;

                    if (isSide)
                    {
                        if (isPosX)
                        {
                            offset = Vector3.UnitX;
                        }
                        else if (isPosZ)
                        {
                            offset = Vector3.UnitZ;
                        }
                        else if (isNegX)
                        {
                            offset = -Vector3.UnitX;
                        }
                        else if (isNegZ)
                        {
                            offset = -Vector3.UnitZ;
                        }
                    }

                    // Fill from the top height down to the bottom.
                    for (int y = h - 1; y < averageHeight; y++)
                    {
                        var v = new VoxelHandle(baseVoxel.Chunk,
                                                new LocalVoxelCoordinate((int)localCoord.X, y, (int)localCoord.Z));
                        v.RawSetType(VoxelLibrary.GetVoxelType("Scaffold"));
                        v.QuickSetLiquid(LiquidType.None, 0);

                        if (y == averageHeight - 1)
                        {
                            if (dz >= 0)
                            {
                                balloonPortDesignations.Add(v);
                            }
                            else
                            {
                                treasuryDesignations.Add(v);
                            }
                        }

                        if (isSide)
                        {
                            var ladderPos = new Vector3(worldPos.X, y, worldPos.Z) + offset +
                                            Vector3.One * 0.5f;
                            var ladderVox = new VoxelHandle(chunkManager.ChunkData,
                                                            GlobalVoxelCoordinate.FromVector3(ladderPos));
                            if (ladderVox.IsValid && ladderVox.IsEmpty)
                            {
                                var ladder = EntityFactory.CreateEntity <Ladder>("Ladder", ladderPos);
                                Master.Faction.OwnedObjects.Add(ladder);
                                ladder.Tags.Add("Moveable");
                                ladder.Tags.Add("Deconstructable");
                            }
                        }
                    }
                }
            }

            // Actually create the BuildRoom.
            BalloonPort    toBuild  = new BalloonPort(PlayerFaction, balloonPortDesignations, this);
            BuildRoomOrder buildDes = new BuildRoomOrder(toBuild, roomDes.Faction, this);

            buildDes.Build(true);
            roomDes.DesignatedRooms.Add(toBuild);

            // Also add a treasury
            Treasury treasury = new Treasury(PlayerFaction, treasuryDesignations, this);

            treasury.OnBuilt();
            roomDes.DesignatedRooms.Add(treasury);

            return(toBuild);
        }
Пример #14
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);

            CollideMinions(time);

            List <BuildOrder> removals = (from d in DigDesignations
                                          let vref = d.Vox
                                                     let v = vref
                                                             where v.IsEmpty || v.Health <= 0.0f || v.Type.Name == "empty" || v.Type.IsInvincible
                                                             select d).ToList();

            foreach (BuildOrder v in removals)
            {
                DigDesignations.Remove(v);
            }

            List <Body> gatherRemovals = (from b in GatherDesignations
                                          where b == null || b.IsDead
                                          select b).ToList();

            foreach (Body b in gatherRemovals)
            {
                GatherDesignations.Remove(b);
            }


            removals.Clear();
            foreach (BuildOrder d in GuardDesignations)
            {
                Voxel v = d.Vox;

                if (!v.IsEmpty && !(v.Health <= 0.0f) && v.Type.Name != "empty")
                {
                    continue;
                }

                removals.Add(d);

                if (!v.IsEmpty)
                {
                    v.Kill();
                }
            }

            foreach (BuildOrder v in removals)
            {
                GuardDesignations.Remove(v);
            }

            List <Body> treesToRemove = ChopDesignations.Where(tree => tree.IsDead).ToList();

            foreach (Body tree in treesToRemove)
            {
                ChopDesignations.Remove(tree);
            }

            List <Body> attacksToRemove = AttackDesignations.Where(body => body.IsDead).ToList();

            foreach (Body body in attacksToRemove)
            {
                AttackDesignations.Remove(body);
            }

            HandleThreats();
        }