public UberSpawnerEntry(UberSpawner parent, GenericReader reader) { int version = reader.ReadInt(); m_SpawnedName = reader.ReadString(); m_SpawnedProbability = reader.ReadInt(); m_SpawnedMaxCount = reader.ReadInt(); m_Properties = reader.ReadString(); m_Parameters = reader.ReadString(); int count = reader.ReadInt(); m_Spawned = new List <ISpawnable>(count); for (int i = 0; i < count; ++i) { //IEntity e = World.FindEntity( reader.ReadInt() ); ISpawnable e = reader.ReadEntity() as ISpawnable; if (e != null) { e.Spawner = parent; if (e is BaseCreature) { ((BaseCreature)e).RemoveIfUntamed = true; } m_Spawned.Add(e); if (!parent.Spawned.ContainsKey(e)) { parent.Spawned.Add(e, this); } } } }
public void Defrag(UberSpawner parent) { for (int i = 0; i < m_Spawned.Count; ++i) { ISpawnable e = m_Spawned[i]; bool remove = false; if (e is Item) { Item item = (Item)e; if (item.Deleted || item.RootParent is Mobile || item.IsLockedDown || item.IsSecure || item.Spawner == null) { remove = true; } } else if (e is Mobile) { Mobile m = (Mobile)e; if (m.Deleted) { remove = true; } else if (m is BaseCreature) { BaseCreature c = (BaseCreature)m; if (c.Controlled || c.IsStabled) { remove = true; } /* * else if ( c.Combatant == null && ( c.GetDistanceToSqrt( Location ) > (c.RangeHome * 4) ) ) * { * //m_Spawned[i].Delete(); * m_Spawned.RemoveAt( i ); * --i; * c.Delete(); * remove = true; * } */ } else if (m.Spawner == null) { remove = true; } } else { remove = true; } if (remove) { m_Spawned.RemoveAt(i--); if (parent.Spawned.ContainsKey(e)) { parent.Spawned.Remove(e); } } } }
public void Defrag(UberSpawner parent) { for (int i = 0; i < m_Spawned.Count; ++i) { ISpawnable e = m_Spawned[i]; bool remove = false; if (e is Item) { Item item = (Item)e; if (item.Deleted || item.RootParent is Mobile || item.IsLockedDown || item.IsSecure || item.Spawner == null) remove = true; } else if (e is Mobile) { Mobile m = (Mobile)e; if (m.Deleted) remove = true; else if (m is BaseCreature) { BaseCreature c = (BaseCreature)m; if (c.Controlled || c.IsStabled) remove = true; /* else if ( c.Combatant == null && ( c.GetDistanceToSqrt( Location ) > (c.RangeHome * 4) ) ) { //m_Spawned[i].Delete(); m_Spawned.RemoveAt( i ); --i; c.Delete(); remove = true; } */ } else if (m.Spawner == null) remove = true; } else remove = true; if (remove) { m_Spawned.RemoveAt(i--); if (parent.Spawned.ContainsKey(e)) parent.Spawned.Remove(e); } } }
public UberSpawnerEntry(UberSpawner parent, GenericReader reader) { int version = reader.ReadInt(); m_SpawnedName = reader.ReadString(); m_SpawnedProbability = reader.ReadInt(); m_SpawnedMaxCount = reader.ReadInt(); m_Properties = reader.ReadString(); m_Parameters = reader.ReadString(); int count = reader.ReadInt(); m_Spawned = new List<ISpawnable>(count); for (int i = 0; i < count; ++i) { //IEntity e = World.FindEntity( reader.ReadInt() ); ISpawnable e = reader.ReadEntity() as ISpawnable; if (e != null) { e.Spawner = parent; if (e is BaseCreature) ((BaseCreature)e).RemoveIfUntamed = true; m_Spawned.Add(e); if (!parent.Spawned.ContainsKey(e)) parent.Spawned.Add(e, this); } } }