Mercurial > repos > snowblizz-super-API-ideas
changeset 118:d39de20f2ba1
Re #54: Add army loading support
* Fix exceptions when loading army with units:
* Remove obsolete methods
* Add EnsureLoaded call to various getters to make sure that all required values are always loaded
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 23 Aug 2009 10:28:03 +0000 |
parents | 093ee2da0f6e |
children | 0cdc0b07fe11 |
files | api/Objects/Race.cs |
diffstat | 1 files changed, 8 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Objects/Race.cs Sat Aug 22 20:02:29 2009 +0000 +++ b/api/Objects/Race.cs Sun Aug 23 10:28:03 2009 +0000 @@ -32,16 +32,6 @@ subID = (raceSubID == null ? "" : raceSubID); system = gameSystem; } - - [Obsolete("Use constructor with GameSystem argument instead")] - public Race(string raceID, string raceName, string gameSystemID, IWarFoundryFactory creatingFactory) : this(raceID, "", raceName, WarFoundryLoader.GetDefault().GetGameSystem(gameSystemID), creatingFactory) - { - } - - [Obsolete("Use constructor with GameSystem argument instead")] - public Race(string raceID, string raceSubID, string raceName, string gameSystemID, IWarFoundryFactory creatingFactory) : this(raceID, raceSubID, raceName, WarFoundryLoader.GetDefault().GetGameSystem(gameSystemID), creatingFactory) - { - } public string SubID { @@ -113,6 +103,7 @@ public bool HasCategoryOverrides() { + EnsureFullyLoaded(); return categories.Count > 0; } @@ -122,15 +113,6 @@ equipment.Add(item.ID, item); } - [Obsolete("Use AddEquipmentItem method instead")] - public void SetEquipmentItems(Dictionary<string, EquipmentItem> items) - { - foreach (EquipmentItem item in items.Values) - { - AddEquipmentItem(item); - } - } - public EquipmentItem GetEquipmentItem(string id) { EnsureFullyLoaded(); @@ -139,6 +121,7 @@ public List<EquipmentItem> GetEquipmentList() { + EnsureFullyLoaded(); List<EquipmentItem> items = new List<EquipmentItem>(); foreach (EquipmentItem item in equipment.Values) @@ -155,17 +138,9 @@ unitTypes.Add(type.ID, type); } - [Obsolete("Use AddUnitType method instead")] - public void SetUnitTypes(Dictionary<string, UnitType> types) - { - foreach (UnitType type in types.Values) - { - AddUnitType(type); - } - } - public UnitType[] GetUnitTypes(Category cat) { + EnsureFullyLoaded(); BuildUnitTypesByCategoryCache(); Dictionary<string, UnitType> unitTypesDictionary; unitTypesByCat.TryGetValue(cat, out unitTypesDictionary); @@ -222,13 +197,13 @@ public UnitType GetUnitType(string id) { - UnitType type = null; - unitTypes.TryGetValue(id, out type); - return type; + EnsureFullyLoaded(); + return DictionaryUtils.GetValue(unitTypes, id); } public List<Ability> GetAbilityList() { + EnsureFullyLoaded(); List<Ability> items = new List<Ability>(); items.AddRange(abilities.Values); return items; @@ -251,9 +226,8 @@ public Ability GetAbility(string id) { - Ability ability = null; - abilities.TryGetValue(id, out ability); - return ability; + EnsureFullyLoaded(); + return DictionaryUtils.GetValue(abilities, id); } protected virtual Dictionary<string, UnitType> RaceUnitTypes