/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { if (sourceContainer == null || sourceContainer.Count <= 0 || destinationParent == null) { return; } // Dump each child out of the targeted container. var movedThingNames = (from thing in sourceContainer.Children let movableBehavior = thing.FindBehavior <MovableBehavior>() where movableBehavior != null where movableBehavior.Move(destinationParent, actionInput.Actor, null, null) select thing.Name).ToList(); var commaSeparatedList = movedThingNames.BuildPrettyList(); var contextMessage = new ContextualString(actionInput.Actor, destinationParent) { ToOriginator = $"You move {commaSeparatedList} from {sourceContainer.Name} into {destinationParent.Name}", ToReceiver = $"{actionInput.Actor.Name} moves {commaSeparatedList} from {sourceContainer.Name} into you.", ToOthers = $"{actionInput.Actor.Name} moves {commaSeparatedList} from {sourceContainer.Name} into {destinationParent.Name}.", }; var message = new SensoryMessage(SensoryType.Sight, 100, contextMessage); var bulkMovementEvent = new BulkMovementEvent(actionInput.Actor, message); actionInput.Actor.Eventing.OnMovementEvent(bulkMovementEvent, EventScope.ParentsDown); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { IController sender = actionInput.Controller; if (sourceContainer == null || sourceContainer.Count <= 0 || destinationParent == null) { return; } // Dump each child out of the targeted container. List <string> movedThingNames = new List <string>(); foreach (Thing thing in sourceContainer.Children) { var movableBehavior = thing.Behaviors.FindFirst <MovableBehavior>(); if (movableBehavior != null) { // Try to move the item without any messaging since we'll be sending a bulk message later. if (movableBehavior.Move(destinationParent, sender.Thing, null, null)) { movedThingNames.Add(thing.Name); } } } string commaSeparatedList = BuildCommaSeparatedList(movedThingNames); var contextMessage = new ContextualString(sender.Thing, destinationParent) { ToOriginator = $"You move {commaSeparatedList} from {sourceContainer.Name} into {destinationParent.Name}", ToReceiver = $"{sender.Thing.Name} moves {commaSeparatedList} from {sourceContainer.Name} into you.", ToOthers = $"{sender.Thing.Name} moves {commaSeparatedList} from {sourceContainer.Name} into {destinationParent.Name}.", }; var message = new SensoryMessage(SensoryType.Sight, 100, contextMessage); var bulkMovementEvent = new BulkMovementEvent(sender.Thing, message); sender.Thing.Eventing.OnMovementEvent(bulkMovementEvent, EventScope.ParentsDown); }