# HG changeset patch # User IBBoard # Date 1239301671 0 # Node ID aa2d05a9c635340f9138686e0cac9c3c41922b45 # Parent 2094bd0ba6520795619d1708d920302ec339b8bb Re #61 - Complete structure of WarFoundry API objects * Add parent links to Units (inverse of r97) diff -r 2094bd0ba652 -r aa2d05a9c635 api/Objects/Unit.cs --- a/api/Objects/Unit.cs Thu Apr 09 15:36:22 2009 +0000 +++ b/api/Objects/Unit.cs Thu Apr 09 18:27:51 2009 +0000 @@ -17,8 +17,8 @@ { private UnitType type; private int size; - private Army army; - private Race race; + private Army army; + private Unit parentUnit; private double points; private ArmyCategory cat; private Dictionary equipment = new Dictionary(); @@ -158,8 +158,7 @@ public Race Race { - get { return race; } - set { race = value; } + get { return UnitType.Race; } } public ArmyCategory Category @@ -211,6 +210,8 @@ { containedUnits.Add(unit); } + + unit.ParentUnit = this; } else { @@ -221,6 +222,23 @@ public void RemoveContainedUnit(Unit unit) { containedUnits.Remove(unit); + } + + public Unit ParentUnit + { + get { return parentUnit; } + set + { + if (!(parentUnit == value || (parentUnit != null && parentUnit.Equals(value)))) + { + parentUnit = value; + + if (value!=null) + { + value.AddContainedUnit(this); + } + } + } } public UnitEquipmentItem[] GetAllowedOptionalEquipment()