public void RemoveSpawns() { Defrag(); for (int i = 0; i < m_Entries.Count; i++) { SpawnerEntry entry = m_Entries[i]; for (int j = entry.Spawned.Count - 1; j >= 0; j--) { ISpawnable e = entry.Spawned[j]; if (e != null) { m_Spawned.Remove(e); entry.Spawned.RemoveAt(j); e.Delete(); } } } if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running) { DoTimer(); } InvalidateProperties(); }
public void RemoveSpawn(SpawnerEntry entry) { for (int i = entry.Spawned.Count - 1; i >= 0; i--) { ISpawnable e = entry.Spawned[i]; if (e != null) { entry.Spawned.RemoveAt(i); m_Spawned.Remove(e); e.Delete(); } } }
public void Despawn() { switch (m_State) { case SpawnState.Respawning: m_Timer.Stop(); break; case SpawnState.Inactive: break; case SpawnState.Active: m_Spawned.Spawner = null; // prevent re-entrancy m_Spawned.Delete(); break; } }
private void InternalDeleteSpawnedObjects() { for (var index = 0; index < m_SpawnedObjects.Count; index++) { ISpawnable spawnable = m_SpawnedObjects[index]; spawnable.Spawner = null; bool uncontrolled = !(spawnable is BaseCreature) || !((BaseCreature)spawnable).Controlled; if (uncontrolled) { spawnable.Delete(); } } m_SpawnedObjects.Clear(); }
public void RemoveEntry(SpawnerEntry entry) { Defrag(); for (int i = entry.Spawned.Count - 1; i >= 0; i--) { ISpawnable e = entry.Spawned[i]; entry.Spawned.RemoveAt(i); if (e != null) { e.Delete(); } } m_Entries.Remove(entry); if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running) { DoTimer(); } InvalidateProperties(); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 7: { GuardImmune = reader.ReadBool(); goto case 6; } case 6: { m_SpawnRange = reader.ReadInt(); goto case 5; } case 5: case 4: { m_WalkingRange = reader.ReadInt(); goto case 3; } case 3: case 2: { m_WayPoint = reader.ReadItem() as WayPoint; goto case 1; } case 1: { m_Group = reader.ReadBool(); goto case 0; } case 0: { m_MinDelay = reader.ReadTimeSpan(); m_MaxDelay = reader.ReadTimeSpan(); m_MaxCount = reader.ReadInt(); m_Team = reader.ReadInt(); m_HomeRange = reader.ReadInt(); m_Running = reader.ReadBool(); TimeSpan ts = TimeSpan.Zero; if (m_Running) { ts = reader.ReadDeltaTime() - DateTime.UtcNow; } int size = reader.ReadInt(); m_SpawnObjects = new List <SpawnObject>(size); for (int i = 0; i < size; ++i) { if (version > 4) { SpawnObject so = new SpawnObject(reader); if (AddSpawnObject(so)) { string typeName = ParseType(so.SpawnName); if (ScriptCompiler.FindTypeByName(typeName) == null) { if (m_WarnTimer == null) { m_WarnTimer = new WarnTimer(); } m_WarnTimer.Add(Location, Map, typeName); } } } else { string creatureString = reader.ReadString(); AddSpawnObject(new SpawnObject(creatureString)); string typeName = ParseType(creatureString); if (ScriptCompiler.FindTypeByName(typeName) == null) { if (m_WarnTimer == null) { m_WarnTimer = new WarnTimer(); } m_WarnTimer.Add(Location, Map, typeName); } } } if (version < 5) { int count = reader.ReadInt(); for (int i = 0; i < count; ++i) { ISpawnable e = World.FindEntity(reader.ReadInt()) as ISpawnable; if (e != null) { e.Delete(); // lets make this easy } } } if (m_Running) { DoTimer(ts); } break; } } if (version < 3 && Weight == 0) { Weight = -1; } }