Change when CameraBound component is removed

Remove CameraBound component when capturing entities, but not when modifying entities
This commit is contained in:
David Vogel 2022-07-28 17:00:24 +02:00
parent 25a28c8469
commit fd7fb31338
3 changed files with 12 additions and 2 deletions

View File

@ -344,6 +344,14 @@ local function captureModifyEntities(file, modify, x, y, radius)
file:write(",\n\t", JSON.Marshal(rootEntity), "\n", "]") file:write(",\n\t", JSON.Marshal(rootEntity), "\n", "]")
end 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. -- Prevent recapturing.
rootEntity:AddTag("MapCaptured") rootEntity:AddTag("MapCaptured")
end end

View File

@ -5,13 +5,15 @@
local Vec2 = require("noita-api.vec2") 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 = { Config.ComponentsToDisable = {
"AnimalAIComponent", "AnimalAIComponent",
"SimplePhysicsComponent", "SimplePhysicsComponent",
"CharacterPlatformingComponent", "CharacterPlatformingComponent",
"WormComponent", "WormComponent",
"WormAIComponent", "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", --"PhysicsBodyCollisionDamageComponent",
--"ExplodeOnDamageComponent", --"ExplodeOnDamageComponent",
--"DamageModelComponent", --"DamageModelComponent",

View File

@ -92,7 +92,7 @@ end
---Doesn't ensure any chunks around the player. ---Doesn't ensure any chunks around the player.
function OnWorldInitialized() function OnWorldInitialized()
-- Set camera free based on mod settings. -- 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 end
---Called *every* time the game is about to start updating the world. ---Called *every* time the game is about to start updating the world.