private OperationResponse ItemOperationDestroy(Item item, DestroyItem operation)
        {
            MethodReturnValue result = this.CheckAccess(item);

            if (result.IsOk)
            {
                item.Destroy();
                item.Dispose();
                this.RemoveItem(item);

                item.World.ItemCache.RemoveItem(item.Id);
                var eventInstance = new ItemDestroyed {
                    ItemId = item.Id
                };
                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));
        }
예제 #2
0
        private void ItemDestroy(object sender, EventArgs e)
        {
            IDestroyNotifier item = (IDestroyNotifier)sender;

            item.Destroy -= ItemDestroy;
            items.Remove(item);
            ItemDestroyed?.Invoke(this, new DestroyedItemEventArgs(item));
        }
예제 #3
0
파일: Item.cs 프로젝트: theGameShop/Flipper
        /// <summary>
        /// Publishes event ItemDestroyed in the Item.EventChannel.
        /// </summary>
        protected void OnDestroy()
        {
            var eventInstance = new ItemDestroyed {
                ItemId = this.Id
            };
            var eventData = new EventData((byte)EventCode.ItemDestroyed, eventInstance);
            var message   = new ItemEventMessage(this, eventData, new SendParameters {
                ChannelId = Settings.ItemEventChannel
            });

            this.EventChannel.Publish(message);
        }
예제 #4
0
        private void NewEvent(object sender, IEvent e)
        {
            switch (e)
            {
            case ItemCreated itemCreated:
                ItemCreated?.Invoke(sender, itemCreated);
                break;

            case ItemDestroyed itemDestroyed:
                ItemDestroyed?.Invoke(sender, itemDestroyed);
                break;
            }
        }
예제 #5
0
        protected override void OnDestroy()
        {
            //log.InfoFormat("destroy object of type {0}", (ItemType)Type);
            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);
            base.OnDestroy();
            this.Dispose(true);
        }
예제 #6
0
 public Ship(ItemManager itemManager, Zone zone, EquippableItem hull, EntitySettings settings) : base(itemManager, zone, hull, settings)
 {
     ItemDestroyed.Where(item => _thrusterItems.Contains(item)).Subscribe(RemoveThruster);
     ItemDestroyed.Where(item => _aetherDriveItems.Contains(item)).Subscribe(RemoveAetherDrive);
 }