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)); }
private void ItemDestroy(object sender, EventArgs e) { IDestroyNotifier item = (IDestroyNotifier)sender; item.Destroy -= ItemDestroy; items.Remove(item); ItemDestroyed?.Invoke(this, new DestroyedItemEventArgs(item)); }
/// <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); }
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; } }
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); }
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); }