function Utils::IsTownGrowing(town, cargo) {
local cargoList = AICargoList();
local cargoRequired = AIList();
for (local cargo_type = cargoList.Begin(); !cargoList.IsEnd(); cargo_type = cargoList.Next()) {
local town_effect = AICargo.GetTownEffect(cargo_type);
if (town_effect != AICargo.TE_NONE) {
local cargo_goal = AITown.GetCargoGoal(town, town_effect);
if (cargo_goal != 0) {
// AILog.Info("Cargo " + AICargo.GetCargoLabel(cargo_type) + " is required to grow " + AITown.GetName(town));
cargoRequired.AddItem(cargo_type, 0);
}
}
}
local num_cargo_required = cargoRequired.Count();
local result = null;
if (num_cargo_required == 0 || cargoRequired.HasItem(cargo) && num_cargo_required == 1) {
result = true;
} else {
result = false;
}
// AILog.Info("Result for town " + AITown.GetName(town) + ": " + result + " - " + num_cargo_required);
return result;
}