From 0e0cc0b83a72f9f9fa3c20cc1a4ff7d2ad810bf3 Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 18 Feb 2023 00:40:55 -0600 Subject: [PATCH] Ensures that if no client camera is defined when attempting to swap into an editor camera mode, it makes one so that the normal editor camera modes can work as expected Adds sanity check to default onNewDatablock function on the GameDatablock namespace in case the onAdd or onRemove functions aren't defined, we don't spam the console --- .../core/utility/scripts/gameObjectManagement.tscript | 6 ++++-- .../tools/worldEditor/scripts/cameraCommands.ed.tscript | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript index 275c088f9..fff2a8ace 100644 --- a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript @@ -80,8 +80,10 @@ function spawnGameObject(%name, %addToScene) function GameBaseData::onNewDataBlock(%this, %obj) { - %this.onRemove(%obj); - %this.onAdd(%obj); + if(%this.isMethod("onRemove")) + %this.onRemove(%obj); + if(%this.isMethod("onAdd")) + %this.onAdd(%obj); } function saveGameObject(%name, %tamlPath, %scriptPath) diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/cameraCommands.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/cameraCommands.ed.tscript index c842b77c1..18c0a1a5e 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/cameraCommands.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/cameraCommands.ed.tscript @@ -47,6 +47,15 @@ function serverCmdToggleCamera(%client) { if (%client.getControlObject() == %client.player) { + if (!isObject(%client.camera)) + { + %client.camera = spawnObject("Camera", Observer); + MissionCleanup.add( %client.camera ); + %client.camera.scopeToClient(%client); + + %client.camera.setPosition(%client.player.getPosition()); + } + %client.camera.setVelocity("0 0 0"); %control = %client.camera; }