public override CommandResult Execute() { if (!Cell.Walkable(destinationCell)) { Cost = -1; return(CommandResult.Failed); } if (destinationCell.Actor != null) { ActorComp actor = Entity.GetComponent <ActorComp>(); if (actor.HostileTo(destinationCell.Actor.GetComponent <ActorComp>())) { ActorCommand cmd = new MeleeCommand(Entity, destinationCell); CommandResult result = cmd.Execute(); Cost = cmd.Cost; return(result); } else if (Entity.HasComponent <AI>()) { ActorCommand cmd = new WaitCommand(Entity); CommandResult result = cmd.Execute(); Cost = cmd.Cost; return(result); } } Entity.Move(destinationLevel, destinationCell); Cost = TurnScheduler.TurnTime; return(CommandResult.Succeeded); }
public override CommandResult Execute() { ActorComp actor = Entity.GetComponent <ActorComp>(); switch (actor.Control) { case ActorControl.AI: { if (newControl == ActorControl.None) { Locator.Log.Send( $"{Strings.Subject(Entity, true)} goes limp...", Color.cyan); } else if (newControl == ActorControl.Player) { Locator.Log.Send( $"You possess {Strings.Subject(Entity, false)}!", Color.cyan); } else { throw new ArgumentException( $"Both current and new controls are the same."); } break; } case ActorControl.Player: { if (newControl == ActorControl.None) { Locator.Log.Send( $"You lose control of your physical body!", Color.magenta); } else if (newControl == ActorControl.AI) { Locator.Log.Send( $"You are possessed by {Strings.Subject(Target, false)}!", Color.magenta); } else { throw new ArgumentException( $"Both current and new controls are the same."); } break; } case ActorControl.None: { if (newControl == ActorControl.Player) { Locator.Log.Send( $"You possess {Strings.Subject(Entity, false)}", Color.cyan); } else if (newControl == ActorControl.AI) { Locator.Log.Send( $"{Strings.Subject(Entity, true)} takes on a new vigour!", Color.cyan); } else { throw new ArgumentException( $"Both current and new controls are the same."); } break; } } actor.Control = newControl; return(CommandResult.Succeeded); }