From 8f8d0d0a88d5ba43239ddcd830d26b65758954be Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sun, 27 Jul 2025 12:41:48 +0300 Subject: [PATCH] placeable and rotatable vehicles in the map editor --- Assets/Scripts/Core/options.lua | 5 +++-- mapEditorAppState.cpp | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Core/options.lua b/Assets/Scripts/Core/options.lua index 5c0be6d..9218efb 100644 --- a/Assets/Scripts/Core/options.lua +++ b/Assets/Scripts/Core/options.lua @@ -41,13 +41,14 @@ mappings = { {bind = 50, trigger = 85, action = true, bindType = 0, inOptions = false}, {bind = 51, trigger = 79, action = true, bindType = 0, inOptions = false}, + {bind = 0, trigger = 0, action = true, bindType = 1, inOptions = false}, {bind = 7, trigger = 312, action = false, bindType = 2, inOptions = false}, {bind = 8, trigger = 313, action = false, bindType = 2, inOptions = false}, {bind = 9, trigger = 310, action = false, bindType = 2, inOptions = false}, {bind = 10, trigger = 311, action = false, bindType = 2, inOptions = false}, - {bind = 11, trigger = 1, action = true, bindType = 1, inOptions = false}, + {bind = 11, trigger = 2, action = true, bindType = 1, inOptions = false}, + {bind = 13, trigger = 1, action = true, bindType = 1, inOptions = false}, {bind = 33, trigger = 256, action = true, bindType = 0, inOptions = false}, - {bind = 0, trigger = 0, action = true, bindType = 1, inOptions = false}, {bind = 34, trigger = 67, action = true, bindType = 0, inOptions = false}, {bind = 35, trigger = 86, action = true, bindType = 0, inOptions = false}, {bind = 36, trigger = 312, action = false, bindType = 2, inOptions = false}, diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp index 502bf8f..c9c1658 100644 --- a/mapEditorAppState.cpp +++ b/mapEditorAppState.cpp @@ -658,26 +658,33 @@ namespace battleship{ switch((Bind)bind){ case Bind::LOOK_AROUND: - if(ufCtr->isPlacingOnSurface()){ + if(!ufCtr->isPlacingOnSurface()) + CameraController::getSingleton()->setLookingAround(isPressed); + + break; + case Bind::ROTATE_OBJ_FRAME: + if(isPressed && ufCtr->isPlacingOnSurface()) + ufCtr->setRotating(true); + else if(!isPressed && ufCtr->isRotating()){ Player *player = Game::getSingleton()->getPlayer(0); GameObjectFrame &frame = ufCtr->getGameObjectFrame(0); Model *model = frame.getModel(); Vector3 pos = model->getPosition(); Quaternion rot = model->getOrientation(); - GameObject *obj; if(frame.getType() == GameObject::Type::RESOURCE_DEPOSIT) player->addResourceDeposit(GameObjectFactory::createResourceDeposit(player, frame.getId(), pos, rot)); else player->addUnit(GameObjectFactory::createUnit(player, frame.getId(), pos, rot)); - } - else - CameraController::getSingleton()->setLookingAround(isPressed); - break; - case Bind::ROTATE_OBJ_FRAME: + ufCtr->setRotating(false); + } + + break; + case Bind::DESELECT_STRUCTURE: ufCtr->removeGameObjectFrames(); ufCtr->setPlacingOnSurface(false); + ufCtr->setRotating(false); break; case Bind::INCREASE_RADIUS: if(isPressed) mapEditor->updateCircleRadius(true); @@ -751,6 +758,7 @@ namespace battleship{ void MapEditorAppState::onAnalog(int bind, float strength){ CameraController *camCtr = CameraController::getSingleton(); + GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton(); switch((Bind)bind){ case Bind::LOOK_UP: @@ -766,6 +774,8 @@ namespace battleship{ case Bind::LOOK_RIGHT: if(camCtr->isLookingAround()) camCtr->orientCamera(Vector3(0, 1, 0), strength); + else if(ufCtr->isRotating()) + ufCtr->rotateGameObjectFrames(100 * strength); break; case Bind::PUSH_VERTS_UP: