using System; using System.Collections.Generic; using System.Linq; using game; public class BuffSettings { private readonly List _loadedBuffs = null; public BuffSettings(ConfGameBuffs config) { _loadedBuffs = new List(config.buffs.Count); for (int i = 0; i < config.buffs.Count; i++) { var buffConfig = config.buffs[i]; if (_loadedBuffs.Contains(b => b.Type == buffConfig.buffType)) throw new InvalidOperationException($"The {nameof(config)} contains a duplicate buff."); _loadedBuffs.Add(new Buff(buffConfig)); } Log.Debug($"BuffSettings.Constructor: uploaded successfully {_loadedBuffs.Count}"); } public bool TryGet(EnumBuffType type, out Buff value) { value = _loadedBuffs.FirstOrDefault(b => b.Type == type); return value != null; } }