Ejemplo n.º 1
0
        protected override void HandleMessage(EntityActorMessageContext messageContext, BehaviourGameObjectState <AvatarPedestalInstanceModel> state, InteractWithEntityActorMessage message)
        {
            if (Logger.IsDebugEnabled)
            {
                Logger.Debug($"Entity: {message.EntityInteracting} Interacted with Avatar Pedestal: {state.EntityGuid}");
            }

            //Only players should be able to interact with this.
            if (message.EntityInteracting.EntityType != EntityType.Player)
            {
                return;
            }

            //Initially, we should make the assumption that they CAN change their avatr with this pedestal
            //so we will send the change packet BEFORE checking.
            messageContext.Sender.Tell(new ChangeEntityActorDisplayModelMessage(state.BehaviourData.AvatarModelId));

            //Now we REALLY need to be sure.
            ZoneServerDataClient.UpdatePlayerAvatar(new ZoneServerAvatarPedestalInteractionCharacterRequest(message.EntityInteracting, state.BehaviourData.LinkedGameObjectId))
            .ContinueWith((task, o) =>
            {
                if (task.IsFaulted)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"TODO: Log");                                 //lazy
                    }
                    return;
                }

                //Now, we should verify the response. If the model id differ then it failed
                //or some race condition externally, the desired result is the player gets changed back.
                //To prevent exploits
                if (state.BehaviourData.AvatarModelId != task.Result.PersistedModelId)
                {
                    messageContext.Sender.Tell(new ChangeEntityActorDisplayModelMessage(task.Result.PersistedModelId));
                }
            }, TaskContinuationOptions.ExecuteSynchronously);
        }
Ejemplo n.º 2
0
        protected override void HandleMessage(EntityActorMessageContext messageContext, BehaviourGameObjectState <WorldTeleporterInstanceModel> state, InteractWithEntityActorMessage message)
        {
            if (Logger.IsDebugEnabled)
            {
                Logger.Debug($"Entity: {message.EntityInteracting} Interacted with World Teleporter: {state.EntityGuid}");
            }

            //Only players should be able to interact with this.
            if (message.EntityInteracting.EntityType != EntityType.Player)
            {
                return;
            }

            //Right now there is no validation, just teleport them.
            messageContext.Sender.Tell(new WorldTeleportPlayerEntityActorMessage(state.BehaviourData.RemoteSpawnPointId, state.BehaviourData.LinkedGameObjectId));
        }
Ejemplo n.º 3
0
        protected override void HandleMessage(EntityActorMessageContext messageContext, BehaviourGameObjectState <AvatarPedestalInstanceModel> state, EntityActorInitializationSuccessMessage message)
        {
            //We need to initialize our replicateable state here.

            //TODO: Better handling of enum names for specialized gameobjects
            //Basically this is how clients see the avatar id.
            state.EntityData.SetFieldValue(GameObjectField.RESERVED_DATA_1, state.BehaviourData.AvatarModelId);

            //avatar pedestal can be interacted with.
            state.EntityData.AddBaseObjectFieldFlag(BaseObjectFieldFlags.UNIT_FLAG_INTERACTABLE);
        }
Ejemplo n.º 4
0
 protected override void HandleMessage(EntityActorMessageContext messageContext, BehaviourGameObjectState <WorldTeleporterInstanceModel> state, EntityActorInitializationSuccessMessage message)
 {
     //world teleporters can be interacted with.
     state.EntityData.AddBaseObjectFieldFlag(BaseObjectFieldFlags.UNIT_FLAG_INTERACTABLE);
 }