Loading

Paste #p29unkvwv

  1. /*
  2.  * Create an array of targets from industries on the map that accept or produce
  3.  * the predefined cargo for this schema.
  4.  */
  5. function Schema::GetIndustryTargets() {
  6.     // Get a list of all industries that handle the appropriate cargo
  7.     local indList = AIList();
  8.    
  9.     foreach(cargo, _ in this.cargos) {
  10.         indList.AddList(AIIndustryList_CargoAccepting(cargo));
  11.         indList.AddList(AIIndustryList_CargoProducing(cargo));
  12.     }
  13.    
  14.     // The source node is currently a town, which is no good!
  15.     indList.Valuate(AIIndustry.GetDistanceManhattanToTile, AITown.GetLocation(this.sourceNode));
  16.     indList.Sort(AIAbstractList.SORT_BY_VALUE, true);
  17.     this.sourceNode = indList.Begin();
  18.    
  19.     // Build a list of targets
  20.     local targets = Map();
  21.     foreach(industry, _ in indList) {
  22.         targets.Insert(Target(Target.TYPE_INDUSTRY, industry));
  23.     }
  24.  
  25.     return targets;
  26. }

Comments