diff api/Objects/UnitEquipmentItem.cs @ 85:46ad6f478203

Re #50: Complete core loading of WarFoundry XML files * Start loading of UnitEquipmentItems * Fix XPath queries for equipment items and abilities * Allow UnitEquipmentItem to be created without a UnitType * Make adding UnitEquipmentItem to UnitType set UnitType of UnitEquipmentItem * Make loading of abilities and equipment items add the item to the race Also: * Code cleanup (line endings) * Make method to get equipment by ID return null instead of throwing "no such key" exception
author IBBoard <dev@ibboard.co.uk>
date Sat, 01 Aug 2009 16:06:25 +0000
parents 3ea0ab04352b
children 729d9e54162c
line wrap: on
line diff
--- a/api/Objects/UnitEquipmentItem.cs	Sun Jul 05 09:50:40 2009 +0000
+++ b/api/Objects/UnitEquipmentItem.cs	Sat Aug 01 16:06:25 2009 +0000
@@ -25,10 +25,9 @@
 		private string mutexGroup;
 		private UnitType unitType;
 
-		protected UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipForType)
+		public UnitEquipmentItem(EquipmentItem equipmentItem)
 		{
 			item = equipmentItem;
-			EquipmentForUnit = equipForType;
 		}
 		
 		public override string Name
@@ -98,6 +97,7 @@
 				if (value != null)
 				{
 					unitType = value;
+					unitType.AddEquipmentItem(this);
 				}
 			}
 		}
@@ -175,6 +175,10 @@
 			{
 				return false;
 			}
+			else if (EquipmentForUnit == null)
+			{
+				return false;
+			}
 			else
 			{
 				//If the number of items in the MutEx group is greater than one then it must be this item plus another