public void Defrag() { for (int i = 0; i < m_pups.Count; ++i) { try { object o = m_pups[i]; WolfPup pup = o as WolfPup; if (pup == null || !pup.Alive) { m_pups.RemoveAt(i); --i; } else if (pup.Controlled || pup.IsStabled) { pup.Mother = null; m_pups.RemoveAt(i); --i; } } catch (Exception e) { Console.WriteLine("/nException Caught in MotherWolf Defrag: /n{0}/n", e); } } }
public void Defrag() { for (int i = 0; i < m_Pups.Count; ++i) { try { object o = m_Pups[i]; WolfPup pup = o as WolfPup; if (pup == null || !pup.Alive) { m_Pups.RemoveAt(i); --i; } else if (pup.Controlled || pup.IsStabled) { pup.Mother = null; m_Pups.RemoveAt(i); --i; } } catch {} } }
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) { WolfPup pup = new WolfPup(); bool validLocation = false; Point3D loc = this.Location; for (int j = 0; !validLocation && j < 10; ++j) { int x = X + Utility.Random(5) - 1; int y = Y + Utility.Random(5) - 1; int z = map.GetAverageZ(x, y); if (validLocation = map.CanFit(x, y, this.Z, 16, false, false)) { loc = new Point3D(x, y, Z); } else if (validLocation = map.CanFit(x, y, z, 16, false, false)) { loc = new Point3D(x, y, z); } } pup.Mother = this; pup.Team = this.Team; pup.Home = this.Location; pup.HomeMap = this.Map; pup.RangeHome = (hr > 4 ? 4 : hr); pup.MoveToWorld(loc, map); m_Pups.Add(pup); } }
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 ) { WolfPup pup = new WolfPup(); bool validLocation = false; Point3D loc = this.Location; for ( int j = 0; !validLocation && j < 10; ++j ) { int x = X + Utility.Random( 5 ) - 1; int y = Y + Utility.Random( 5 ) - 1; int z = map.GetAverageZ( x, y ); if ( validLocation = map.CanFit( x, y, this.Z, 16, false, false ) ) loc = new Point3D( x, y, Z ); else if ( validLocation = map.CanFit( x, y, z, 16, false, false ) ) loc = new Point3D( x, y, z ); } pup.Mother = this; pup.Team = this.Team; pup.Home = this.Location; pup.RangeHome = ( hr > 4 ? 4 : hr ); pup.MoveToWorld( loc, map ); m_pups.Add( pup ); } }