Submissions from 2017-10-16 to 2017-10-17 (1 total)

Started working on a system that I think will be reused in quite a few places throughout the game. I'm having a hard time coming up with a succinct title for it, but I'm currently calling it "Tile Mask".

Basically, I want to define a reusable object that defines all the tiles that should be 'valid' for a given action, from a given position, for things like: movement, attacking, area-of-affect abilities etc. Basically, it's this from Hoplite.

In the Unity world, I'm implementing it as a Scriptable Object that will be configurable in the editor, and then reuseable on other prefabs/components so, for instance, an attack component can be 'masked' by a "Tile Mask". The "Tile Mask" exposes a simple API for checking if a queried position is 'valid'. Valid means it's within the mask'd grid cells, and (for now) also whether the tile is actually passable in the terrain.

This is what I have so far:

For now, the 'shape' of the mask is limited to a rectangle, but soon I will implement the ability to configure it to arbitrary shapes with some improved Editor scripting.


Implementing it did raise a pretty serious design question:

  • Right now, the test for terrain passability is 'hard coded'. But what if I want an ability that doesn't care about that? Or want the inverse behavior? What if I want a 'mask' that is only valid if there is an enemy at that tile? That is quite different logic.. I could hack these 'options' in with bool parameters, but it raises a bigger question about how best to design the configurability in this regard.
Also, what is a better name than "Tile Mask", since that has (at least to me) an inherit graphical connotation than what this concept is used for.