Esempio n. 1
0
        private async Task RefreshLocalDataAsync(IGameObjectBehaviourDataServiceClient <TBehaviourTransportType> client)
        {
            try
            {
                var responseModel = await client.GetBehaviourInstance(GetTarget().gameObject.GetComponent <GameObjectStaticSpawnPointDefinition>().GameObjectInstanceId);

                //TODO: Handle failure
                GetTarget().UpdateModel(responseModel.Result);
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to refresh local data. Reason: {e.Message}");
                throw;
            }
            finally
            {
                ClearProgressBar();
            }
        }
Esempio n. 2
0
        //[AuthorizeJwt(GuardianApplicationRole.ZoneServer)] //TODO: Eventually we'll need to auth these zoneservers.
        public async Task <IActionResult> UpdatePlayerAvatar([FromBody][NotNull] ZoneServerAvatarPedestalInteractionCharacterRequest requestModel,
                                                             [FromServices][NotNull] IGameObjectBehaviourDataServiceClient <AvatarPedestalInstanceModel> avatarPedestalModel,
                                                             [FromServices][NotNull] ICharacterAppearanceRepository characterAppearanceRepository)
        {
            if (avatarPedestalModel == null)
            {
                throw new ArgumentNullException(nameof(avatarPedestalModel));
            }
            if (characterAppearanceRepository == null)
            {
                throw new ArgumentNullException(nameof(characterAppearanceRepository));
            }

            //If this fails we have problems that can be mitigated.
            CharacterAppearanceModel appearanceModel = await characterAppearanceRepository.RetrieveAsync(requestModel.CharacterGuid.EntityId);

            try
            {
                var behaviourInstanceResponse = await avatarPedestalModel.GetBehaviourInstance(requestModel.AvatarPedestalId);

                if (behaviourInstanceResponse.isSuccessful)
                {
                    //we can properly change.
                    appearanceModel.AvatarModelId = behaviourInstanceResponse.Result.AvatarModelId;
                    await characterAppearanceRepository.UpdateAsync(requestModel.CharacterGuid.EntityId, appearanceModel);

                    //return BadRequest($"Cannot query data for Avatar Pedestal: {requestModel.AvatarPedestalId} Reason: {behaviourInstanceResponse.ResultCode.ToString()}");
                }
            }
            catch (Exception e)
            {
                if (Logger.IsEnabled(LogLevel.Error))
                {
                    Logger.LogError($"Encountered exception: {e.Message} in {nameof(UpdatePlayerAvatar)}.\n\nStack: {e.StackTrace}");
                }
            }

            //No matter what we should return the current.
            return(Json(new AvatarPedestalChangeResponse((int)appearanceModel.AvatarModelId)));
        }
Esempio n. 3
0
        //[AuthorizeJwt(GuardianApplicationRole.ZoneServer)] //TODO: Eventually we'll need to auth these zoneservers.
        public async Task <IActionResult> WorldTeleportCharacter([FromBody][NotNull] ZoneServerWorldTeleportCharacterRequest requestModel,
                                                                 [FromServices][NotNull] ICharacterLocationRepository characterLocationRepository,
                                                                 [FromServices][NotNull] IGameObjectBehaviourDataServiceClient <WorldTeleporterInstanceModel> worldTelporterDataClient,
                                                                 [FromServices][NotNull] IPlayerSpawnPointDataServiceClient playerSpawnDataClient)
        {
            if (requestModel == null)
            {
                throw new ArgumentNullException(nameof(requestModel));
            }
            if (characterLocationRepository == null)
            {
                throw new ArgumentNullException(nameof(characterLocationRepository));
            }
            if (worldTelporterDataClient == null)
            {
                throw new ArgumentNullException(nameof(worldTelporterDataClient));
            }
            if (playerSpawnDataClient == null)
            {
                throw new ArgumentNullException(nameof(playerSpawnDataClient));
            }

            //TODO: Right now there is no verification of WHO/WHAT is actually teleporting the player.
            //We need an authorization system with player-owned zone servers. So that we can determine
            //who is requesting to transfer the session and then verify that a player is even on
            //that zone server.
            ProjectVersionStage.AssertBeta();

            //We don't await so that we can get rolling on this VERY async multi-part process.
            //TODO: Handle failure
            ResponseModel <WorldTeleporterInstanceModel, SceneContentQueryResponseCode> teleporterInstanceResponse = await worldTelporterDataClient.GetBehaviourInstance(requestModel.WorldTeleporterId);

            //TODO: Handle failure
            ResponseModel <PlayerSpawnPointInstanceModel, SceneContentQueryResponseCode> pointInstanceResponse = await playerSpawnDataClient.GetSpawnPointInstance(teleporterInstanceResponse.Result.RemoteSpawnPointId);

            //Remove current location and update the new location.
            await characterLocationRepository.TryDeleteAsync(requestModel.CharacterGuid.EntityId);

            await characterLocationRepository.TryCreateAsync(new CharacterLocationModel(requestModel.CharacterGuid.EntityId,
                                                                                        pointInstanceResponse.Result.InitialPosition.x,
                                                                                        pointInstanceResponse.Result.InitialPosition.y,
                                                                                        pointInstanceResponse.Result.InitialPosition.z,
                                                                                        pointInstanceResponse.Result.WorldId));

            //TODO: Better indicate reason for failure.
            return(Ok());
        }