Beispiel #1
0
        private async Task RefreshData([NotNull] IPlayerSpawnPointDataServiceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            try
            {
                DisplayProgressBar("Refreshing PlayerSpawnPoint", "Spawn Instance (1/1).", 0.5f);

                PlayerSpawnPointInstanceModel instanceData = await RefreshInstanceData(client);

                GetTarget().PlayerSpawnPointId = instanceData.SpawnPointId;
                GetTarget().isInstanceReserved = instanceData.isReserved;

                CachedInfoText = $"PlayerSpawn Instance: {GetTarget().PlayerSpawnPointId}\nSpawnPosition: {instanceData.InitialPosition}\nYRotation: {instanceData.YAxisRotation}\nIsReserved: {instanceData.isReserved}";
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to refresh PlayerSpawnPoint. Reason: {e.Message}");
                throw;
            }
            finally
            {
                ClearProgressBar();
            }
        }
Beispiel #2
0
 public InitializeSpawnInformationEventListener(IServerStartingEventSubscribable subscriptionService,
                                                [NotNull] PlayerSpawnPointQueue spawnStrategyQueue,
                                                [NotNull] ILog logger,
                                                [NotNull] IPlayerSpawnPointDataServiceClient playerSpawnContentDataClient,
                                                [NotNull] WorldConfiguration worldConfiguration)
     : base(subscriptionService)
 {
     SpawnStrategyQueue           = spawnStrategyQueue ?? throw new ArgumentNullException(nameof(spawnStrategyQueue));
     Logger                       = logger ?? throw new ArgumentNullException(nameof(logger));
     PlayerSpawnContentDataClient = playerSpawnContentDataClient ?? throw new ArgumentNullException(nameof(playerSpawnContentDataClient));
     WorldConfiguration           = worldConfiguration ?? throw new ArgumentNullException(nameof(worldConfiguration));
 }
Beispiel #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());
        }
Beispiel #4
0
        private async Task <PlayerSpawnPointInstanceModel> RefreshInstanceData([NotNull] IPlayerSpawnPointDataServiceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            ResponseModel <PlayerSpawnPointInstanceModel, SceneContentQueryResponseCode> queryResponseModel = await client.GetSpawnPointInstance(GetTarget().PlayerSpawnPointId);

            //TODO: No idea what should be done here.
            if (!queryResponseModel.isSuccessful)
            {
                return(null);
            }

            return(queryResponseModel.Result);
        }
Beispiel #5
0
        private void CreateInstance(IPlayerSpawnPointDataServiceClient client, WorldDefinitionData worldData)
        {
            DisplayProgressBar("Creating PlayerSpawnPoint", "Requesting instance (1/2)", 0.0f);

            UnityAsyncHelper.UnityMainThreadContext.Post(async o =>
            {
                try
                {
                    //If they press this, we need to actually create a creature instance for this world id.
                    var result = await client.CreateSpawnPointInstance(worldData.ContentId);

                    if (result.isSuccessful)
                    {
                        DisplayProgressBar("Creating PlayerSpawnPoint", "Saving Instance (2/2)", 0.5f);

                        GetTarget().PlayerSpawnPointId = result.Result.SpawnPointId;
                        EditorUtility.SetDirty(GetTarget());
                        EditorSceneManager.MarkSceneDirty(GetTarget().gameObject.scene);

                        await RefreshData(client);
                    }
                    else
                    {
                        Debug.LogError($"Failed to create PlayerSpawnPoint Instance. Reason: {result.ResultCode}");
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"Failed to create PlayerSpawnPoint Instance. Reason: {e.Message}");
                    throw;
                }
                finally
                {
                    ClearProgressBar();
                }
            }, null);
        }