Beispiel #1
0
        /// <summary>
        ///   The destroy.
        /// </summary>
        /// <param name = "item">
        ///   The mmo item.
        /// </param>
        /// <param name = "operation">
        ///   The operation.
        /// </param>
        /// <returns>
        ///   error code ok
        /// </returns>
        private OperationResponse ItemOperationDestroy(Item item, DestroyItem operation)
        {
            MethodReturnValue result = this.CheckAccess(item);
            if (result)
            {
                item.Destroy();
                item.Dispose();
                this.RemoveItem(item);

                item.World.ItemCache.RemoveItem(item.Type, item.Id);
                var eventInstance = new ItemDestroyed { ItemId = item.Id, ItemType = item.Type };
                var eventData = new EventData((byte)EventCode.ItemDestroyed, eventInstance);
                this.Peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel });

                // no response, event is sufficient
                operation.OnComplete();
                return null;
            }

            return operation.GetOperationResponse(result);
        }
Beispiel #2
0
 /// <summary>
 ///   Publishes event <see cref = "ItemDestroyed" /> in the <see cref = "Item.EventChannel" />.
 /// </summary>
 protected override void OnDestroy()
 {
     var eventInstance = new ItemDestroyed { ItemId = this.Id, ItemType = this.Type };
     var eventData = new EventData((byte)EventCode.ItemDestroyed, eventInstance);
     var message = new ItemEventMessage(this, eventData, new SendParameters { ChannelId = Settings.ItemEventChannel });
     this.EventChannel.Publish(message);
 }