コード例 #1
0
        /// <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 });
        }
コード例 #2
0
        /// <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 });
        }