prefabs/plantables.lua
123456
require "prefabutil"
local function test_ground(inst, pt)
local tiletype = GetGroundTypeAtPosition(pt)
local ground_OK = tiletype ~= GROUND.ROCKY and tiletype ~= GROUND.ROAD and tiletype ~= GROUND.IMPASSABLE and
123456
require "prefabutil"
local notags = {'NOBLOCK', 'player', 'FX'}
local function test_ground(inst, pt)
local tiletype = GetGroundTypeAtPosition(pt)
local ground_OK = tiletype ~= GROUND.ROCKY and tiletype ~= GROUND.ROAD and tiletype ~= GROUND.IMPASSABLE and
89101112131415161718
tiletype ~= GROUND.CARPET and tiletype ~= GROUND.CHECKER and tiletype < GROUND.UNDERGROUND
if ground_OK then
local ents = TheSim:FindEntities(pt.x,pt.y,pt.z, 4) -- or we could include a flag to the search?
local min_spacing = inst.components.deployable.min_spacing or 2
for k, v in pairs(ents) do
if v ~= inst and v.entity:IsValid() and v.entity:IsVisible() and not v:HasTag("NOBLOCK") and not v:HasTag("player") and not v.components.placer and v.parent == nil and not v:HasTag("FX") then
if distsq( Vector3(v.Transform:GetWorldPosition()), pt) < min_spacing*min_spacing then
return false
end
89101112131415161718
tiletype ~= GROUND.CARPET and tiletype ~= GROUND.CHECKER and tiletype < GROUND.UNDERGROUND
if ground_OK then
local ents = TheSim:FindEntities(pt.x,pt.y,pt.z, 4, nil, notags) -- or we could include a flag to the search?
local min_spacing = inst.components.deployable.min_spacing or 2
for k, v in pairs(ents) do
if v ~= inst and v.entity:IsValid() and v.entity:IsVisible() and not v.components.placer and v.parent == nil then
if distsq( Vector3(v.Transform:GetWorldPosition()), pt) < min_spacing*min_spacing then
return false
end