/// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            if (itemCommand.Id == CommandTake)
            {
                var itemManager    = ModuleManager.GetManager <IItemManager>();
                var messageManager = ModuleManager.GetManager <IMessageManager>();
                var item           = itemManager.Read(itemCommand.ItemId.Value);
                itemManager.Move(item, origin, origin);
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = item,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            if (itemCommand.Id == CommandDrop)
            {
                var itemManager    = ModuleManager.GetManager <IItemManager>();
                var messageManager = ModuleManager.GetManager <IMessageManager>();
                var item           = itemManager.Read(itemCommand.ItemId.Value);
                var location       = itemManager.Read(origin.ParentId.Value);
                itemManager.Move(item, location, origin);
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = item,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            return(continueIfNull);
        }
Exemple #2
0
        /// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            if (itemCommand.Id == CommandGo)
            {
                var itemManager     = ModuleManager.GetManager <IItemManager>();
                var messageManager  = ModuleManager.GetManager <IMessageManager>();
                var exitItem        = itemManager.Read(itemCommand.ItemId.Value);
                var destinationItem = itemManager.Read(Guid.Parse(exitItem.GetProperty <ExitItemProperty>().DestinationId));
                itemManager.Move(origin, destinationItem, exitItem);
                IResponse mockResponse    = new Response();
                var       locationSummary = ModuleManager.GetManager <ILocationItemDataManager>()
                                            .HandleReadLocationSummaryRequest(new WorldReadLocationSummaryRequest()
                {
                }, origin, ModuleManager, mockResponse);
                messageManager.SendMessage(new List <IMessage>()
                {
                    locationSummary
                }, new List <Item>()
                {
                    origin
                });
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = exitItem,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            return(continueIfNull);
        }
Exemple #3
0
        /// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            if (itemCommand.Id == CommandJavascript)
            {
                var itemManager = ModuleManager.GetManager <IItemManager>();
                var item        = itemManager.Read(itemCommand.ItemId.Value);
                ExecuteFunction(item, "onUse", itemCommand, origin);
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = item,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            return(continueIfNull);
        }
Exemple #4
0
        /// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            return(continueIfNull);
        }