Mod is updated for Starsector 0.97.
Instructions for a modder wanting to mirror weapons in their mod:
Case 1: The weapon in question does not already have an EveryFrameEffectPlugin attached to it.
• Add an appropriate dependencies entry to your mod's mod_info.json, like so:
"dependencies": [ { "id":"wyv_decolib","name":"DecoLib" } ],
• Add an everyFrameEffect entry to the .wpn file using one of the two completely pre-built weapon-mirroring classes in DecoLib:
"everyFrameEffect": "data.scripts.wyv.MirrorQuadLeft",
Or
"everyFrameEffect": "data.scripts.wyv.MirrorQuadRight",
Case 2: The weapon does have an EveryFrameEffectPlugin, or you want different mirroring behavior than the default quad-left or quad-right.
• Add a dependencies entry to your mod's mod_info.json, as per case 1.
• Do whatever steps you need to do to get your IDE to recognize DecoLib.jar as a referenced library.
• Make your existing EveryFrameEffectPlugin extend MirrorQuadLeft, MirrorQuadRight, or just Mirror.
• If your class doesn't implement its own init or advanceAfter methods, and you extended MirrorQuadLeft or MirrorQuadRight, you're done!
• If your class implements init, or you extended Mirror, then you need to call super.init() from your own init method - setting isMirrored first if you're extending Mirror.
• If your class implements advanceAfter
and the weapon is animated, then you need to call super.advanceAfter() from your own advanceAfter method.
Extra step for decorative weapons:
• Add "NEVER_RENDER_IN_CAMPAIGN" to the "renderHints" field in the .wpn file. Something like this:
"renderHints":[NEVER_RENDER_IN_CAMPAIGN],
• This is needed because weapon mirroring
does not work in campaign contexts; setting this renderHint makes the game simply not show the weapons in such contexts.
• This is not needed for non-deco weapons, as they don't naturally show in campaign contexts in the first place.
And that's it! Simple, right?
If you want to see examples of how this works, take a look at the Mirror mod.
Now, is there more that you can do with DecoUtils? Yes! For example, you can use the ManagedWeapon class to have your weapon read mirroring behavior and custom sprite centerpoint offsets from a json file. But that starts to get beyond the really simple basics, here; if you've got specific questions (or specific things you want DecoUtils to do that it doesn't), feel free to reach out to me via PM or post in this thread.