void CFactory::Update() { nanoPieceCache.Update(); if (beingBuilt) { // factory is under construction, cannot build anything yet CUnit::Update(); #if 1 // this can happen if we started being reclaimed *while* building a // unit, in which case our buildee can either be allowed to finish // construction (by assisting builders) or has to be killed --> the // latter is easier if (curBuild != NULL) { StopBuild(); } #endif return; } if (curBuildDef != NULL) { if (!yardOpen && !IsStunned()) { if (groundBlockingObjectMap->CanOpenYard(this)) { script->Activate(); groundBlockingObjectMap->OpenBlockingYard(this); // make sure the idle-check does not immediately trigger // (scripts have 7 seconds to set inBuildStance to true) lastBuildUpdateFrame = gs->frameNum; } } if (yardOpen && inBuildStance && !IsStunned()) { StartBuild(curBuildDef); } } if (curBuild != NULL) { UpdateBuild(curBuild); FinishBuild(curBuild); } const bool wantClose = (!IsStunned() && yardOpen && (gs->frameNum >= (lastBuildUpdateFrame + GAME_SPEED * 7))); const bool closeYard = (wantClose && curBuild == NULL && groundBlockingObjectMap->CanCloseYard(this)); if (closeYard) { // close the factory after inactivity groundBlockingObjectMap->CloseBlockingYard(this); script->Deactivate(); } CBuilding::Update(); }
void CFactory::Update() { if (beingBuilt) { // factory is under construction, cannot build anything yet CUnit::Update(); return; } if (curBuildDef != NULL) { if (!opening && !stunned) { if (groundBlockingObjectMap->CanOpenYard(this)) { script->Activate(); groundBlockingObjectMap->OpenBlockingYard(this); opening = true; // make sure the idle-check does not immediately trigger // (scripts have 7 seconds to set inBuildStance to true) lastBuildUpdateFrame = gs->frameNum; } } if (opening && inBuildStance && !stunned) { StartBuild(curBuildDef); } } if (curBuild != NULL && !beingBuilt) { UpdateBuild(curBuild); FinishBuild(curBuild); } const bool wantClose = (!stunned && opening && (gs->frameNum >= (lastBuildUpdateFrame + GAME_SPEED * 7))); const bool closeYard = (wantClose && curBuild == NULL && groundBlockingObjectMap->CanCloseYard(this)); if (closeYard) { // close the factory after inactivity groundBlockingObjectMap->CloseBlockingYard(this); opening = false; script->Deactivate(); } CBuilding::Update(); }