public void Defrag() { for (int i = 0; i < m_pups.Count; ++i) { try { object o = m_pups[i]; UnicornPup pup = o as UnicornPup; if (pup == null || !pup.Alive) { m_pups.RemoveAt(i); --i; } else if (pup.Controlled || pup.IsStabled) { pup.Queen = null; m_pups.RemoveAt(i); --i; } } catch (Exception e) { Console.WriteLine("\nException Caught in UnicornQueenMOTM Defrag: \n{0}\n", e); } } }
public void SpawnBabies() { Defrag(); int family = m_pups.Count; if (family >= pupCount) { return; } //Say( "family {0}, should be {1}", family, pupCount ); Map map = this.Map; if (map == null) { return; } int hr = (int)((this.RangeHome + 1) / 2); for (int i = family; i < pupCount; ++i) { UnicornPup pup = new UnicornPup(); bool validLocation = false; Point3D loc = this.Location; for (int j = 0; !validLocation && j < 10; ++j) { int x = X + Utility.Random(10) - 5; int y = Y + Utility.Random(10) - 5; int z = map.GetAverageZ(x, y); if (validLocation = map.CanFit(x, y, this.Z, 16, false, false)) { loc = new Point3D(x, y, Z); break; } else if (validLocation = map.CanFit(x, y, z, 16, false, false)) { loc = new Point3D(x, y, z); break; } } pup.Queen = this; pup.Team = this.Team; pup.Home = this.Location; pup.RangeHome = (hr > 4 ? 4 : hr); pup.MoveToWorld(loc, map); m_pups.Add(pup); } respawn_previous = DateTime.Now; }
public void SpawnBabies() { Defrag(); int family = m_pups.Count; if (family >= pupCount) return; //Say( "family {0}, should be {1}", family, pupCount ); Map map = this.Map; if (map == null) return; int hr = (int)((this.RangeHome + 1) / 2); for (int i = family; i < pupCount; ++i) { UnicornPup pup = new UnicornPup(); bool validLocation = false; Point3D loc = this.Location; for (int j = 0; !validLocation && j < 10; ++j) { int x = X + Utility.Random(10) - 5; int y = Y + Utility.Random(10) - 5; int z = map.GetAverageZ(x, y); if (validLocation = map.CanFit(x, y, this.Z, 16, false, false)) { loc = new Point3D(x, y, Z); break; } else if (validLocation = map.CanFit(x, y, z, 16, false, false)) { loc = new Point3D(x, y, z); break; } } pup.Queen = this; pup.Team = this.Team; pup.Home = this.Location; pup.RangeHome = (hr > 4 ? 4 : hr); pup.MoveToWorld(loc, map); m_pups.Add(pup); } respawn_previous = DateTime.Now; }