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(); }
public void Update(DwarfTime time) { RoomBuilder.CheckRemovals(); Minions.RemoveAll(m => m.IsDead); SelectedMinions.RemoveAll(m => m.IsDead); Minions.ForEach(m => m.Creature.SelectionCircle.IsVisible = false); SelectedMinions.ForEach(m => m.Creature.SelectionCircle.IsVisible = true); 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(); }