Added toggle of cicatrization update at startup
This commit is contained in:
@@ -32,12 +32,12 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
|
|||||||
CachedDataHandler.CalculateAmputatedLimbs(username)
|
CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
||||||
|
|
||||||
--Setup the CicatrizationUpdate event
|
--Setup the CicatrizationUpdate event and triggers it once
|
||||||
Events.OnAmputatedLimb.Add(PlayerHandler.ToggleCicatrizationUpdate)
|
Events.OnAmputatedLimb.Add(PlayerHandler.ToggleCicatrizationUpdate)
|
||||||
|
PlayerHandler.ToggleCicatrizationUpdate()
|
||||||
|
|
||||||
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
||||||
if isForced then
|
if isForced then
|
||||||
--ISHealthPanel.highestAmputations = {}
|
|
||||||
local ItemsHandler = require("TOC/Handlers/ItemsHandler")
|
local ItemsHandler = require("TOC/Handlers/ItemsHandler")
|
||||||
ItemsHandler.Player.DeleteAllOldAmputationItems(playerObj)
|
ItemsHandler.Player.DeleteAllOldAmputationItems(playerObj)
|
||||||
CachedDataHandler.Reset(username)
|
CachedDataHandler.Reset(username)
|
||||||
|
|||||||
@@ -73,8 +73,10 @@ end
|
|||||||
---Get a value between 1 and 0.1 for the cicatrization time
|
---Get a value between 1 and 0.1 for the cicatrization time
|
||||||
---@param cicTime integer
|
---@param cicTime integer
|
||||||
---@return integer
|
---@return integer
|
||||||
local function GetColorFromCicatrizationTime(cicTime)
|
local function GetColorFromCicatrizationTime(cicTime, limbName)
|
||||||
return math.max(math.min(cicTime/100, 1), 0.1)
|
local defaultTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName]
|
||||||
|
local delta = cicTime/defaultTime
|
||||||
|
return math.max(0.15, math.min(delta, 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
---Try to draw the highest amputation in the health panel, based on the cicatrization time
|
---Try to draw the highest amputation in the health panel, based on the cicatrization time
|
||||||
@@ -89,10 +91,11 @@ function ISHealthPanel:tryDrawHighestAmputation(side, username)
|
|||||||
texture = getTexture("media/ui/test_pattern.png")
|
texture = getTexture("media/ui/test_pattern.png")
|
||||||
else
|
else
|
||||||
if self.highestAmputations[side] == nil then return end
|
if self.highestAmputations[side] == nil then return end
|
||||||
|
local limbName = self.highestAmputations[side]
|
||||||
|
|
||||||
local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(self.highestAmputations[side])
|
local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(limbName)
|
||||||
redColor = GetColorFromCicatrizationTime(cicTime)
|
redColor = GetColorFromCicatrizationTime(cicTime, limbName)
|
||||||
texture = StaticData.HEALTH_PANEL_TEXTURES[self.sexPl][self.highestAmputations[side]]
|
texture = StaticData.HEALTH_PANEL_TEXTURES[self.sexPl][limbName]
|
||||||
end
|
end
|
||||||
|
|
||||||
self:drawTexture(texture, self.healthPanel.x, self.healthPanel.y, 1, redColor, 0, 0)
|
self:drawTexture(texture, self.healthPanel.x, self.healthPanel.y, 1, redColor, 0, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user