Start entity capturing based on mod settings

- Rename disable-entity-components mod setting to modify-entities
- Add IsPlayer and IsInvisible methods to entity API
- Don't modify the player entity
This commit is contained in:
David Vogel 2022-07-28 12:38:26 +02:00
parent 640a241d38
commit 6becf72420
3 changed files with 22 additions and 2 deletions

View File

@ -322,7 +322,8 @@ local function captureModifyEntities(file, modify, x, y, radius)
end
-- Make sure to only modify entities when they are encountered the first time.
if modify and not rootEntity:HasTag("MapModified") then
-- Also, don't modify the player.
if modify and not rootEntity:IsPlayer() and not rootEntity:HasTag("MapModified") then
-- Disable some components.
for _, componentTypeName in ipairs(Config.ComponentsToDisable) do
local components = rootEntity:GetComponents(componentTypeName)
@ -506,6 +507,11 @@ function Capture:StartCapturing()
Message:ShowRuntimeError("StartCapturing", string.format("Unknown capturing mode %q", tostring(mode)))
end
-- Start entity capturing and modification, if wanted.
local captureEntities = ModSettingGet("noita-mapcap.capture-entities")
local modifyEntities = ModSettingGet("noita-mapcap.modify-entities")
self:StartCapturingEntities(captureEntities, modifyEntities)
end)
end

View File

@ -340,6 +340,20 @@ end
-- TODO: Add missing Noita API methods and functions.
---
---@return boolean
function NoitaEntity:IsPlayer()
return IsPlayer(self.ID)
end
---
---@return boolean
function NoitaEntity:IsInvisible()
return IsInvisible(self.ID)
end
-- TODO: Add missing Noita API methods and functions.
-------------------------
-- JSON Implementation --
-------------------------

View File

@ -263,7 +263,7 @@ modSettings = {
not_setting = true,
},
{
id = "disable-entity-components",
id = "modify-entities",
ui_name = " Modify entities",
ui_description = "If enabled, the mod will disable some components of all encountered entities.\nThis will:\n- Disable AI\n- Disable falling\n- Disable hovering and rotation animations\n- Reduce explosions\n \nThis may slow down things a bit.\nAnd it may make Noita more likely to crash.\nUse at your own risk.",
value_default = false,