server-master/srcs/_plugins/WingsEmu.Plugins.GameEvents/GameEventInstanceManager.cs
2026-02-10 18:21:30 +01:00

35 lines
No EOL
1.3 KiB
C#

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