refactor: removed compat with b41 entirely

This commit is contained in:
ZioPao
2025-12-16 00:34:40 +01:00
parent 3f888e7f22
commit 20fa1bd05e
249 changed files with 215 additions and 176 deletions

View File

@@ -0,0 +1,48 @@
local StaticData = require("TOC/StaticData")
-----------------------------------
local CommonMethods = {}
---@param val number
---@param min number
---@param max number
function CommonMethods.Normalize(val, min, max)
if (max - min) == 0 then return 1 end
return (val - min)/(max-min)
end
function CommonMethods.GetLimbNameFromBodyPart(bodyPart)
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
return StaticData.LIMBS_IND_STR[bodyPartTypeStr]
end
---Returns the side for a certain limb or prosthesis
---@param name string
---@return string "L" or "R"
function CommonMethods.GetSide(name)
if string.find(name, "_L") then return "L" else return "R" end
end
---Returns full name for the side, to be used with BodyLocations
---@param side string
---@return string?
function CommonMethods.GetSideFull(side)
if side == 'R' then
return "Right"
elseif side == 'L' then
return 'Left'
end
return nil
end
---Stops and start an event, making sure that we don't stack them up
---@param event string
---@param method function
function CommonMethods.SafeStartEvent(event, method)
Events[event].Remove(method)
Events[event].Add(method)
end
return CommonMethods