Exemplo n.º 1
0
        private void ClientUpdateCallback()
        {
            if (!ClientInputManager.IsButtonDown(EditorButton.ToggleEditorMode))
            {
                return;
            }

            var currentPlayerCharacter = Client.Characters.CurrentPlayerCharacter;

            if (currentPlayerCharacter is null)
            {
                return;
            }

            // reset focus (workaround for NoesisGUI crash when not focused unloaded control receives OnKeyDown)
            Client.UI.BlurFocus();

            var protoCharacterEditorMode = Api.GetProtoEntity <PlayerCharacterEditorMode>();

            if (currentPlayerCharacter.ProtoCharacter is PlayerCharacterEditorMode)
            {
                // switch to player mode
                EditorActiveToolManager.Deactivate();
                protoCharacterEditorMode
                .CallServer(_ => _.ServerRemote_SwitchToPlayerMode());
            }
            else
            {
                // switch to editor mode
                protoCharacterEditorMode
                .CallServer(_ => _.ServerRemote_SwitchToEditorMode());
            }
        }
Exemplo n.º 2
0
 public override void ClientDeinitialize(ICharacter character)
 {
     if (character.IsCurrentClientCharacter)
     {
         // reset
         BootstrapperClientGame.Init(null);
         EditorActiveToolManager.Deactivate();
     }
 }