迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
@@ -7,13 +7,13 @@ namespace SepCore.Components
|
||||
{
|
||||
public class StatComponent : MonoBehaviour
|
||||
{
|
||||
private Dictionary<StatType, List<StatModifier>> _statModifiers;
|
||||
private Dictionary<StatType, Action<StatModifier, bool>> _statModifierCallbacks;
|
||||
private Dictionary<StatType, List<modifier>> _statModifiers;
|
||||
private Dictionary<StatType, Action<modifier, bool>> _statModifierCallbacks;
|
||||
|
||||
public void OnInit()
|
||||
{
|
||||
_statModifiers = new Dictionary<StatType, List<StatModifier>>();
|
||||
_statModifierCallbacks = new Dictionary<StatType, Action<StatModifier, bool>>();
|
||||
_statModifiers = new Dictionary<StatType, List<modifier>>();
|
||||
_statModifierCallbacks = new Dictionary<StatType, Action<modifier, bool>>();
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
@@ -22,11 +22,11 @@ namespace SepCore.Components
|
||||
_statModifierCallbacks.Clear();
|
||||
}
|
||||
|
||||
public void AddModifier(StatModifier modifier)
|
||||
public void AddModifier(modifier modifier)
|
||||
{
|
||||
if (!_statModifiers.TryGetValue(modifier.StatType, out var modifiers))
|
||||
{
|
||||
_statModifiers.Add(modifier.StatType, modifiers = new List<StatModifier>());
|
||||
_statModifiers.Add(modifier.StatType, modifiers = new List<modifier>());
|
||||
modifiers.Add(modifier);
|
||||
}
|
||||
else
|
||||
@@ -38,7 +38,7 @@ namespace SepCore.Components
|
||||
callbacks?.Invoke(modifier, true);
|
||||
}
|
||||
|
||||
public void RemoveModifier(StatModifier modifier)
|
||||
public void RemoveModifier(modifier modifier)
|
||||
{
|
||||
if (_statModifiers.TryGetValue(modifier.StatType, out var modifiers))
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace SepCore.Components
|
||||
callbacks?.Invoke(modifier, false);
|
||||
}
|
||||
|
||||
public void Subscribe(StatType statType, Action<StatModifier, bool> callback)
|
||||
public void Subscribe(StatType statType, Action<modifier, bool> callback)
|
||||
{
|
||||
if (!_statModifierCallbacks.TryAdd(statType, callback))
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace SepCore.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void Unsubscribe(StatType statType, Action<StatModifier, bool> callback)
|
||||
public void Unsubscribe(StatType statType, Action<modifier, bool> callback)
|
||||
{
|
||||
if (!_statModifierCallbacks.TryGetValue(statType, out var callbacks))
|
||||
{
|
||||
@@ -79,23 +79,23 @@ namespace SepCore.Components
|
||||
|
||||
foreach (var modifier in modifiers)
|
||||
{
|
||||
if (modifier.IsPercent) result.Percent += modifier.Value;
|
||||
else result.Value += modifier.Value;
|
||||
if (modifier.IsPercent) result.Percent += modifier.RealValue;
|
||||
else result.Value += modifier.RealValue;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void UpdateStat(StatProperty stat, StatModifier modifier, bool isApply)
|
||||
public void UpdateStat(StatProperty stat, modifier modifier, bool isApply)
|
||||
{
|
||||
float coef = isApply ? 1f : -1f;
|
||||
if (modifier.IsPercent)
|
||||
{
|
||||
stat.Percent += modifier.Value * coef;
|
||||
stat.Percent += modifier.RealValue * coef;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat.Value += modifier.Value * coef;
|
||||
stat.Value += modifier.RealValue * coef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user