using System.Collections.Generic; using WingsEmu.Game.GameEvent; namespace WingsEmu.Plugins.GameEvents { public class GameEventInstanceManager : IGameEventInstanceManager { private readonly Dictionary> _gameEventInstances = new(); public IReadOnlyCollection GetGameEventsByType(GameEventType gameEventType) => _gameEventInstances.TryGetValue(gameEventType, out List gameEventInstance) ? gameEventInstance : null; public void AddGameEvent(IGameEventInstance gameEventInstance) { if (_gameEventInstances.TryGetValue(gameEventInstance.GameEventType, out List gameEventInstances)) { gameEventInstances.Add(gameEventInstance); return; } _gameEventInstances[gameEventInstance.GameEventType] = new List { gameEventInstance }; } public void RemoveGameEvent(IGameEventInstance gameEventInstance) { if (_gameEventInstances.TryGetValue(gameEventInstance.GameEventType, out List gameEventInstances)) { gameEventInstances.Remove(gameEventInstance); } } } }