A month of two halves…#
July was split between work and a long-overdue summer break, so the coding split neatly in two. Work was still on my mind at first, but then I settled into my go-to turn-based wargame. The first week was a burst of CAD work - drawing tools and snapping. The rest of the month belonged to Skirmish, which moved its game objects over to ECS composition and, in doing so, dragged a couple of embarrassingly missing features into Gremlin.
Drawing, with snapping#
Gremlin’s Cad namespace gained a proper drawing-tool framework: a CadTool base, a CadToolStack that routes input to whichever tool is active, a first PolylineTool and TransformTool, and a little CursorRay helper for turning the mouse position into a ray in the 3D view. Within the day there was basic polyline drawing, with grid and axis snapping, running in the workbench.
The interesting part is snapping. The design splits policy from positions:
- Snap providers each know about one kind of position - grid points, axis lines, geometry already in the document and, after a rework the next day, geometry the active tool is generating.
- The SnapEngine owns the policy. It throws away disabled kinds, keeps candidates within tolerance, and ranks them by kind priority first, cursor distance second.
That ranking rule is what makes it feel like CAD. If distance came first, a grid point right under the cursor would always beat an endpoint a few pixels away, and you’d never be able to hit an endpoint near a grid line. Maddening! Priorities are a table rather than code, so they can be tuned without touching the engine.
Two follow-ups landed within days. Snap radii are now correct at oblique viewing angles - a tolerance in pixels means very different distances in the world when you’re looking along a plane. And angular snapping draws little indicator lines, so you can see what you’ve locked on to.
Skirmish goes full ECS#
Skirmish started life with its game objects as good old-fashioned OO classes. In July that changed: first the game objects moved into the ECS (still hidden behind ‘increasingly thin classes’, as I put it at the time), and by the 22nd the characters themselves were being composed from components rather than inherited from classes. Its game phases also got broken out into distinct classes, with a ‘Conductor’ organising the transitions and view changes between them.
That’s a big shift for one game, and it found two holes in Gremlin straight away.
Entities can die now#
Rather embarrassingly, Gremlin’s ECS could create entities but had no proper support for destroying them. A wargame where characters get taken off the board can’t really live with that. So July added entity destruction, plus debug assertions that catch any attempt to use an entity after it’s been destroyed.
The UI that wasn’t there#
And a good bug: VisibilitySystem ignored the children of any parent that had no Renderable. The UI root is exactly such a parent, so whole UI trees could go unprocessed - invisible, and very confusing. It turned up the same day as a big simplification of Skirmish’s overlay construction code. The fix handles renderable-less parents properly, and caches the root parents it finds along the way.
Bits & bobs#
- Hover is now forced off when a hoverable is disabled, and the nine-patch hover isn’t drawn for things you can’t select.
- The space-creation helper for UI layouts takes a proportion.
- Tile maps report their full pixel dimensions and tile sizes.

