清理 Player 以及相关组件

This commit is contained in:
2026-09-15 11:31:20 +08:00
parent 88ed35e757
commit 1e4d3ef8d7
15 changed files with 150 additions and 134 deletions
@@ -7,13 +7,11 @@ namespace SepCore.Components
{
public class StatComponent : MonoBehaviour
{
private Dictionary<StatType, List<modifier>> _statModifiers;
private Dictionary<StatType, Action<modifier, bool>> _statModifierCallbacks;
private readonly Dictionary<StatType, List<modifier>> _statModifiers = new();
private readonly Dictionary<StatType, Action<modifier, bool>> _statModifierCallbacks = new();
public void OnInit()
{
_statModifiers = new Dictionary<StatType, List<modifier>>();
_statModifierCallbacks = new Dictionary<StatType, Action<modifier, bool>>();
}
public void OnReset()
@@ -26,13 +24,10 @@ namespace SepCore.Components
{
if (!_statModifiers.TryGetValue(modifier.StatType, out var modifiers))
{
_statModifiers.Add(modifier.StatType, modifiers = new List<modifier>());
modifiers.Add(modifier);
}
else
{
modifiers.Add(modifier);
modifiers = new List<modifier>();
_statModifiers.Add(modifier.StatType, modifiers);
}
modifiers.Add(modifier);
if (_statModifierCallbacks.TryGetValue(modifier.StatType, out var callbacks))
callbacks?.Invoke(modifier, true);
@@ -42,7 +37,7 @@ namespace SepCore.Components
{
if (_statModifiers.TryGetValue(modifier.StatType, out var modifiers))
{
_statModifiers[modifier.StatType].Remove(modifier);
modifiers.Remove(modifier);
}
if (_statModifierCallbacks.TryGetValue(modifier.StatType, out var callbacks))