local AddPrefabPostInitAny = AddPrefabPostInitAny local GetModConfigData = GetModConfigData GLOBAL.setfenv(1, GLOBAL) local breakers = { {"worm"}, {"hound"}, {"worm", "hound"}, } TUNING.BREAKER_TAGS = breakers[GetModConfigData("isbreaker")] TUNING.HOUSEMATES_RADIUS = GetModConfigData("housemate_radius") * 4 local function IsHousematesNear(inst, home, ownerindex) local x, y, z = home.Transform:GetWorldPosition() local has_housemates = false local players = TheSim:FindEntities(x, y, z, home._radius + TUNING.HOUSEMATES_RADIUS, {"player"}) for _, player in ipairs(players) do if player and player:IsValid() then local userindex = TheWorld.net.components.myhome_manager:GetUserIndexByPlayer(player) if ownerindex > 0 and userindex > 0 and (TheWorld.net.components.myhome_manager:IsFriend(ownerindex, userindex) or userindex == ownerindex) then has_housemates = true break end end end return has_housemates end local function OnCollision(inst, other) if other and other:IsValid() and (TUNING.BREAKER_TAGS and other:HasOneOfTags(TUNING.BREAKER_TAGS) or (other:HasTag("epic") and not other:HasTag("bearger"))) then if inst.components.myhome_wall and inst.components.myhome_wall.homeindex > 0 then local homeindex = inst.components.myhome_wall.homeindex local ownerindex = inst.components.myhome_wall.ownerindex local home = TheWorld.net.components.myhome_manager:GetHomeByHomeIndex(homeindex) if not home or (not IsHousematesNear(inst, home, ownerindex) and TUNING.HOUSEMATES_RADIUS > 0) then return end local x, y, z = home.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, home._radius, {"mh_h"..home._homeindex}) for _, v in ipairs(ents) do if v ~= nil and v:IsValid() then if v:HasTag("door") and v._ispathfinding:value() then v.components.activatable.OnActivate(v) end end end end end end AddPrefabPostInitAny(function(inst) if not TheWorld.ismastersim then return inst end if inst:HasTag("wall") and inst.Physics then inst.Physics:SetCollisionCallback(OnCollision) end end)