I am trying to make a function that is faster then RecordBuilding. It is so painfully slow and the AI builds slower then the human player. Not good. So here is my solution that uses IUnit:
Enumerate for a idle SF (not producing), have it build the kit, then have a idle ConVec come and collect the kit and go build it. After the building is started, record the building it is place so it will be rebulit later if it is destroyed. This is the code I have so far:
void BuildStruct(int ai, BuildingGroup build, enum map_id building, enum map_id weapon, LOCATION buildloc)
{
IUnit AIb, AIv;
PlayerBuildingEnum IdleSF(ai, mapStructureFactory);
GroupEnumerator IdleConVec(build);
while (IdleSF.GetNext(AIb))
{
if (!AIb.GetBusy() == ctMoProduce)
{
AIb.Produce(building, weapon);
while (IdleConVec.GetNext(AIv)
{
//make the ConVec move to the dock
}
while (AIb.GetBusy() == ctMoProduce);
//now that the SF is done building kit, test for bay and transfer to the ConVec
AIv.Bulid(buildloc);
build.RecordBuilding(builloc, builing, weapon);
}
}
}
The comments show what I need help on. Thanks.