derail-valley-modding / custom-car-loader

A Derail Valley mod that allows the addition of new cars and locomotive types to the game.
https://nexusmods.com/derailvalley/mods/324
MIT License
14 stars 6 forks source link

Add public utility to find loco type for a given tender #202

Open fauxnik opened 10 months ago

fauxnik commented 10 months ago

Is your feature request related to a problem? Please describe. Rolling Stock Ownership needs this information.

Describe the solution you'd like When passed a TrainCarLivery belonging to a tender, the associated locomotive's TrainCarLivery is returned.

Additional context From RSO:

private static Dictionary<TrainCarLivery, TrainCarLivery> locomotiveForTender = new Dictionary<TrainCarLivery, TrainCarLivery>
{
    { TransitionHelpers.ToV2(TrainCarType.Tender), TransitionHelpers.ToV2(TrainCarType.LocoSteamHeavy) }
};

// TODO: how to get loco/tender associations from CCL?
public static TrainCarLivery LocoForTender(TrainCarLivery carLivery)
{
    return locomotiveForTender.ContainsKey(carLivery) ? locomotiveForTender[carLivery] : carLivery;
}