Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: DModManagers and the Women Who Love Them  (Read 742 times)

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
DModManagers and the Women Who Love Them
« on: September 13, 2019, 06:49:07 PM »

Rather than having a static DModManager, which has to be overridden if we want to add more D-mod "type" tags and is therefore only modifiable by one mod at a time (unless I'm missing something), it would be awesome if this could be reworked to work something like the following:

  • new class: DModTagHandlerAPI or something, has methods that accept the same arguments as DModManager.addDMods() plus List<HullModSpecAPI> potentialMods (or I guess a params object containing them) and return the same
  • DModManager changed to be sector-specific and register DModTagHandlerAPIs, build a List<HullModSpecAPI> potentialMods as normal, then pass all arguments as well as the list in a params object to all registered DModTagHandlerAPIs before finally deduplicating the list and actually adding D-mods to the ship
  • Modders write DModTagHandlerAPIs to determine the conditions when their D-mods tagged with new tags (not in vanilla) would be added (or more likely: removed) from the list, then register their DModTagHandlerAPIs to Global.getSector().getDModManager() on game load or whatever

Cases where this might be useful would be, say I want to add a D-mod that only affects ships with missile-capable (missile, composite, synergy, universal) mounts, and reduces the cost of all missile weapons by 100 OP while making them regenerate ammo. I tag this with "hasMissile", but to make that do anything special I have to override DModManager (again, unless I'm way wrong about this) with all the same methods plus a bit in the middle of removeUnsuitedMods() that checks for the presence of a missile-capable mount and removes the mod from the list of potentials unless there is one... but wait! Someone else wants to add a D-mod that only affects ships from their particular faction, so they also override DModManager! So we're stuck, and now every missile costs 0 OP and regenerates ammo, just as planned...

If I've missed something obvious that makes this not necessary, on the other hand, please let me know because that'd be great news.  ;D

EDIT: dunno if there's actually any reason why that would mean the DModManager has to be sector-specific so maybe just ignore that part, the important part is the functionality
« Last Edit: September 13, 2019, 08:59:20 PM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it