/// <summary> /// Notifies peer about Item entered area. /// </summary> public override void OnItemEnter(ItemSnapshot snapshot) { base.OnItemEnter(snapshot); var item = snapshot.Source; GlobalVars.log.InfoFormat("OnItemEnter: " + item.Id + "disposed" + item.Disposed); // temp fix for projectiles that get destroyed but are still tied to on RequestItemEnterChannel // of certain regions // an alternative to this hack would be to never subsribe projectiles to RequestItemEnterChannel, which // would be faster but would mean a projectile created in a foreign interest area could not hit you... if (item.Disposed) { return; } var subscribeEvent = new ItemSubscribed { ItemId = item.Id, ItemType = item.Type, Position = snapshot.Position, PropertiesRevision = snapshot.PropertiesRevision, InterestAreaId = this.Id, Rotation = snapshot.Rotation }; var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent); this.peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); }
protected override void OnItemSubscribed(ItemSnapshot snapshot) { //ConsoleLogging.Get.Print("ON PLAYER ITEM SUBSSCRIBED: {0}, {1}", snapshot.Source.Id.Substring(0, 3), (ItemType)snapshot.Source.Type); base.OnItemSubscribed(snapshot); var mmoSnapshot = (MmoItemSnapshot)snapshot; var item = snapshot.Source; if ((bool)item == false) { return; } byte subType = (byte)0; if (item.GetComponent <BotObject>()) { subType = item.GetComponent <BotObject>().botSubType; } string displayName = item.name; //log.InfoFormat("item subscribed position: {0},{1},{2}", item.transform.position.X, item.transform.position.Y, item.transform.position.Z); var subscribeEvent = new ItemSubscribed { ItemId = item.Id, ItemType = item.Type, Position = item.transform.position.ToArray(), //mmoSnapshot.Coordinate, PropertiesRevision = snapshot.PropertiesRevision, InterestAreaId = this.Id, Rotation = mmoSnapshot.Rotation, SubType = subType, Properties = item.properties.raw, DisplayName = displayName, Components = item.componentIds, size = item.size, subZone = item.subZone }; var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent); this.Peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); //log.InfoFormat("SEND ITEM SUBSCRIBE {0}:{1} ITEM VALID: {2}", (ItemType)item.Type, item.Id, (bool)item); }
private OperationResponse ItemOperationSubscribeItem(Item item, SubscribeItem operation) { if (item.Disposed) { return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound")); } this.interestItems.SubscribeItem(item); var subscribeEvent = new ItemSubscribed { ItemId = item.Id, ItemType = item.Type, Position = item.Position, PropertiesRevision = item.PropertiesRevision, Rotation = item.Rotation }; var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent); this.Peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); if (operation.PropertiesRevision.HasValue == false || operation.PropertiesRevision.Value != item.PropertiesRevision) { var properties = new ItemPropertiesSet { ItemId = item.Id, PropertiesRevision = item.PropertiesRevision, PropertiesSet = new Hashtable(item.Properties) }; var propEventData = new EventData((byte)EventCode.ItemPropertiesSet, properties); this.Peer.SendEvent(propEventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); } // don't send response operation.OnComplete(); return(null); }
/// <summary> /// Calls <see cref="ClientInterestArea.OnItemSubscribed">ClientInterestArea.OnItemSubscribed</see> and sends event <see cref="ItemSubscribed"/> to the client. /// </summary> /// <param name="snapshot"> /// The item snapshot. /// </param> protected override void OnItemSubscribed(ItemSnapshot snapshot) { base.OnItemSubscribed(snapshot); var mmoSnapshot = (MmoItemSnapshot)snapshot; var item = snapshot.Source; var subscribeEvent = new ItemSubscribed { ItemId = item.Id, ItemType = item.Type, Position = mmoSnapshot.Coordinate, PropertiesRevision = snapshot.PropertiesRevision, InterestAreaId = this.Id, Rotation = mmoSnapshot.Rotation }; var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent); this.Peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); }
/// <summary> /// Notifies peer about Item entered area. /// </summary> public override void OnItemEnter(ItemSnapshot snapshot) { base.OnItemEnter(snapshot); var item = snapshot.Source; var subscribeEvent = new ItemSubscribed { ItemId = item.Id, ItemType = item.Type, Position = snapshot.Position, PropertiesRevision = snapshot.PropertiesRevision, InterestAreaId = this.Id, Rotation = snapshot.Rotation }; var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent); this.peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); }
/// <summary> /// Calls <see cref="ClientInterestArea.OnItemSubscribed">ClientInterestArea.OnItemSubscribed</see> and sends event <see cref="ItemSubscribed"/> to the client. /// </summary> /// <param name="snapshot"> /// The item snapshot. /// </param> protected override void OnItemSubscribed(ItemSnapshot snapshot) { base.OnItemSubscribed(snapshot); var mmoSnapshot = (MmoItemSnapshot)snapshot; var item = snapshot.Source; var subscribeEvent = new ItemSubscribed { ItemId = item.Id, ItemType = item.Type, Position = mmoSnapshot.Coordinate, PropertiesRevision = snapshot.PropertiesRevision, InterestAreaId = this.Id, Rotation = mmoSnapshot.Rotation }; #region PopBloop var mmoItem = (MmoItem)item; if (mmoItem != null) { subscribeEvent.AvatarName = mmoItem.AvatarName; subscribeEvent.Animation = mmoItem.Animation; subscribeEvent.AnimationSpeed = mmoItem.AnimationSpeed; subscribeEvent.AnimationWrap = mmoItem.AnimationWrap; } else { subscribeEvent.AvatarName = "Unknown"; } #endregion var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent); this.Peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel }); }