public override IEnumerable <IActionEffect> Execute() { GameEntity entityToRelease = Contexts.sharedInstance.game.GetEntityWithId(Entity.entityHolder.EntityHeld); Position?newPosition = _firstPlaceInAreaFinder.FindForItem(Entity.position.Position); entityToRelease.ReplacePosition(newPosition.Value); entityToRelease.AddEnergy(1f, 0f); entityToRelease.isCarryable = true; Entity.ReplaceEntityHolder(Guid.Empty); IActionEffect effect = ActionEffectFactory .CreateLambdaEffect(viewController => viewController.DropHeldEntity(entityToRelease), Entity.view.Controller); yield return(effect); }
public override IEnumerable <IActionEffect> Execute() { if (Entity.entityHolder.EntityHeld != Guid.Empty || ItemToPickUp.hasHeld) { throw new InvalidOperationException( "Actor should not try to pick up if he's holding an entity or someone else is holding an entity"); } Entity.entityHolder.EntityHeld = ItemToPickUp.id.Id; ItemToPickUp.ReplaceHeld(Entity.id.Id); _uiFacade.AddLogEntry($"<color=#aaa>You pick up {ItemToPickUp.view.Controller.Name}.</color>"); IActionEffect effect = ActionEffectFactory .CreateLambdaEffect(viewController => viewController.HoldOnFront(ItemToPickUp), Entity.view.Controller); yield return(effect); }
public override IEnumerable <IActionEffect> Execute() { yield return(new ControlStaysEffect()); List <Guid> inventoryList = Entity.inventory.EntitiesInInventory; Guid itemToTakeId = inventoryList[_indexInInventory]; GameEntity itemToTake = Contexts.sharedInstance.game.GetEntityWithId(itemToTakeId); inventoryList[_indexInInventory] = Guid.Empty; Entity.ReplaceInventory(inventoryList); Entity.ReplaceEntityHolder(itemToTakeId); itemToTake.ReplacePosition(Entity.position.Position); IActionEffect effect = ActionEffectFactory .CreateLambdaEffect(viewController => viewController.HoldOnFront(itemToTake), Entity.view.Controller); yield return(effect); }
public override IEnumerable <IActionEffect> Execute() { Entity.ReplaceEntityHolder(EntityToKidnap.id.Id); EntityToKidnap.AddHeld(Entity.id.Id); EntityToKidnap.RemoveEnergy(); EntityToKidnap.isEnergyReady = false; EntityToKidnap.isCarryable = false; if (!Entity.hasEntityHolder || Entity.entityHolder.EntityHeld == Guid.Empty) { IActionEffect effect = ActionEffectFactory .CreateLambdaEffect(viewController => viewController.HoldOnBack(EntityToKidnap), Entity.view.Controller); yield return(effect); } else { throw new InvalidOperationException("Kidnap action shouldn't be executed if the active actor is holding something."); } }
public override IEnumerable <IActionEffect> Execute() { if (Entity.entityHolder.EntityHeld == _itemToDrop.id.Id) { IActionEffect dropEffect = ActionEffectFactory .CreateLambdaEffect(actorBehaviour => actorBehaviour.DropHeldEntity(_itemToDrop), Entity.view.Controller); Entity.ReplaceEntityHolder(Guid.Empty); string itemName = _itemToDrop.view.Controller.Name; Position?newPosition = _firstPlaceInAreaFinder.FindForItem(Entity.position.Position); _itemToDrop.RemoveHeld(); _itemToDrop.ReplacePosition(newPosition ?? Entity.position.Position); _itemToDrop.view.Controller.RefreshWorldPosition(); _uiFacade.AddLogEntry($"<color=#aaa>You drop {itemName} on the ground.</color>"); yield return(dropEffect); } }