/* * Create an array of targets from industries on the map that accept or produce * the predefined cargo for this schema. */ function Schema::GetIndustryTargets() { // Get a list of all industries that handle the appropriate cargo local indList = AIList(); foreach(cargo, _ in this.cargos) { indList.AddList(AIIndustryList_CargoAccepting(cargo)); indList.AddList(AIIndustryList_CargoProducing(cargo)); } // The source node is currently a town, which is no good! indList.Valuate(AIIndustry.GetDistanceManhattanToTile, AITown.GetLocation(this.sourceNode)); indList.Sort(AIAbstractList.SORT_BY_VALUE, true); this.sourceNode = indList.Begin(); // Build a list of targets local targets = Map(); foreach(industry, _ in indList) { targets.Insert(Target(Target.TYPE_INDUSTRY, industry)); } return targets; }