Adds (configurable) random chances to various elements of a job's chain of cars.
Permissions and credits
Author's instructions
Licensed under the MIT license. See Source and License link below.
File credits
User @AdroitCobra on the Derail Valley Discord for the mod suggestion
Donation Points system
Please log in to find out whether this mod is receiving Donation Points
Changelogs
Version 0.1.1
Updated Config to support new additions by catching exceptions and accepting as much data as we could recover.
Added new config options 'EventsPerJob' and 'RandomizeOnSpawnOnly'.
Consolidated all randomization code from harmony patches into one static class which also contains public APIs.
Abstracted TrainCar randomization to Station randomization.
Pulled station randomization far enough up the execution chain, so it can effectively run before and after the relevant TrainCar generation done by PersistentJobs.
Now supports PersistentJobs by allowing trains to be modified on re-entry to the station. The config allows this to be restricted to the previous behaviour with the 'RandomizeOnSpawnOnly', which with PersistentJobs active, will restrict events to game start/initial station entry, and with vanilla it will act similarly to if it was left unchanged.
Abstracted randomization code into `Randomizer.Event`s, simple structs containing a string Id and some delegates for random chance validation and execution.
`RandomizeCarSetups.Randomizer.ActiveEvents` is a public static readonly List<Randomizer.Event> that other developers could theoretically add custom events with.
These ActiveEvents are randomly selected 'EventsPerJob' times when we determine what to do to each set of train cars. Then validated to make sure the event hasn't run on that set of cars before executing if it passes the events custom randomization check (which we provide a convenient 0-1 float for percentage checks).
Implemented a simple static SaveGameData class to manage the saving and loading of each save's events that have been executed (Train cars are removed from the list on job-acceptance to prevent it from becoming infinitely larger).
Sloppy Shunters The shunters before you are a bit sloppy.. They've been known to leave handbrakes applied on arbitrary cars and couplers in disarray, you should be sure to check your cars carefully before each haul or you might just pull away with half a load!