void CWaitCommandsAI::SquadWait::Update() { if (buildUnits.empty() && ((int)waitUnits.size() < squadCount)) { // FIXME -- unblock remaining waitUnits ? delete this; return; } if ((int)waitUnits.size() >= squadCount) { CUnitSet unblockSet; CUnitSet::iterator it = waitUnits.begin(); while (it != waitUnits.end()) { WaitState state = GetWaitState(*it); if (state == Active) { unblockSet.insert(*it); if ((int)unblockSet.size() >= squadCount) { break; // we've got our squad } } else if (state == Queued) { // do nothing } else if (state == Missing) { DeleteDeathDependence(*it); it = RemoveUnitFromSet(it, waitUnits); continue; } ++it; } if ((int)unblockSet.size() >= squadCount) { // FIXME -- rebuild the order queue so // that formations are created? SendWaitCommand(unblockSet); for (it = unblockSet.begin(); it != unblockSet.end(); ++it) { DeleteDeathDependence(*it); waitUnits.erase(*it); } } } UpdateText(); // FIXME -- clean builders }
void CWaitCommandsAI::DeathWait::SelectAreaUnits( const float3& pos0, const float3& pos1, CUnitSet& units, bool enemies) { units.clear(); const float3 mins(std::min(pos0.x, pos1.x), 0.0f, std::min(pos0.z, pos1.z)); const float3 maxs(std::max(pos0.x, pos1.x), 0.0f, std::max(pos0.z, pos1.z)); const std::vector<CUnit*> &tmpUnits = qf->GetUnitsExact(mins, maxs); const int count = (int)tmpUnits.size(); for (int i = 0; i < count; i++) { CUnit* unit = tmpUnits[i]; if (enemies && teamHandler->Ally(unit->allyteam, gu->myAllyTeam)) { continue; } if (!(unit->losStatus[gu->myAllyTeam] & (LOS_INLOS | LOS_INRADAR))) { continue; } units.insert(unit); } }
void CWaitCommandsAI::DeathWait::Update() { if (waitUnits.empty()) { delete this; return; } unitPos.clear(); if (!deathUnits.empty()) { return; // more must die } CUnitSet unblockSet; CUnitSet::iterator it = waitUnits.begin(); while (it != waitUnits.end()) { WaitState state = GetWaitState(*it); if (state == Active) { unblockSet.insert(*it); DeleteDeathDependence(*it); it = RemoveUnitFromSet(it, waitUnits); continue; } else if (state == Queued) { // do nothing } else if (state == Missing) { DeleteDeathDependence(*it); it = RemoveUnitFromSet(it, waitUnits); continue; } ++it; } SendWaitCommand(unblockSet); if (waitUnits.empty()) { delete this; return; } }
void CWaitCommandsAI::TimeWait::Update() { if (unit == NULL) { delete this; return; } WaitState state = GetWaitState(unit); if (state == Active) { if (!enabled) { enabled = true; endFrame = (gs->frameNum + duration); } else { if (endFrame <= gs->frameNum) { CUnitSet smallSet; smallSet.insert(unit); SendWaitCommand(smallSet); if (!factory) { delete this; return; } else { enabled = false; } } } } else if (state == Queued) { return; } else if (state == Missing) { if (!factory) { // FIXME delete this; return; } } }