Loading

Paste #p6kltihwu

  1. function Utils::IsTownGrowing(town, cargo) {
  2.     local cargoList = AICargoList();
  3.     local cargoRequired = AIList();
  4.     for (local cargo_type = cargoList.Begin(); !cargoList.IsEnd(); cargo_type = cargoList.Next()) {
  5.         local town_effect = AICargo.GetTownEffect(cargo_type);
  6.         if (town_effect != AICargo.TE_NONE) {
  7.             local cargo_goal = AITown.GetCargoGoal(town, town_effect);
  8.             if (cargo_goal != 0) {
  9. //              AILog.Info("Cargo " + AICargo.GetCargoLabel(cargo_type) + " is required to grow " + AITown.GetName(town));
  10.                 cargoRequired.AddItem(cargo_type, 0);
  11.             }
  12.         }
  13.     }
  14.     local num_cargo_required = cargoRequired.Count();
  15.     local result = null;
  16.     if (num_cargo_required == 0 || cargoRequired.HasItem(cargo) && num_cargo_required == 1) {
  17.         result = true;
  18.     } else {
  19.         result = false;
  20.     }
  21. //  AILog.Info("Result for town " + AITown.GetName(town) + ": " + result + " - " + num_cargo_required);
  22.     return result;
  23. }

Comments