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); }
public void OnDeserialized(StreamingContext ctx) { World = ((WorldManager)ctx.Context); HandleThreatsTimer = new Timer(1.0f, false, Timer.TimerMode.Real); if (Threats == null) { Threats = new List <Creature>(); } if (Minions == null) { Minions = new List <CreatureAI>(); } Threats.RemoveAll(threat => threat == null || threat.IsDead); Minions.RemoveAll(minion => minion == null || minion.IsDead); }
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); }
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); 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(); }