[REQUEST] Add new getAdjacentActors function for actor.nut
Opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
Several skills and perks work off of adjacent entities, meaning anyone standing on the 6 tiles around an entity/position.
In Vanilla this is very copy&pasty done with a for-loop from 0 to 5 which then checks each tile via a getNext(i)
function.
MSU currently only offers ::Tactical.Entities.getActorsByFunction
but that is not efficient when we know that we only need to check the adjacent tiles. That function instead iterates over every entity on the whole battlefield and it is also a bit harder to parse when reading the code.
Describe the solution you'd like
I would like to have a function getAdjacentActors()
for the actor.nut
class which returns an array of up to 6 actor references.
Adjacency is where I draw the line already for this. Anything beyond adjacent needs to fall back on a getActorsByFunction
call.
Feel free to make this into a PR, it could be added to 1.4
Seems like a useful function to have. I have a couple of questions regarding this:
Question 1:
Should this exist in actor.nut
:
<actor>.getAdjacentActors();
Or in tactical_entity_manager.nut
:
::Tactical.Entities.getAdjacentActors(actor);
The latter is the usual place for other such functions.
Question 2:
You don't always want every single actor, rather sometimes you may only want allied actors, or hostile actors, etc. So perhaps the function should accept an optional filter of some sort in its parameters? There are four distinct filters we need:
- Allied (contains both my faction and other allied factions)
- Hostile
- Same faction
- Non faction allied