mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-04-22 23:25:15 +02:00
Add seethru node list support to mcl_mobs.check_line_of_sight
This commit is contained in:
parent
299c209b60
commit
374db5ad24
1 changed files with 9 additions and 3 deletions
|
@ -1,4 +1,11 @@
|
|||
function mcl_mobs.check_line_of_sight(origin, target)
|
||||
local default_seethru = {air = true}
|
||||
|
||||
---@param origin vector.Vector
|
||||
---@param target vector.Vector
|
||||
---@param seethru? {[string]: boolean} Set (look-up table) of nodes to treat as seethrough. Defaults to {air: true}
|
||||
---@return boolean True if line-of-sight is blocked, false otherwise
|
||||
function mcl_mobs.check_line_of_sight(origin, target, seethru)
|
||||
seethru = seethru or default_seethru
|
||||
local raycast = core.raycast(origin, target, false, true)
|
||||
|
||||
local los_blocked = false
|
||||
|
@ -7,7 +14,7 @@ function mcl_mobs.check_line_of_sight(origin, target)
|
|||
--TODO: type object could block vision, for example minecarts
|
||||
local node = core.get_node(core.get_pointed_thing_position(hitpoint))
|
||||
|
||||
if node.name ~= "air" then
|
||||
if not seethru[node.name] then
|
||||
local nodef = core.registered_nodes[node.name]
|
||||
if nodef and nodef.walkable then
|
||||
los_blocked = true
|
||||
|
@ -18,4 +25,3 @@ function mcl_mobs.check_line_of_sight(origin, target)
|
|||
end
|
||||
return not los_blocked
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue