Skip to content

Instantly share code, notes, and snippets.

@SamuXarick
Last active February 16, 2023 17:58
Show Gist options
  • Save SamuXarick/2c859fb291261ad1c01b8cc910762d5d to your computer and use it in GitHub Desktop.
Save SamuXarick/2c859fb291261ad1c01b8cc910762d5d to your computer and use it in GitHub Desktop.
function LeagueTable::GetInfrastructureEfficiency_Val(company)
{
local rating = 0;
local score = SetText(GetInfrastructureEfficiency_ScoreString(), [ rating ]);
local element = SetText(GetInfrastructureEfficiency_ElementString(), [ company ]);
if (GSCompany.ResolveCompanyID(company) != GSCompany.COMPANY_INVALID) {
local company_scope = GSCompanyMode(company);
local rail_infrastructure_count = GSInfrastructure.GetInfrastructurePieceCount(company, GSInfrastructure.INFRASTRUCTURE_RAIL) + GSInfrastructure.GetInfrastructurePieceCount(company, GSInfrastructure.INFRASTRUCTURE_SIGNALS);
local road_infrastructure_count = GSInfrastructure.GetInfrastructurePieceCount(company, GSInfrastructure.INFRASTRUCTURE_ROAD);
local canal_infrastructure_count = GSInfrastructure.GetInfrastructurePieceCount(company, GSInfrastructure.INFRASTRUCTURE_CANAL);
local airport_infrastructure_count = GSInfrastructure.GetInfrastructurePieceCount(company, GSInfrastructure.INFRASTRUCTURE_AIRPORT);
local any_station_list = GSStationList(GSStation.STATION_ANY);
local num_rail_sts = 0;
local num_road_sts = 0;
local num_dock_sts = 0;
local num_airport_sts = 0;
local visited_rail_sts = 0;
local visited_road_sts = 0;
local visited_dock_sts = 0;
local visited_airport_sts = 0;
foreach (station, _ in any_station_list) {
local vehicle_list = GSVehicleList_Station(station);
vehicle_list.Valuate(GSVehicle.GetVehicleType);
local count = vehicle_list.Count();
if (GSStation.HasStationType(station, GSStation.STATION_TRAIN)) {
num_rail_sts++;
local old_count = count;
vehicle_list.RemoveValue(GSVehicle.VT_RAIL);
count = vehicle_list.Count();
if ((old_count - count) > 0) visited_rail_sts++;
}
if (GSStation.HasStationType(station, GSStation.STATION_TRUCK_STOP) || GSStation.HasStationType(station, GSStation.STATION_BUS_STOP)) {
num_road_sts++;
local old_count = count;
vehicle_list.RemoveValue(GSVehicle.VT_ROAD);
count = vehicle_list.Count();
if ((old_count - count) > 0) visited_road_sts++;
}
if (GSStation.HasStationType(station, GSStation.STATION_DOCK)) {
num_dock_sts++;
local old_count = count;
vehicle_list.RemoveValue(GSVehicle.VT_WATER);
count = vehicle_list.Count();
if ((old_count - count) > 0) visited_dock_sts++;
}
if (GSStation.HasStationType(station, GSStation.STATION_AIRPORT)) {
num_airport_sts++;
local old_count = count;
vehicle_list.RemoveValue(GSVehicle.VT_AIR);
count = vehicle_list.Count();
if ((old_count - count) > 0) visited_airport_sts++;
}
}
local rail_pct = num_rail_sts > 0 ? (visited_rail_sts * 100 / num_rail_sts) : 0;
local road_pct = num_road_sts > 0 ? (visited_road_sts * 100 / num_road_sts) : 0;
local dock_pct = num_dock_sts > 0 ? (visited_dock_sts * 100 / num_dock_sts) : 0;
local airport_pct = num_airport_sts > 0 ? (visited_airport_sts * 100 / num_airport_sts) : 0;
element.p = [ visited_rail_sts, num_rail_sts, rail_pct, visited_road_sts, num_road_sts, road_pct, visited_dock_sts, num_dock_sts, dock_pct, visited_airport_sts, num_airport_sts, airport_pct ];
}
return [ rating, score, element ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment