don't reset actors each frame by default; make the behavior toggleable

This commit is contained in:
Jill 2022-12-09 21:55:11 +03:00
parent f4e8c1df7c
commit 0a1805e6fa
2 changed files with 37 additions and 5 deletions

View File

@ -108,6 +108,8 @@
oat.useProfiler = false oat.useProfiler = false
oat.profilerInfo = {} oat.profilerInfo = {}
local resetOnFrameStartCfg = false
local resetOnFrameStartActors = {}
local uraniumFunc = {} local uraniumFunc = {}
@ -207,6 +209,11 @@
local function onCommand(self) local function onCommand(self)
actorsInitialized = true actorsInitialized = true
actorsInitializing = false actorsInitializing = false
local resetOnFrameStartActors_ = {}
for k,v in pairs(resetOnFrameStartActors) do
resetOnFrameStartActors_[k.__raw] = v
end
resetOnFrameStartActors = resetOnFrameStartActors_
uranium:call('init') uranium:call('init')
end end
@ -291,6 +298,15 @@
DISPLAY:ClearShaderFuck() DISPLAY:ClearShaderFuck()
end end
function resetOnFrameStart(bool)
resetOnFrameStartCfg = bool
end
function resetActorOnFrameStart(actor, bool)
if bool == nil then bool = not resetOnFrameStartCfg end
resetOnFrameStartActors[actor.__raw or actor] = bool
end
-- actors -- actors
local actorQueue = {} local actorQueue = {}
@ -770,14 +786,21 @@
drawfunctionArguments = {} drawfunctionArguments = {}
for _, q in ipairs(globalQueue) do for _, q in ipairs(globalQueue) do
local enabled = resetOnFrameStartCfg
local actor = q[1] local actor = q[1]
local v = q[2] local v = q[2]
local func = actor[v[1]] local pref = resetOnFrameStartActors[actor]
if not func then if pref ~= nil then enabled = pref end
-- uhmmm ??? hm. what do we do??
else if enabled then
patchFunction(func, actor)(unpack(v[2])) local func = actor[v[1]]
if not func then
-- uhmmm ??? hm. what do we do??
else
patchFunction(func, actor)(unpack(v[2]))
end
end end
end end

View File

@ -78,6 +78,15 @@ function setDrawFunction(frame, func) end
---@param shader RageShaderProgram ---@param shader RageShaderProgram
function setShader(actor, shader) end function setShader(actor, shader) end
-- Toggle actor resetting on frame start behavior by default.
---@param bool boolean
function resetOnFrameStart(bool) end
-- Toggle actor resetting on frame start for individual actors. `bool` defaults to the opposite of your `resetOnFrameStart` config
---@param actor Actor
---@param bool boolean | nil
function resetActorOnFrameStart(actor, bool) end
---@type number ---@type number
--- A simple timer. Ticks upwards at a rate of 1/sec. --- A simple timer. Ticks upwards at a rate of 1/sec.
--- ---