Code: Select all
if(cant get definition of units) canbuild
BuildTime = targets_buildTime / builders_buildSpeed;
// Energy Cost/Second
EPerS = (energyCost*0.8f) / BuildTime;
if (EnergyStored + BuildTime * (EnergyIncome - (EnergyUsage + EPerS)) < 0.0f){
//insufficient energy to build a stall is anticipated if construction is started
cant build
}
MPerS = (metalCost*0.8f) / BuildTime;
if (metalstored + BuildTime * (MetalIncome - (MetalUsage + MPerS)) < 0){
// insufficient metal
//insufficient metal to build, a stall is anticipated if construction is started
cant build
}
canbuild
Now I know that soemtimes you build anyways knowing there's gonna be a stall because ti's important but I need foundations, a general algorithm before I starta dding special exceptions.