Mercurial > repos > IBBoard.WarFoundry.API
diff api/Objects/SystemStats.cs @ 67:e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
* Clean up stat loading for game systems and unit types
* Delete rogue character that stopped code compiling
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 25 Apr 2009 14:59:23 +0000 |
parents | 306558904c2a |
children | 3ea0ab04352b |
line wrap: on
line diff
--- a/api/Objects/SystemStats.cs Sat Apr 11 14:53:45 2009 +0000 +++ b/api/Objects/SystemStats.cs Sat Apr 25 14:59:23 2009 +0000 @@ -12,40 +12,45 @@ /// </summary> public class SystemStats { - private Dictionary<string, StatSlot> stats; + private Dictionary<string, StatSlot> statsByName; + private List<StatSlot> stats; private string id; - public SystemStats(string statsID, StatSlot[] statSlots) + public SystemStats(string statsID) { id = statsID; - stats = new Dictionary<string, StatSlot>(); - - foreach (StatSlot slot in statSlots) - { - slot.SystemStats = this; - stats[slot.Name] = slot; - } - } + statsByName = new Dictionary<string, StatSlot>(); + stats = new List<StatSlot>(); + } + + public void AddStatSlot(string slotName) + { + StatSlot slot = new StatSlot(slotName); + slot.SystemStats = this; + statsByName[slot.Name] = slot; + stats.Add(slot); + } public StatSlot[] StatSlots { get { - StatSlot[] slots = new StatSlot[stats.Count]; - stats.Values.CopyTo(slots, 0); - return slots; + return stats.ToArray(); } } - public StatSlot this[string key] + public StatSlot this[string statName] { get { - StatSlot slot = null; - stats.TryGetValue(key, out slot); - return slot; + return DictionaryUtils.GetValue(statsByName, statName); } } + + public int GetStatSlotPosition(StatSlot slot) + { + return stats.IndexOf(slot); + } public int SlotCount {