diff --git a/files/capture.lua b/files/capture.lua index a14cf64..f5651dd 100644 --- a/files/capture.lua +++ b/files/capture.lua @@ -344,6 +344,14 @@ local function captureModifyEntities(file, modify, x, y, radius) file:write(",\n\t", JSON.Marshal(rootEntity), "\n", "]") end + -- Disabling this component will prevent entites from being killed/reset when they go offscreen. + -- If they are reset, all tags will be reset and we may capture these entities multiple times. + -- This has some side effects, like longleg.xml and zombie_weak.xml will respawn every revisit, as their spawner doesn't get deleted. (Or something similar to this) + local components = rootEntity:GetComponents("CameraBoundComponent") + for _, component in ipairs(components) do + rootEntity:SetComponentsEnabled(component, false) + end + -- Prevent recapturing. rootEntity:AddTag("MapCaptured") end diff --git a/files/config.lua b/files/config.lua index d6c67b2..e0f3aad 100644 --- a/files/config.lua +++ b/files/config.lua @@ -5,13 +5,15 @@ local Vec2 = require("noita-api.vec2") +-- List of components that will be disabled on every encountered entity. +-- This is only used when modifying entities, not when capturing/storing them. Config.ComponentsToDisable = { "AnimalAIComponent", "SimplePhysicsComponent", "CharacterPlatformingComponent", "WormComponent", "WormAIComponent", - "CameraBoundComponent", -- Disabling this component will prevent entites from being killed/reset when they go offscreen. If they are reset, all tags will be reset and we may capture these entities multiple times. This has some side effects, like longleg.xml and zombie_weak.xml will respawn every revisit, as the spawner doesn't get deleted. + --"CameraBoundComponent", -- This is already removed when capturing/storing entities. Not needed when we only modify entities. --"PhysicsBodyCollisionDamageComponent", --"ExplodeOnDamageComponent", --"DamageModelComponent", diff --git a/init.lua b/init.lua index 41af02c..5f952e6 100644 --- a/init.lua +++ b/init.lua @@ -92,7 +92,7 @@ end ---Doesn't ensure any chunks around the player. function OnWorldInitialized() -- Set camera free based on mod settings. - Modification.SetCameraFree() + Modification.SetCameraFree() -- BUG: Calling this here has the side effect of the player entity not being loaded. Also the player UI will be gone end ---Called *every* time the game is about to start updating the world.