// === SERIALIZATION === public void OnBeforeSerialize() { Dictionary <string, float> statStrings = new Dictionary <string, float>(); foreach (var stat in stats) { statStrings[stat.Key.ToString()] = stat.Value; } serializedStats = new StatDictionary(statStrings); }
private StatSet(StatDictionary stats) : this() { Dictionary <string, float> statStrings = stats.ToDictionary(); this.stats = new Dictionary <StatTag, float>(); foreach (var stat in statStrings) { StatTag result; if (Enum.TryParse(stat.Key, true, out result)) { this.stats[result] = stat.Value; } } }
// === SERIALIZATION === public void OnBeforeSerialize() { serializedStats = new StatDictionary(stats); }
private StatSet(StatDictionary stats) { this.stats = stats.ToDictionary(); }
Stat() { stats = new StatDictionary(); }
public void ClampInBounds() { Assert.Equal(StatDictionary.Clamp(50), 50); }
public void ClampBelow() { Assert.Equal(StatDictionary.Clamp(-50), 0); }
public void ClampAbove() { Assert.Equal(StatDictionary.Clamp(500), 100); }