public static function FromList(array $resources, array $amounts, Colony $colony, array $listPositions = NULL, $forDeletion = false) { $members = array(); $positionInList = 0; $amountCounter = 0; // Determine the list positions. if ($listPositions == NULL) { // Get the offset of build list positions $firstItem = ResourceParser::Instance()->GetItemByName($resources[0]); if ($firstItem->IsBuilding()) { $scheduledUnitData = BuildGroup::GetLastBuildListPosition($colony); $positionInList += $scheduledUnitData; } else { $scheduledUnitData = BuildGroup::ShipyardIsBusyUntil(); $positionInList += $scheduledUnitData["build_list_position"]; } $positionInList++; // If there are other constructions preceding this, offset by 1. } else { $positionCounter = 0; $positionInList = $listPositions[$positionCounter]; } // Construct list of members foreach ($resources as $itemName) { $itemObject = clone ResourceParser::Instance()->GetItemByName($itemName); // the 'false' boolean means "Don't inform the BuildGroup of a change" because we'll manually calculate build times in a second $itemObject->Amount($amounts[$amountCounter], false); $amountCounter++; if ($listPositions != NULL) { $positionInList = $listPositions[$positionCounter]; $positionCounter++; } if ($itemObject->IsBuilding()) { $members[$positionInList] =& BuildingBuildItem::FromIDResource($itemObject, $positionInList, $positionInList, 0, 1, NULL); } else { $members[$positionInList] =& BuildItem::FromIDResource($itemObject, $positionInList, $positionInList, 0, NULL); } $positionInList++; } if ($itemObject->IsBuilding()) { $rg = new BuildingBuildGroup($members, $colony); } else { $rg = new BuildGroup($members, $colony); } foreach ($rg->Members() as $unit) { $unit->BuildGroup($rg); } if (!$forDeletion) { $rg->FillItemsInDatabase(); // Pretty damn crucial for correct calculation of buildLevels! $rg->UpdateBuildTimes(); } return $rg; }