function canPlaceObject(objectElement)
if isElement(objectElement) then
local objectX, objectY, objectZ = getElementPosition(objectElement)
local minX, minY, minZ, maxX, maxY, maxZ = getElementBoundingBox(objectElement)
local objectMatrix = getElementMatrix(objectElement)
for i = 0, 1 do
local z = minZ + maxZ * i
local offX, offY, offZ = getPositionFromElementOffset(objectMatrix, minX, minY, z)
if not isLineOfSightClear(objectX, objectY, objectZ, offX, offY, offZ, true, true, false, true, true, false, false, localPlayer) then
return false
end
offX, offY, offZ = getPositionFromElementOffset(objectMatrix, maxX, minY, z)
if not isLineOfSightClear(objectX, objectY, objectZ, offX, offY, offZ, true, true, false, true, true, false, false, localPlayer) then
return false
end
offX, offY, offZ = getPositionFromElementOffset(objectMatrix, minX, maxY, z)
if not isLineOfSightClear(objectX, objectY, objectZ, offX, offY, offZ, true, true, false, true, true, false, false, localPlayer) then
return false
end
offX, offY, offZ