Files
PlanetFleet/researchStruct.cpp
T
devZoGok 43ccac92d4 structures work only once complete
research structures research when they have min 30% HP
2024-02-25 16:46:52 +02:00

31 lines
885 B
C++

#include "researchStruct.h"
#include "player.h"
namespace battleship{
using namespace std;
using namespace vb01;
using namespace gameBase;
ResearchStruct::ResearchStruct(Player *player, int id, Vector3 pos, Quaternion rot, int buildStatus, Unit::State state) : Structure(player, id, pos, rot, buildStatus, state){
sol::table unitTable = generateView()["units"][id + 1];
generationRate = unitTable["generationRate"];
generationSpeed = unitTable["generationSpeed"];
researchCost = unitTable["researchCost"];
}
void ResearchStruct::update(){
Structure::update();
if(!isComplete()) return;
if(health > .3 * maxHealth && player->getRefineds() >= researchCost && canGenerateResearch()){
player->addResearch(generationSpeed);
player->subtractRefineds(researchCost);
lastGenTime = getTime();
}
}
void ResearchStruct::researchTechnology(int techId){
}
}