Skip to content

Commit 566aa3e

Browse files
committed
feat: add functions to get actors adjacent and with specified distance
1 parent d4c8bba commit 566aa3e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

msu/hooks/entity/tactical/tactical_entity_manager.nut

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,45 @@
3232
}
3333
return ret;
3434
}
35+
36+
q.getActorsWithDistance <- function( _tile, _distance, _atDistance = false )
37+
{
38+
if (_distance == 1)
39+
{
40+
local ret = [];
41+
42+
if (!_atDistance && _tile.IsOccupiedByActor)
43+
ret.push(_tile.getEntity());
44+
45+
for (local i = 0; i < 6; i++)
46+
{
47+
if (!_tile.hasNextTile(i))
48+
continue;
49+
50+
local nextTile = _tile.getNextTile(i);
51+
if (nextTile.IsOccupiedByActor)
52+
ret.push(nextTile.getEntity());
53+
}
54+
55+
return ret;
56+
}
57+
else
58+
{
59+
return this.getActorsByFunction(function(_actor) {
60+
if (!_actor.isPlacedOnMap())
61+
return false;
62+
local distance = _tile.getDistanceTo(_actor.getTile());
63+
if (distance > _distance)
64+
return false;
65+
return !_atDistance || distance == _distance;
66+
})
67+
}
68+
}
69+
70+
q.getAdjacentActors <- function( _tile )
71+
{
72+
return this.getActorsWithDistance(_tile, 1, true);
73+
}
3574

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

0 commit comments

Comments
 (0)