private void AfterTroopMoved(ActionState state) { if (state == ActionState.Completed) { ICity city; ICity targetCity; ITroopObject troopObject; if (!gameObjectLocator.TryGetObjects(cityId, troopObjectId, out city, out troopObject)) { throw new Exception("City or troop object is missing"); } if (!gameObjectLocator.TryGetObjects(targetCityId, out targetCity)) { //If the target is missing, walk back locker.Lock(city).Do(() => { TroopMovePassiveAction tma = actionFactory.CreateTroopMovePassiveAction(city.Id, troopObject.ObjectId, city.PrimaryPosition.X, city.PrimaryPosition.Y, true, true); ExecuteChainAndWait(tma, AfterTroopMovedHome); }); return; } // Get all of the stationed city id's from the target city since they will be used by the engage attack action CallbackLock.CallbackLockHandler lockAllStationed = delegate { return(targetCity.Troops.StationedHere() .Select(stationedStub => stationedStub.City) .Cast <ILockable>() .ToArray()); }; locker.Lock(lockAllStationed, null, city, targetCity).Do(() => { var bea = actionFactory.CreateCityEngageAttackPassiveAction(cityId, troopObject.ObjectId, targetCityId); ExecuteChainAndWait(bea, AfterBattle); }); } }