Fixed some last stuff in the PlayerHandler and Healthpanel
This commit is contained in:
@@ -38,7 +38,7 @@ end
|
|||||||
---@param username string
|
---@param username string
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
function CachedDataHandler.AddAmputatedLimb(username, limbName)
|
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
|
-- Add it to the generic list
|
||||||
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
|
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
|
||||||
@@ -64,16 +64,17 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if CachedDataHandler.amputatedLimbs == nil or CachedDataHandler.amputatedLimbs[username] == nil then
|
-- if CachedDataHandler.amputatedLimbs == nil or CachedDataHandler.amputatedLimbs[username] == nil then
|
||||||
--- This function gets ran pretty early, we need to account for the Bob stuff
|
-- --- This function gets ran pretty early, we need to account for the Bob stuff
|
||||||
-- if username == "Bob" then
|
-- -- if username == "Bob" then
|
||||||
-- TOC_DEBUG.print("skip, Bob is default char")
|
-- -- TOC_DEBUG.print("skip, Bob is default char")
|
||||||
-- return
|
-- -- return
|
||||||
-- end
|
-- -- 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)
|
-- CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
end
|
-- end
|
||||||
|
CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
|
|
||||||
local amputatedLimbs = CachedDataHandler.amputatedLimbs[username]
|
local amputatedLimbs = CachedDataHandler.amputatedLimbs[username]
|
||||||
CachedDataHandler.highestAmputatedLimbs[username] = {}
|
CachedDataHandler.highestAmputatedLimbs[username] = {}
|
||||||
@@ -83,7 +84,7 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
|||||||
local limbName = k
|
local limbName = k
|
||||||
local index = CommonMethods.GetSide(limbName)
|
local index = CommonMethods.GetSide(limbName)
|
||||||
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then
|
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
|
CachedDataHandler.highestAmputatedLimbs[username][index] = limbName
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
|
|||||||
CachedDataHandler.Reset(username)
|
CachedDataHandler.Reset(username)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Overrides various functions on the Health Panel ONLY after we're done initializing the player
|
-- Set a bool to use an overriding GetDamagedParts
|
||||||
OverrideHealthPanelForTOC()
|
SetHealthPanelTOC()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,13 @@ local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
|||||||
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
|
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
|
||||||
local WoundCleaningHandler = require("TOC/UI/WoundCleaningInteraction")
|
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.
|
-- 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
|
-- 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
|
else
|
||||||
if highestAmputations[side] == nil then return end
|
if highestAmputations[side] == nil then return end
|
||||||
local limbName = highestAmputations[side]
|
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)
|
local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(limbName)
|
||||||
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
|
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
|
||||||
@@ -176,7 +181,7 @@ function OverrideHealthPanelForTOC()
|
|||||||
local og_ISMedicalCheckAction_perform = ISMedicalCheckAction.perform
|
local og_ISMedicalCheckAction_perform = ISMedicalCheckAction.perform
|
||||||
function ISMedicalCheckAction:perform()
|
function ISMedicalCheckAction:perform()
|
||||||
local username = self.otherPlayer:getUsername()
|
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
|
-- We need to recalculate them here before we can create the highest amputations point
|
||||||
CachedDataHandler.CalculateAmputatedLimbs(username)
|
CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
@@ -233,24 +238,30 @@ function OverrideHealthPanelForTOC()
|
|||||||
function ISHealthPanel:getDamagedParts()
|
function ISHealthPanel:getDamagedParts()
|
||||||
-- TODO Overriding it is a lot easier, but ew
|
-- TODO Overriding it is a lot easier, but ew
|
||||||
|
|
||||||
local result = {}
|
if isReady then
|
||||||
local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
|
|
||||||
if isClient() and not self:getPatient():isLocalPlayer() then
|
|
||||||
bodyParts = self:getPatient():getBodyDamageRemote():getBodyParts()
|
|
||||||
end
|
|
||||||
|
|
||||||
local patientUsername = self:getPatient():getUsername()
|
local result = {}
|
||||||
local mdh = ModDataHandler.GetInstance(patientUsername)
|
local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
|
||||||
for i=1,bodyParts:size() do
|
if isClient() and not self:getPatient():isLocalPlayer() then
|
||||||
local bodyPart = bodyParts:get(i-1)
|
bodyParts = self:getPatient():getBodyDamageRemote():getBodyParts()
|
||||||
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
|
|
||||||
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
|
|
||||||
|
|
||||||
if ISHealthPanel.cheat or bodyPart:HasInjury() or bodyPart:bandaged() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0 or bodyPart:getAdditionalPain() > 10 or bodyPart:getStiffness() > 5 or (mdh:getIsCut(limbName) and mdh:getIsVisible(limbName)) then
|
|
||||||
table.insert(result, bodyPart)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local patientUsername = self:getPatient():getUsername()
|
||||||
|
local mdh = ModDataHandler.GetInstance(patientUsername)
|
||||||
|
for i=1,bodyParts:size() do
|
||||||
|
local bodyPart = bodyParts:get(i-1)
|
||||||
|
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
|
||||||
|
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
|
||||||
|
|
||||||
|
if ISHealthPanel.cheat or bodyPart:HasInjury() or bodyPart:bandaged() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0 or bodyPart:getAdditionalPain() > 10 or bodyPart:getStiffness() > 5 or (mdh:getIsCut(limbName) and mdh:getIsVisible(limbName)) then
|
||||||
|
table.insert(result, bodyPart)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
|
||||||
|
else
|
||||||
|
return og_ISHealthPanel_getDamagedParts(self)
|
||||||
end
|
end
|
||||||
return result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
--end
|
||||||
Reference in New Issue
Block a user