Weekly Update: February 16, 2024

I spent almost five straight days in this past week working on one “small” feature:

Multi-module selection. I.e., the ability to remove more than one module from the ship and move them.

Why was this feature so hard?

One reason is that the shipbuilder logic is pretty complicated and module selection was designed around manipulating a single module. Anyone who has worked in software has probably noticed that early design decisions have a tendency to get baked-in, as later modifications treat those decisions as reliable assumptions.

Here are just some of the things that need to happen around the process of selecting, removing and placing module(s):

  • Remove the module from the ship’s data structure
  • Remove the module gameobject from the ship’s transform
  • Instantiate a temporary gameobject to represent the “carried” module
  • Calculate the target position of the module in hex coordinates
  • Transform, rotate, and mirror hexagonal coordinates and their edges
  • Smoothly lerp the model’s position and rotation
  • Calculate ship stat changes
  • Check for module overlaps
  • Enforce placement and rotation rules
  • Calculate every hex edge connection
  • Find “orphaned” modules and recycle them
  • Record undo/redo steps
  • Apply color swatches
  • Play “weld” and “recycle” animations
  • Deduct or refund resource differences
  • Determine what grid cells in the shipbuilder are visible
  • Placement hinting in the grid to indicate overlaps, connections, etc

Another reason is that I’ve found it quite challenging to plan the necessary coordinate transformations. E.g., if you move, then rotate, then mirror a selection with a sub-module, what happens to that sub-module’s offset, hex coordinates, rotation and mirror? Moving modules is pretty simple. Rotating was a bit of a challenge, but doable. I’ll tell you how hard group mirroring is if I ever figure it out.

The feature I believe is working, sans group mirroring, and so I’ve deployed it as a patch to the Jupiter Unstable branch.

Now, if you remove any module that creates “orphaned” modules, rather than those modules being immediately recycled, they are added to the selection. You can move and rotate the selection as a group.

There’s also a multi-select mode. If you hold “shift” you can select specific modules to manipulate by clicking on them sequentially. When you release shift they will become a selection group. This way you can manipulate multiple modules, even if they would still be connected to the ship without the first module.

Feedback from Jupiter continues to be positive: no major issues compared to Icarus. Named builds are not save compatible, but if you’re starting a new game, you may want to switch to the Jupiter opt-in for the added content, bug fixes and new features.

Until next week!
– Kevin