fixed destroyed unit deselection

rovers have greater distance allowance to load resources from structures
temporarily removed patroling
This commit is contained in:
devZoGok
2025-06-24 18:34:19 +03:00
parent 86f73ca279
commit 09fb45fdc4
5 changed files with 18 additions and 1 deletions
+2
View File
@@ -825,10 +825,12 @@ namespace battleship{
}
break;
case Bind::SELECT_PATROL_POINTS:
/*
if(isPressed && mainPlayer->getNumSelectedUnits() > 0){
targets.push_back(Order::Target(nullptr, mainPlayer->getSelectedUnit(0)->getPos()));
selectingPatrolPoints = isPressed;
}
*/
break;
case Bind::GROUP_0:
+1
View File
@@ -77,6 +77,7 @@ namespace battleship{
void GameObject::destroyHitbox(){
model->dettachChild(hitbox);
delete hitbox;
hitbox = nullptr;
}
//TODO use a vector for the color nodes
+11
View File
@@ -142,6 +142,9 @@ namespace battleship{
}
void Player::removeUnit(int id){
if(find(selectedUnits.begin(), selectedUnits.end(), units[id]) != selectedUnits.end())
deselectUnit(units[id]);
delete units[id];
units.erase(units.begin() + id);
}
@@ -244,4 +247,12 @@ namespace battleship{
return vector<TradeOffer*>{};
}
void Player::deselectUnit(Unit *unit){
for(int i = 0; i < selectedUnits.size(); i++)
if(selectedUnits[i] == unit){
selectedUnits.erase(selectedUnits.begin() + i);
break;
}
}
}
+1
View File
@@ -36,6 +36,7 @@ namespace battleship{
void updateTradedResource(Player*, ResourceType, int, bool, bool);
void addTradeOffer(Player*, TradeOffer*);
std::vector<TradeOffer*> getTradeOffers(Player*);
void deselectUnit(Unit*);
inline int getResource(ResourceType rt){return resources[(int)rt];}
inline void updateResource(ResourceType rt, int amount, bool add){resources[(int)rt] = (add ? resources[(int)rt] + amount : amount);}
inline Trader* getTrader(){return trader;}
+3 -1
View File
@@ -37,8 +37,10 @@ namespace battleship{
loadRate = unitTable["loadRate"]; loadRate += game->calcAbilFromTech(Ability::Type::LOAD_RATE, currTechs, (int)GameObject::type, id);
}
//TODO implement a check of whether a vehicle is next to a building's outline
void ResourceRover::loadResources(Structure *targStruct, float minDist, bool loadResource){
bool closeEnough = (pos.getDistanceFrom(targStruct->getPos()) <= minDist);
float w = targStruct->getWidth(), l = targStruct->getLength();
bool closeEnough = (pos.getDistanceFrom(targStruct->getPos()) <= sqrt(l * l + w * w));
if(!closeEnough) return;
ResourceType resType;