Skip to content

Commit

Permalink
feat: add functions to get actors adjacent and with specified distance
Browse files Browse the repository at this point in the history
  • Loading branch information
LordMidas committed Apr 21, 2024
1 parent d4c8bba commit 566aa3e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions msu/hooks/entity/tactical/tactical_entity_manager.nut
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,45 @@
}
return ret;
}

q.getActorsWithDistance <- function( _tile, _distance, _atDistance = false )
{
if (_distance == 1)
{
local ret = [];

if (!_atDistance && _tile.IsOccupiedByActor)
ret.push(_tile.getEntity());

for (local i = 0; i < 6; i++)
{
if (!_tile.hasNextTile(i))
continue;

local nextTile = _tile.getNextTile(i);
if (nextTile.IsOccupiedByActor)
ret.push(nextTile.getEntity());
}

return ret;
}
else
{
return this.getActorsByFunction(function(_actor) {
if (!_actor.isPlacedOnMap())
return false;
local distance = _tile.getDistanceTo(_actor.getTile());
if (distance > _distance)
return false;
return !_atDistance || distance == _distance;
})
}
}

q.getAdjacentActors <- function( _tile )
{
return this.getActorsWithDistance(_tile, 1, true);
}

q.getAlliedActors <- function( _faction, _tile = null, _distance = null, _atDistance = false )
{
Expand Down

0 comments on commit 566aa3e

Please sign in to comment.