SHOW:
|
|
- or go back to the newest paste.
| 1 | function character.ValidTiles(start, mapModel, range) | |
| 2 | - | local found, following, current = {}, {[start] = 0}
|
| 2 | + | local found, following, current = {}, {[start] = 0}
|
| 3 | - | for step=1,range do |
| 3 | + | for step = 1, range do |
| 4 | - | current, following = following, {}
|
| 4 | + | current, following = following, {}
|
| 5 | - | for space in pairs(current) do |
| 5 | + | for space in pairs(current) do |
| 6 | - | if space.isTraversable then |
| 6 | + | if space.isTraversable and (not space.Character or space == start) then |
| 7 | - | for neighbor in neighborsInMap(space) do |
| 7 | + | for neighbor in neighborsInMap(space) do |
| 8 | - | found[neighbor.yTile] = found[neighbor.yTile] or {}
|
| 8 | + | found[neighbor.yTile] = found[neighbor.yTile] or {}
|
| 9 | - | if not found[neighbor.yTile][neighbor.xTile] then |
| 9 | + | if not found[neighbor.yTile][neighbor.xTile] then |
| 10 | found[neighbor.yTile][neighbor.xTile] = neighbor | |
| 11 | following[neighbor] = step | |
| 12 | - | end |
| 12 | + | end |
| 13 | - | end |
| 13 | + | end |
| 14 | - | end |
| 14 | + | end |
| 15 | - | end |
| 15 | + | end |
| 16 | - | end |
| 16 | + | end |
| 17 | - | return found |
| 17 | + | found[start] = nil |
| 18 | return found | |
| 19 | end |