Skip to content

Commit 43f75a9

Browse files
committed
feat: add functions to get actors adjacent and with specified distance
1 parent f75c14f commit 43f75a9

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
@@ -8,6 +8,45 @@
88
}
99
return ret;
1010
}
11+
12+
q.getActorsWithDistance <- function( _tile, _distance, _atDistance = false )
13+
{
14+
if (_distance == 1)
15+
{
16+
local ret = [];
17+
18+
if (!_atDistance && _tile.IsOccupiedByActor)
19+
ret.push(_tile.getEntity());
20+
21+
for (local i = 0; i < 6; i++)
22+
{
23+
if (!_tile.hasNextTile(i))
24+
continue;
25+
26+
local nextTile = _tile.getNextTile(i);
27+
if (nextTile.IsOccupiedByActor)
28+
ret.push(nextTile.getEntity());
29+
}
30+
31+
return ret;
32+
}
33+
else
34+
{
35+
return this.getActorsByFunction(function(_actor) {
36+
if (!_actor.isPlacedOnMap())
37+
return false;
38+
local distance = _tile.getDistanceTo(_actor.getTile());
39+
if (distance > _distance)
40+
return false;
41+
return !_atDistance || distance == _distance;
42+
})
43+
}
44+
}
45+
46+
q.getAdjacentActors <- function( _tile )
47+
{
48+
return this.getActorsWithDistance(_tile, 1, true);
49+
}
1150

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

0 commit comments

Comments
 (0)