private async Task SpawnerSpawned(ISpawnable spawned, IMap map) { if (spawned.GetType() == typeof(GridEntity)) { var entity = (GridEntity)spawned; entity.Died += EntityDied; } else { var itemsUpdate = MudLikeOperationBuilder.Start("itemlist").AddItems(map.Items) .Build(); await Game.Network.SendViewCommandsToMapAsync(map, MudLikeViewBuilder.Start().AddOperation(itemsUpdate).Build()); } }
private void UpdateList(List <INpc> list) { List <int> indicesToRemove = new List <int>(); for (int i = 0; i < list.Count; i++) { ISpawnable item = list[i]; item.Update(); if (item.SafeToDespawn) { if (item.GetType() == typeof(Aquamentus) || item.GetType() == typeof(Skeleton) || item.GetType() == typeof(Goriya) || item.GetType() == typeof(Hand)) { itemDropper.DropItem(item.Position); } indicesToRemove.Add(i); } } for (int i = 0; i < indicesToRemove.Count; i++) { list.RemoveAt(indicesToRemove[i] - i); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_Spawned = new Dictionary <ISpawnable, SpawnerEntry>(); if (version < 7) { m_Entries = new List <SpawnerEntry>(); } switch (version) { case 7: { int size = reader.ReadInt(); m_Entries = new List <SpawnerEntry>(size); for (int i = 0; i < size; ++i) { m_Entries.Add(new SpawnerEntry(this, reader)); } goto case 4; //Skip the other crap } case 6: { int size = reader.ReadInt(); bool addentries = m_Entries.Count == 0; for (int i = 0; i < size; ++i) { if (addentries) { m_Entries.Add(new SpawnerEntry(String.Empty, 100, reader.ReadInt())); } else { m_Entries[i].SpawnedMaxCount = reader.ReadInt(); } } goto case 5; } case 5: { int size = reader.ReadInt(); bool addentries = m_Entries.Count == 0; for (int i = 0; i < size; ++i) { if (addentries) { m_Entries.Add(new SpawnerEntry(String.Empty, reader.ReadInt(), 1)); } else { m_Entries[i].SpawnedProbability = reader.ReadInt(); } } goto case 4; } 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_Count = 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; } if (version < 7) { int size = reader.ReadInt(); bool addentries = m_Entries.Count == 0; for (int i = 0; i < size; ++i) { string typeName = reader.ReadString(); if (addentries) { m_Entries.Add(new SpawnerEntry(typeName, 100, 1)); } else { m_Entries[i].SpawnedName = typeName; } if (SpawnerType.GetType(typeName) == null) { if (m_WarnTimer == null) { m_WarnTimer = new WarnTimer(); } m_WarnTimer.Add(Location, Map, typeName); } } int count = reader.ReadInt(); for (int i = 0; i < count; ++i) { ISpawnable e = reader.ReadEntity() as ISpawnable; if (e != null) { if (e is BaseCreature) { ((BaseCreature)e).RemoveIfUntamed = true; } e.Spawner = this; for (int j = 0; j < m_Entries.Count; j++) { if (SpawnerType.GetType(m_Entries[j].SpawnedName) == e.GetType()) { m_Entries[j].Spawned.Add(e); m_Spawned.Add(e, m_Entries[j]); break; } } } } } DoTimer(ts); break; } } if (version < 4) { m_WalkingRange = m_HomeRange; } }