How To Use RetroLib (in a nutshell)
A working example is included with RetroLib - it adds a retrofitter to every bar when dev mode is active. It consists of 2 entries in rules.csv and a rule command located at src/retroLib.impl.rulecmd.RetroLib_DefaultAccess.
Your goal when making your own version is to create an adjuster, filter, manager, and delivery service, hand them off to a class or classes that create a UI, then show that UI to the player. The default UI, as shown in the example, is a dialog plugin with separate classes to handle the logic (interactor), UI (view), and passing data between them (model).
There are 2 tricks RetroLib provides. The first trick is you can use the Base classes in retroLib.impl and only modify what you need to customize your retrofitter.
- Filter - filters out retrofits you don't want your retrofitter to ever show
- Adjuster - modifies retrofit data before and after filtering - cost, how long it takes to complete, anything
- Manager - handles which retrofits are shown at which times (allowed, unavailable, illegal, or otherwise not allowed)
- Delivery Service - handles delivering the completed retrofits
The second trick is that your UI does not need to be a dialog plugin. It could be a submarket or a fully custom GUI - anything at all. The four pieces above don't care.
My Roider Union mod demonstrates several modifications in src/roiderUnion.retrofit. The UnionHQ version simply filters retrofits (filter), makes retrofits instant (delivery service), and plays a music loop (view). Shipworks and Nomad retrofits are a little more involved. Finally, Argos retrofitting is accessed through an ability, uses commodities instead of credits, and is limited by the Argosi in the player's fleet, which requires a lot more code to achieve.
Changelog:
Version 1.1.0
Changes
- Updated to 0.98a
- Replaced S-mod transfer with bonus XP
Version 1.0.1
Bug Fixes
- Stopped built-in wings from dropping as LPCs when RetroLib strips a ship
Version 1.0.0
- Initial release