annotate api/Objects/Race.cs @ 310:f7c3c1b39726

Re #99: Define "points" values in GameSystem * Inline some local variables for readability * Define defaults in schema no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 20 Feb 2011 20:36:48 +0000
parents 92d10b06ab0f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
1 // This file (Race.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
2 //
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
4
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
5 using System;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
6 using System.Collections.Generic;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
7 using System.IO;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
8 using System.Xml;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
9 using IBBoard.IO;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
10 using IBBoard.WarFoundry.API.Factories;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
11
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
12 namespace IBBoard.WarFoundry.API.Objects
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
13 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
14 public class Race : WarFoundryStagedLoadingObject
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
15 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
16 public static string SYSTEM_DEFAULT_RACE_ID = "GameDefault";
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
17
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
18 private string subID;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
19 private GameSystem system;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
20 private string defaultArmyName = "";
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
21 private Dictionary<Category, Dictionary<string, UnitType>> unitTypesByCat;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
22 private Dictionary<string, UnitType> unitTypes = new Dictionary<string,UnitType>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
23 private Dictionary<string, EquipmentItem> equipment = new Dictionary<string,EquipmentItem>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
24 private Dictionary<string, Ability> abilities = new Dictionary<string,Ability>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
25 private Dictionary<string, Category> categories = new Dictionary<string,Category>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
26 private Dictionary<string, UnitMemberType> memberTypes = new Dictionary<string, UnitMemberType>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
27
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
28 public Race(string raceID, string raceName, GameSystem gameSystem, IWarFoundryFactory creatingFactory) : this(raceID, "", raceName, gameSystem, creatingFactory)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
29 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
30 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
31
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
32 public Race(string raceID, string raceSubID, string raceName, GameSystem gameSystem, IWarFoundryFactory creatingFactory) : base(raceID + (raceSubID != "" ? "_" + raceSubID : ""), raceName, creatingFactory)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
33 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
34 subID = (raceSubID == null ? "" : raceSubID);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
35 system = gameSystem;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
36 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
37
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
38 public string SubID
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
39 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
40 get { return subID; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
41 set { subID = (value == null ? "" : value.Trim()); }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
42 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
43
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
44 public GameSystem GameSystem
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
45 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
46 get { return system; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
47 set
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
48 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
49 if (value == null)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
50 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
51 throw new ArgumentException("Game system for a race cannot be null");
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
52 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
53
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
54 system = value;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
55 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
56 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
57
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
58 public string ArmyDefaultName
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
59 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
60 get { return defaultArmyName; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
61 set
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
62 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
63 if (value == null)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
64 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
65 throw new ArgumentException("No default army name");
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
66 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
67
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
68 defaultArmyName = value;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
69 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
70 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
71
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
72 public void AddCategory(Category cat)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
73 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
74 categories[cat.ID] = cat;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
75 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
76
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
77 /// <summary>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
78 /// Gets a category from its ID. Attempts to get the category from the race's overrides, or else it falls back to getting the Game System's category with that ID.
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
79 /// </summary>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
80 /// <param name="id">
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
81 /// The ID of the category to get
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
82 /// </param>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
83 /// <returns>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
84 /// The <code>Category</code> with the specified ID, or null if one doesn't exist.
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
85 /// </returns>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
86 public Category GetCategory(string id)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
87 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
88 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
89 Category cat = null;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
90 categories.TryGetValue(id, out cat);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
91
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
92 if (cat == null)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
93 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
94 cat = GameSystem.GetCategory(id);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
95 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
96
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
97 return cat;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
98 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
99
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
100 public Category[] Categories
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
101 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
102 get
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
103 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
104 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
105 Category[] cats;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
106
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
107 if (!HasCategoryOverrides())
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
108 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
109 cats = GameSystem.Categories;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
110 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
111 else
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
112 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
113 cats = DictionaryUtils.ToArray<string, Category>(categories);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
114 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
115
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
116 return cats;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
117 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
118 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
119
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
120 public bool HasCategoryOverrides()
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
121 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
122 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
123 return categories.Count > 0;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
124 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
125
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
126 public void AddEquipmentItem(EquipmentItem item)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
127 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
128 //TODO: Throw DuplicateItemException
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
129 equipment.Add(item.ID, item);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
130 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
131
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
132 public EquipmentItem GetEquipmentItem(string id)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
133 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
134 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
135 return DictionaryUtils.GetValue(equipment, id);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
136 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
137
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
138 public List<EquipmentItem> GetEquipmentList()
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
139 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
140 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
141 List<EquipmentItem> items = new List<EquipmentItem>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
142
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
143 foreach (EquipmentItem item in equipment.Values)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
144 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
145 items.Add(item);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
146 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
147
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
148 return items;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
149 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
150
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
151 public void AddUnitType(UnitType type)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
152 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
153 CacheUnitType(type);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
154 unitTypes.Add(type.ID, type);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
155 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
156
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
157 public UnitType[] GetUnitTypes(Category cat)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
158 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
159 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
160 BuildUnitTypesByCategoryCache();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
161 Dictionary<string, UnitType> unitTypesDictionary;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
162 unitTypesByCat.TryGetValue(cat, out unitTypesDictionary);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
163 UnitType[] unitTypesArray;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
164
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
165 if (unitTypesDictionary == null)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
166 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
167 unitTypesArray = new UnitType[0];
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
168 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
169 else
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
170 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
171 unitTypesArray = DictionaryUtils.ToArray<string, UnitType>(unitTypesDictionary);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
172 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
173
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
174 return unitTypesArray;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
175 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
176
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
177 private void CacheUnitType(UnitType unit)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
178 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
179 BuildUnitTypesByCategoryCache();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
180
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
181 foreach (Category cat in unit.Categories)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
182 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
183 Dictionary<string, UnitType> catUnitTypes = DictionaryUtils.GetValue(unitTypesByCat, cat);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
184
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
185 if (catUnitTypes == null)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
186 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
187 throw new InvalidFileException(String.Format("Unit type {0} with name {1} is a unit of an undefined category ({2})", unit.ID, unit.Name, cat.ID));
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
188 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
189
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
190 catUnitTypes.Add(unit.ID, unit);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
191 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
192 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
193
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
194 private void BuildUnitTypesByCategoryCache()
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
195 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
196 if (unitTypesByCat == null)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
197 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
198 DoBuildUnitTypesByCategoryCache();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
199 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
200 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
201
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
202 private void DoBuildUnitTypesByCategoryCache()
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
203 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
204 unitTypesByCat = new Dictionary<Category,Dictionary<string,UnitType>>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
205
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
206 foreach (Category category in Categories)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
207 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
208 unitTypesByCat.Add(category, new Dictionary<string, UnitType>());
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
209 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
210
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
211 foreach (UnitType unit in unitTypes.Values)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
212 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
213 CacheUnitType(unit);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
214 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
215 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
216
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
217 public UnitType GetUnitType(string id)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
218 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
219 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
220 return DictionaryUtils.GetValue(unitTypes, id);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
221 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
222
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
223 public List<Ability> GetAbilityList()
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
224 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
225 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
226 List<Ability> items = new List<Ability>();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
227 items.AddRange(abilities.Values);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
228 return items;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
229 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
230
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
231 public void AddAbility(Ability newAbility)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
232 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
233 //TODO: Throw DuplicateItemException
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
234 abilities.Add(newAbility.ID, newAbility);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
235 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
236
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
237 public Ability GetAbility(string id)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
238 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
239 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
240 return DictionaryUtils.GetValue(abilities, id);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
241 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
242
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
243 protected virtual Dictionary<string, UnitType> RaceUnitTypes
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
244 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
245 get { return RaceRawUnitTypes; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
246 set { RaceRawUnitTypes = value; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
247 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
248
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
249 protected virtual Dictionary<string, EquipmentItem> RaceEquipment
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
250 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
251 get { return RaceRawEquipment; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
252 set { RaceRawEquipment = value; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
253 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
254
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
255 protected virtual Dictionary<string, Ability> RaceAbilities
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
256 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
257 get { return RaceRawAbilities; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
258 set { RaceRawAbilities = value; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
259 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
260
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
261 protected Dictionary<string, UnitType> RaceRawUnitTypes
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
262 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
263 get { return unitTypes; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
264 set { unitTypes = value; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
265 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
266
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
267 protected Dictionary<string, EquipmentItem> RaceRawEquipment
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
268 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
269 get { return equipment; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
270 set { equipment = value; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
271 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
272
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
273 protected Dictionary<string, Ability> RaceRawAbilities
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
274 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
275 get { return abilities; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
276 set { abilities = value; }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
277 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
278
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
279 public void AddUnitMemberType(UnitMemberType memberType)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
280 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
281 memberTypes[memberType.ID] = memberType;
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
282 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
283
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
284 /// <summary>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
285 /// Gets a unit member type by its ID.
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
286 /// </summary>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
287 /// <param name="id">
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
288 /// The ID of the unit member type to get
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
289 /// </param>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
290 /// <returns>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
291 /// The <code>UnitMemberType</code> with the specified ID, or null if one doesn't exist.
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
292 /// </returns>
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
293 public UnitMemberType GetUnitMemberType(string id)
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
294 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
295 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
296 return DictionaryUtils.GetValue(memberTypes, id);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
297 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
298
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
299 public UnitMemberType[] UnitMemberTypes
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
300 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
301 get
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
302 {
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
303 EnsureFullyLoaded();
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
304 return DictionaryUtils.ToArray(memberTypes);
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
305 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
306 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
307 }
cd657faa0c05 * Merge branch into trunk (branch contained some fixes that should have been made on trunk)
IBBoard <dev@ibboard.co.uk>
parents: 258
diff changeset
308 }