Fixed some last stuff in the PlayerHandler and Healthpanel

This commit is contained in:
ZioPao
2024-01-07 22:44:58 +01:00
parent 2cbf5aea8b
commit 6b1205e160
3 changed files with 44 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ end
---@param username string
---@param limbName string
function CachedDataHandler.AddAmputatedLimb(username, limbName)
TOC_DEBUG.print("added " .. limbName .. " to known amputated limbs for " .. username)
TOC_DEBUG.print("[CachedDataHandler] Added " .. limbName .. " to known amputated limbs for " .. username)
-- Add it to the generic list
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
@@ -64,16 +64,17 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
return
end
if CachedDataHandler.amputatedLimbs == nil or CachedDataHandler.amputatedLimbs[username] == nil then
--- This function gets ran pretty early, we need to account for the Bob stuff
-- if username == "Bob" then
-- TOC_DEBUG.print("skip, Bob is default char")
-- return
-- end
-- if CachedDataHandler.amputatedLimbs == nil or CachedDataHandler.amputatedLimbs[username] == nil then
-- --- This function gets ran pretty early, we need to account for the Bob stuff
-- -- if username == "Bob" then
-- -- TOC_DEBUG.print("skip, Bob is default char")
-- -- return
-- -- end
TOC_DEBUG.print("Amputated limbs weren't calculated. Trying to calculate them now for " .. username)
-- TOC_DEBUG.print("Amputated limbs weren't calculated. Trying to calculate them now for " .. username)
-- CachedDataHandler.CalculateAmputatedLimbs(username)
-- end
CachedDataHandler.CalculateAmputatedLimbs(username)
end
local amputatedLimbs = CachedDataHandler.amputatedLimbs[username]
CachedDataHandler.highestAmputatedLimbs[username] = {}
@@ -83,7 +84,7 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
local limbName = k
local index = CommonMethods.GetSide(limbName)
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then
TOC_DEBUG.print("found high amputation " .. limbName)
TOC_DEBUG.print("[CachedDataHandler] Added Highest Amputation: " .. limbName)
CachedDataHandler.highestAmputatedLimbs[username][index] = limbName
end
end

View File

@@ -44,8 +44,8 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
CachedDataHandler.Reset(username)
end
-- Overrides various functions on the Health Panel ONLY after we're done initializing the player
OverrideHealthPanelForTOC()
-- Set a bool to use an overriding GetDamagedParts
SetHealthPanelTOC()
end

View File

@@ -4,8 +4,13 @@ local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
local WoundCleaningHandler = require("TOC/UI/WoundCleaningInteraction")
local isReady = false
function OverrideHealthPanelForTOC()
function SetHealthPanelTOC()
isReady = true
end
--function OverrideHealthPanelForTOC()
-- We're overriding ISHealthPanel to add custom textures to the body panel.
-- By doing so we can show the player which limbs have been cut without having to use another menu
@@ -98,7 +103,7 @@ function OverrideHealthPanelForTOC()
else
if highestAmputations[side] == nil then return end
local limbName = highestAmputations[side]
--TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username)
TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username)
local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(limbName)
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
@@ -176,7 +181,7 @@ function OverrideHealthPanelForTOC()
local og_ISMedicalCheckAction_perform = ISMedicalCheckAction.perform
function ISMedicalCheckAction:perform()
local username = self.otherPlayer:getUsername()
TOC_DEBUG.print("Medical Action on " .. username )
TOC_DEBUG.print("[HealthPanel] Medical Action on " .. username )
-- We need to recalculate them here before we can create the highest amputations point
CachedDataHandler.CalculateAmputatedLimbs(username)
@@ -233,6 +238,8 @@ function OverrideHealthPanelForTOC()
function ISHealthPanel:getDamagedParts()
-- TODO Overriding it is a lot easier, but ew
if isReady then
local result = {}
local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
if isClient() and not self:getPatient():isLocalPlayer() then
@@ -251,6 +258,10 @@ function OverrideHealthPanelForTOC()
end
end
return result
else
return og_ISHealthPanel_getDamagedParts(self)
end
end
end
--end