/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Remove the item from its current container. // We have to do this before we attempt to add it because of the event subscriptions. // TODO: Test, this may be broken now... var actor = actionInput.Controller.Thing; if (numberToGet <= 0) { numberToGet = 1; } // TODO: Prevent item duplication from specifying large numbers, or races for same item, etc. // TODO: Fix Implementation of numberToGet. var contextMessage = new ContextualString(actor, thingToGet.Parent) { ToOriginator = $"You pick up {thingToGet}.", ToReceiver = $"{actor.Name} takes {thingToGet} from you.", ToOthers = $"{actor.Name} picks up {thingToGet.Name}.", }; var getMessage = new SensoryMessage(SensoryType.Sight, 100, contextMessage); if (movableBehavior.Move(actor, actor, getMessage, null)) { // TODO: Transactionally move owners if applicable. //actor.Save(); //actor.Parent.Save(); } }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Remove the item from the character's posession. // TODO: Test, this may be broken now... esp for numberToGive != max IController sender = actionInput.Controller; if (numberToGive > 0 && thing != null) { thing.RemoveFromParents(); } var contextMessage = new ContextualString(sender.Thing, target) { ToOriginator = $"You gave {thing.Name} to {target}.", ToReceiver = $"{sender.Thing.Name} gave you {thing.Name}.", ToOthers = $"{sender.Thing.Name} gave {thing.Name} to {target.Name}.", }; var message = new SensoryMessage(SensoryType.Sight, 100, contextMessage); // Try to move the thing from the sender to the target; this handles eventing and whatnot for us. if (!movableBehavior.Move(target, sender.Thing, null, message)) { sender.Write($"Failed to give {thing.Name} to {target.Name}."); } }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { var contextMessage = new ContextualString(actionInput.Actor, thingToDrop.Parent) { ToOriginator = $"You drop up {thingToDrop.Name}.", ToReceiver = $"{actionInput.Actor.Name} drops {thingToDrop.Name} in you.", ToOthers = $"{actionInput.Actor.Name} drops {thingToDrop.Name}." }; var dropMessage = new SensoryMessage(SensoryType.Sight, 100, contextMessage); var actor = actionInput.Actor; if (movableBehavior.Move(dropLocation, actor, null, dropMessage)) { // TODO: Transactionally save actors if applicable. //actor.Save(); //dropLocation.Save(); } }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Generate an item changed owner event. IController sender = actionInput.Controller; var contextMessage = new ContextualString(sender.Thing, thingToDrop.Parent) { ToOriginator = $"You drop up {thingToDrop.Name}.", ToReceiver = $"{sender.Thing.Name} drops $Thing.Name in you.", ToOthers = $"{sender.Thing.Name} drops $Thing.Name.", }; var dropMessage = new SensoryMessage(SensoryType.Sight, 100, contextMessage); var actor = actionInput.Controller.Thing; if (movableBehavior.Move(dropLocation, actor, null, dropMessage)) { // TODO: Transactionally save actors if applicable. //actor.Save(); //dropLocation.Save(); } }