From 0a1805e6fa8448bcf38b0dde5a77e64213e49bc8 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Fri, 9 Dec 2022 21:55:11 +0300 Subject: [PATCH] don't reset actors each frame by default; make the behavior toggleable --- main.xml | 33 ++++++++++++++++++++++++++++----- typings.lua | 9 +++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/main.xml b/main.xml index 47ea01d..55c3eda 100644 --- a/main.xml +++ b/main.xml @@ -108,6 +108,8 @@ oat.useProfiler = false oat.profilerInfo = {} + local resetOnFrameStartCfg = false + local resetOnFrameStartActors = {} local uraniumFunc = {} @@ -207,6 +209,11 @@ local function onCommand(self) actorsInitialized = true actorsInitializing = false + local resetOnFrameStartActors_ = {} + for k,v in pairs(resetOnFrameStartActors) do + resetOnFrameStartActors_[k.__raw] = v + end + resetOnFrameStartActors = resetOnFrameStartActors_ uranium:call('init') end @@ -291,6 +298,15 @@ DISPLAY:ClearShaderFuck() 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 local actorQueue = {} @@ -770,14 +786,21 @@ drawfunctionArguments = {} for _, q in ipairs(globalQueue) do + local enabled = resetOnFrameStartCfg + local actor = q[1] local v = q[2] - local func = actor[v[1]] - if not func then - -- uhmmm ??? hm. what do we do?? - else - patchFunction(func, actor)(unpack(v[2])) + local pref = resetOnFrameStartActors[actor] + if pref ~= nil then enabled = pref end + + if enabled then + 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 diff --git a/typings.lua b/typings.lua index f40664b..b0eb17a 100644 --- a/typings.lua +++ b/typings.lua @@ -78,6 +78,15 @@ function setDrawFunction(frame, func) end ---@param shader RageShaderProgram 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 --- A simple timer. Ticks upwards at a rate of 1/sec. ---