예제 #1
0
		protected override void OnEventFired(object source, ButtonClickedEventArgs args)
		{
			args.Button.IsInteractable = false;

			UnityAsyncHelper.UnityMainThreadContext.PostAsync(async () =>
			{
				if(SelectedCharacterGuid == null)
				{
					Logger.Error($"Tried to enter the world without any selected character guid.");
					return;
				}

				//We do this before sending the player login BECAUSE of a race condition that can be caused
				//since I actually KNOW this event should disable networking. We should not handle messages in this scene after this point basically.
				//TODO: Don't hardcode this scene.
				OnServerRequestedSceneChange?.Invoke(this, new ServerRequestedSceneChangeEventArgs((PlayableGameScene) 2));

				CharacterSessionEnterResponse enterResponse = await CharacterServiceQueryable.TryEnterSession(SelectedCharacterGuid.EntityId);

				if (Logger.IsDebugEnabled)
					Logger.Debug($"Character Session Entry Response: {enterResponse.ResultCode}.");

				if (!enterResponse.isSuccessful)
					if (Logger.IsErrorEnabled)
						Logger.Error($"Failed to enter CharacterSession for Entity: {SelectedCharacterGuid} Reason: {enterResponse.ResultCode}");

				//TODO: handle character session failure
				CharacterData.UpdateCharacterId(SelectedCharacterGuid.EntityId);

				//TODO: Use the scene manager service.
				//TODO: Don't hardcode scene ids. Don't load scenes directly.
				SceneManager.LoadSceneAsync(GladMMOClientConstants.WORLD_DOWNLOAD_SCENE_NAME).allowSceneActivation = true;
			});
		}
        /// <inheritdoc />
        public override Task HandleMessage(IPeerMessageContext <GameClientPacketPayload> context, LoadNewSceneEventPayload payload)
        {
            if (Logger.IsInfoEnabled)
            {
                Logger.Info($"InstanceServer requested SceneLoad: {payload.SceneToLoad}");
            }

            //Just dispatch it to any interested parties.
            OnServerRequestedSceneChange?.Invoke(this, new ServerRequestedSceneChangeEventArgs(payload.SceneToLoad));

            return(Task.CompletedTask);
        }