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)

Pages: 1 [2]

Author Topic: [0.97a-RC11] Mirror 1.4 & DecoLib 0.3  (Read 26845 times)

Wyvern

  • Admiral
  • *****
  • Posts: 3781
    • View Profile
Re: [0.97a-RC11] Mirror 1.3 & DecoLib 0.3
« Reply #15 on: March 09, 2024, 04:39:28 PM »

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:
Code
"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:
Code
"everyFrameEffect": "data.scripts.wyv.MirrorQuadLeft",
Or
Code
"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:
Code
"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.
« Last Edit: March 09, 2024, 04:52:02 PM by Wyvern »
Logged
Wyvern is 100% correct about the math.

Wyvern

  • Admiral
  • *****
  • Posts: 3781
    • View Profile
Re: [0.96a-RC10] Mirror 1.4 & DecoLib 0.3
« Reply #16 on: March 10, 2024, 03:55:52 PM »

next version should include mining lasers and ion beams
...And somehow I still forgot to include these in Mirror 1.3, so now we've got a Mirror 1.4. Hopefully that's the last update Mirror will need for a while...

(DecoLib, by contrast, is still actively being worked on. I want space dragons with articulated wings and tails, darn it! And while I'm not there yet, I do have all the base pieces I need for it... just need to actually do the trig/matrix calculations, wire it all together, and actually build some ship graphics...)
Logged
Wyvern is 100% correct about the math.
Pages: 1 [2]