-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimeStat.cs
More file actions
42 lines (33 loc) · 959 Bytes
/
Copy pathRuntimeStat.cs
File metadata and controls
42 lines (33 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections.Generic;
namespace UnityRPG.Character.Stats
{
public sealed class RuntimeStat
{
private readonly List<StatModifier> modifiers = new List<StatModifier>();
public float BaseValue { get; }
public float Value
{
get
{
float value = BaseValue;
foreach (StatModifier modifier in modifiers)
value += modifier.Value;
return value;
}
}
public RuntimeStat(float baseValue)
{
BaseValue = baseValue;
}
public void AddModifier(StatModifier modifier)
{
if (modifier == null)
return;
modifiers.Add(modifier);
}
public void RemoveModifiersFromSource(object source)
{
modifiers.RemoveAll(modifier => ReferenceEquals(modifier.Source, source));
}
}
}