/// <summary> /// Adds the locateable to the map. /// </summary> /// <param name="locateable">The locateable object.</param> public void Add(ILocateable locateable) { switch (locateable) { case DroppedItem droppedItem: droppedItem.Id = (ushort)this.dropIdGenerator.GetId(); break; case DroppedMoney droppedMoney: droppedMoney.Id = (ushort)this.dropIdGenerator.GetId(); break; case Player player: player.Id = (ushort)this.objectIdGenerator.GetId(); Interlocked.Increment(ref this.playerCount); break; case NonPlayerCharacter npc: npc.Id = (ushort)this.objectIdGenerator.GetId(); break; case ISupportIdUpdate idUpdate: idUpdate.Id = (ushort)this.objectIdGenerator.GetId(); break; default: throw new ArgumentException($"Adding an object of type {locateable.GetType()} is not supported."); } this.objectsInMap.Add(locateable.Id, locateable); this.areaOfInterestManager.AddObject(locateable); this.ObjectAdded?.Invoke(this, new GameMapEventArgs(this, locateable)); }
/// <summary> /// Adds the locateable to the map. /// </summary> /// <param name="locateable">The locateable object.</param> public void Add(ILocateable locateable) { switch (locateable) { case DroppedItem droppedItem: droppedItem.Id = (ushort)this.dropIdGenerator.GetId(); Log.DebugFormat("{0}: Added drop {1}, {2}", this.Definition, droppedItem.Id, droppedItem.Item); break; case Player player: player.Id = (ushort)this.objectIdGenerator.GetId(); Log.DebugFormat("{0}: Added player {1}, {2}, ", this.Definition, player.Id, player); Interlocked.Increment(ref this.playerCount); break; case NonPlayerCharacter npc: npc.Id = (ushort)this.objectIdGenerator.GetId(); Log.DebugFormat("{0}: Added npc {1}, {2}", this.Definition, npc.Id, npc.Definition.Designation); break; case ISupportIdUpdate idUpdate: idUpdate.Id = (ushort)this.objectIdGenerator.GetId(); Log.DebugFormat("{0}: Added {1}", this.Definition, locateable); break; default: throw new ArgumentException($"Adding an object of type {locateable.GetType()} is not supported."); } this.objectsInMap.Add(locateable.Id, locateable); this.areaOfInterestManager.AddObject(locateable); this.ObjectAdded?.Invoke(this, new GameMapEventArgs(this, locateable)); }