mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
structures work only once complete
research structures research when they have min 30% HP
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef BUILDABLE_UNIT_H
|
||||||
|
#define BUILDABLE_UNIT_H
|
||||||
|
|
||||||
|
namespace battleship{
|
||||||
|
struct BuildableUnit{
|
||||||
|
int id;
|
||||||
|
bool buildable;
|
||||||
|
|
||||||
|
BuildableUnit(int i, bool build) : id(i), buildable(build){}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -18,6 +18,8 @@ namespace battleship{
|
|||||||
void Factory::update(){
|
void Factory::update(){
|
||||||
Structure::update();
|
Structure::update();
|
||||||
|
|
||||||
|
if(!isComplete()) return;
|
||||||
|
|
||||||
if(!unitQueue.empty())
|
if(!unitQueue.empty())
|
||||||
train();
|
train();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PointDefense::attack(Order order){
|
void PointDefense::attack(Order order){
|
||||||
|
if(!isComplete()) return;
|
||||||
|
|
||||||
Unit *targUnit = order.targets[0].unit;
|
Unit *targUnit = order.targets[0].unit;
|
||||||
Vector3 targDir = (targUnit ? targUnit->getPos() : order.targets[0].pos) - pos;
|
Vector3 targDir = (targUnit ? targUnit->getPos() : order.targets[0].pos) - pos;
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -16,7 +16,9 @@ namespace battleship{
|
|||||||
void ResearchStruct::update(){
|
void ResearchStruct::update(){
|
||||||
Structure::update();
|
Structure::update();
|
||||||
|
|
||||||
if(player->getRefineds() >= researchCost && canGenerateResearch()){
|
if(!isComplete()) return;
|
||||||
|
|
||||||
|
if(health > .3 * maxHealth && player->getRefineds() >= researchCost && canGenerateResearch()){
|
||||||
player->addResearch(generationSpeed);
|
player->addResearch(generationSpeed);
|
||||||
player->subtractRefineds(researchCost);
|
player->subtractRefineds(researchCost);
|
||||||
lastGenTime = getTime();
|
lastGenTime = getTime();
|
||||||
|
|||||||
+2
-2
@@ -109,7 +109,7 @@ namespace battleship{
|
|||||||
int minDistId = -1;
|
int minDistId = -1;
|
||||||
|
|
||||||
for(int i = 0; i < structs.size(); i++)
|
for(int i = 0; i < structs.size(); i++)
|
||||||
if(structs[i]->getBuildStatus() == 100){
|
if(structs[i]->isComplete()){
|
||||||
minDistId = i;
|
minDistId = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ namespace battleship{
|
|||||||
if(minDistId == -1) return nullptr;
|
if(minDistId == -1) return nullptr;
|
||||||
|
|
||||||
for(int i = 0; i < structs.size(); i++)
|
for(int i = 0; i < structs.size(); i++)
|
||||||
if(structs[i]->getBuildStatus() == 100 && structs[minDistId]->getPos().getDistanceFrom(pos) > structs[i]->getPos().getDistanceFrom(pos))
|
if(structs[i]->isComplete() && structs[minDistId]->getPos().getDistanceFrom(pos) > structs[i]->getPos().getDistanceFrom(pos))
|
||||||
minDistId = i;
|
minDistId = i;
|
||||||
|
|
||||||
return structs[minDistId];
|
return structs[minDistId];
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace battleship{
|
|||||||
Structure(Player*, int, vb01::Vector3, vb01::Quaternion, int = 0, Unit::State = Unit::State::STAND_GROUND);
|
Structure(Player*, int, vb01::Vector3, vb01::Quaternion, int = 0, Unit::State = Unit::State::STAND_GROUND);
|
||||||
~Structure();
|
~Structure();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
inline bool isComplete(){return buildStatus == 100;}
|
||||||
inline int getBuildStatus(){return buildStatus;}
|
inline int getBuildStatus(){return buildStatus;}
|
||||||
inline void incrementBuildStatus(){buildStatus++;}
|
inline void incrementBuildStatus(){buildStatus++;}
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user