From fff48459feeeb92461ab0e875f0b9c0f94ac8285 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sun, 15 Sep 2024 14:21:24 +0300 Subject: [PATCH] cursors and attack orders only work on visible units --- activeGameState.cpp | 4 +++- unit.h | 1 - vehicle.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/activeGameState.cpp b/activeGameState.cpp index 91c5de9..5d01910 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -225,6 +225,8 @@ namespace battleship{ } bool ActiveGameState::isGameObjSelectable(GameObject *obj, bool useDragBox){ + if(!obj->getModel()->isVisible()) return false; + Node *hitboxNode = obj->getHitbox(); Box *hitbox = (Box*)hitboxNode->getMesh(0); @@ -332,7 +334,7 @@ namespace battleship{ vector selUnits = mainPlayer->getSelectedUnits(); for (Unit *u : units) { - Node *model = u->getNode(); + Node *model = u->getModel(); if (u->getPlayer() == mainPlayer){ if(!u->getLosLightNode()) u->initLosLight(); diff --git a/unit.h b/unit.h index ada7f0d..eaa0725 100755 --- a/unit.h +++ b/unit.h @@ -146,7 +146,6 @@ namespace battleship{ inline int getNumGarrisonSlots(){return garrisonSlots.size();} inline const std::vector& getGarrisonSlots(){return garrisonSlots;} inline float getLineOfSight() {return lineOfSight;} - inline vb01::Model* getNode() {return model;} inline UnitType getType() {return type;} inline UnitClass getUnitClass() {return unitClass;} inline void takeDamage(int damage) {health -= damage;} diff --git a/vehicle.cpp b/vehicle.cpp index 8f7edb4..6a68d11 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -35,7 +35,7 @@ namespace battleship{ void Vehicle::update(){ Unit::update(); - model->setVisible(!garrisonable); + if(garrisonable) model->setVisible(false); } void Vehicle::halt(){