32 lines
957 B
C#
32 lines
957 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using game;
|
|
|
|
public class BuffSettings
|
|
{
|
|
private readonly List<Buff> _loadedBuffs = null;
|
|
|
|
public BuffSettings(ConfGameBuffs config)
|
|
{
|
|
_loadedBuffs = new List<Buff>(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;
|
|
}
|
|
} |