Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff API/Commands/CreateAndAddUnitCommand.cs @ 472:e6c93ceba119
Re #359: Add "only contained" attribute to unit types
* Make sure we add and remove from the parent unit appropriately
* Make sure that setting the unit's parent to null removes it from the parent
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 16 Apr 2012 20:14:23 +0100 |
parents | 0a2068897793 |
children | e47cb422aac1 |
line wrap: on
line diff
--- a/API/Commands/CreateAndAddUnitCommand.cs Sun Apr 15 20:52:32 2012 +0100 +++ b/API/Commands/CreateAndAddUnitCommand.cs Mon Apr 16 20:14:23 2012 +0100 @@ -47,19 +47,20 @@ public override bool Execute() { addedUnit = new Unit(addedUnitType, armyCat); - addedUnit.ParentUnit = parentUnit; - this.Redo(); + Redo(); return true; } public override void Redo() { + addedUnit.ParentUnit = parentUnit; armyCat.AddUnit(addedUnit); } public override void Undo() { armyCat.RemoveUnit(addedUnit); + addedUnit.ParentUnit = null; } public override string Name