From 2cf794552f0d63284c2fff5b2c8b1273710311cc Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sat, 11 Nov 2023 03:04:48 +0100 Subject: [PATCH] Cleaning --- .../lua/client/Handlers/TOC_ItemsHandler.lua | 10 +------- .../client/Handlers/TOC_ModDataHandler.lua | 14 ----------- .../lua/client/Handlers/TOC_PlayerHandler.lua | 25 +++---------------- media/lua/client/TOC_StaticData.lua | 3 --- .../lua/client/UI/TOC_CutLimbInteractions.lua | 15 +++++++++-- media/lua/client/UI/TOC_HealthPanel.lua | 2 -- .../client/UI/TOC_HealthPanelBaseHandler.lua | 2 +- 7 files changed, 19 insertions(+), 52 deletions(-) diff --git a/media/lua/client/Handlers/TOC_ItemsHandler.lua b/media/lua/client/Handlers/TOC_ItemsHandler.lua index 217acda..c94cd3a 100644 --- a/media/lua/client/Handlers/TOC_ItemsHandler.lua +++ b/media/lua/client/Handlers/TOC_ItemsHandler.lua @@ -101,25 +101,17 @@ end local og_ISInventoryPane_refreshContainer = ISInventoryPane.refreshContainer ----Get the list of items for the container and remove the amputations +---Get the list of items for the container and remove the reference to the amputation items function ISInventoryPane:refreshContainer() - - -- Search into the container and remove the reference to the amputation item - og_ISInventoryPane_refreshContainer(self) - if TOC_DEBUG.disablePaneMod then return end - for i=1, #self.itemslist do local cItem = self.itemslist[i] if cItem and cItem.cat == "Amputation" then --print("TOC: current item is an amputation, removing it from the list") table.remove(self.itemslist, i) end - - end - end return ItemsHandler \ No newline at end of file diff --git a/media/lua/client/Handlers/TOC_ModDataHandler.lua b/media/lua/client/Handlers/TOC_ModDataHandler.lua index 8243bc5..09f428f 100644 --- a/media/lua/client/Handlers/TOC_ModDataHandler.lua +++ b/media/lua/client/Handlers/TOC_ModDataHandler.lua @@ -34,7 +34,6 @@ function ModDataHandler:setup(force) self:createData() end -- TODO Check compatibility or do we just skip it at this point? - end function ModDataHandler:createData() @@ -61,10 +60,8 @@ function ModDataHandler:createData() modData[StaticData.MOD_NAME][limbName] = {} self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0) end - end - ----------------- --* Setters *-- @@ -74,7 +71,6 @@ function ModDataHandler:setIsAnyLimbCut(isAnyLimbCut) self.tocData.isAnyLimbCut = true end - ---Set isCut ---@param limbName string ---@param isCut boolean @@ -104,7 +100,6 @@ function ModDataHandler:getIsAnyLimbCut() return self.tocData.isAnyLimbCut end - ---Get isCut ---@param limbName string ---@return boolean @@ -124,8 +119,6 @@ function ModDataHandler:getIsVisible(limbName) return self.tocData[limbName].isVisible end - - --* Limbs data handling *-- ---Set a limb and its dependend limbs as cut @@ -155,10 +148,8 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri -- Set that a limb has been cut, to activate some functions without having to loop through the parts self:setIsAnyLimbCut(true) - end - ---Internal use only, set a limb data ---@param limbName string ---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isVisible} @@ -176,8 +167,6 @@ function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime) if cicatrizationTime ~= nil then limbData.cicatrizationTime = cicatrizationTime end end - - ---@return ModDataHandler function ModDataHandler.GetInstance() if ModDataHandler.instance ~= nil then @@ -187,7 +176,4 @@ function ModDataHandler.GetInstance() end end - - - return ModDataHandler \ No newline at end of file diff --git a/media/lua/client/Handlers/TOC_PlayerHandler.lua b/media/lua/client/Handlers/TOC_PlayerHandler.lua index 9bf61e1..f8f321f 100644 --- a/media/lua/client/Handlers/TOC_PlayerHandler.lua +++ b/media/lua/client/Handlers/TOC_PlayerHandler.lua @@ -66,6 +66,9 @@ function PlayerHandler.AddLocalAmputatedLimb(limbName) end --* Getters *-- + +---Get a table with the strings of the amputated limbs +---@return table function PlayerHandler.GetAmputatedLimbs() return PlayerHandler.amputatedLimbs or {} end @@ -75,7 +78,6 @@ end ---Check if the player has an infected (as in, zombie infection) body part ---@param character IsoGameCharacter function PlayerHandler.CheckInfection(character) - -- This fucking event barely works. Bleeding seems to be the only thing that triggers it if character ~= getPlayer() then return end local bd = character:getBodyDamage() @@ -104,30 +106,12 @@ function PlayerHandler.CheckInfection(character) PlayerHandler.modDataHandler:setIsIgnoredPartInfected(true) end end - end Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection) ----Handle perks ----@param player IsoPlayer -function PlayerHandler.UpdatePerks(player) - -- TODO If player has an amputated limb, they're gonna level up them while doing normal stuff, getting better at it dynamically - -- TODO We should have a way to check if the player has done any amputation at all instead of having to check manually each time - -- TODO Should be run when player is doing stuff like picking up objects, not randomly - for side, _ in pairs(StaticData.SIDES_STRINGS) do - local limbName = "Hand_" .. side - if ModDataHandler.GetInstance():getIsCut(limbName) then - player:getXp():AddXP(Perks["Side_" .. side], 0.1) - end - end -end - ---Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks) - - ---* Some overrides *-- +--* Overrides *-- local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime --- Adjust time @@ -167,5 +151,4 @@ function ISBaseTimedAction:perform() end - return PlayerHandler \ No newline at end of file diff --git a/media/lua/client/TOC_StaticData.lua b/media/lua/client/TOC_StaticData.lua index ad5dc75..10dc10c 100644 --- a/media/lua/client/TOC_StaticData.lua +++ b/media/lua/client/TOC_StaticData.lua @@ -76,9 +76,6 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do end end - - - ----------------- -- Visuals and clothing diff --git a/media/lua/client/UI/TOC_CutLimbInteractions.lua b/media/lua/client/UI/TOC_CutLimbInteractions.lua index 0d25114..f24b327 100644 --- a/media/lua/client/UI/TOC_CutLimbInteractions.lua +++ b/media/lua/client/UI/TOC_CutLimbInteractions.lua @@ -6,16 +6,23 @@ local ModDataHandler = require("Handlers/TOC_ModDataHandler") --------------------- ----comment +---Check if the item name corresponds to a compatible saw ---@param itemName string local function CheckIfSaw(itemName) return itemName == "Saw" or itemName == "GardenSaw" or itemName == "Chainsaw" end +---Add the action to the queue +---@param limbName string +---@param surgeon IsoPlayer +---@param patient IsoPlayer local function PerformAction(limbName, surgeon, patient) ISTimedActionQueue.add(CutLimbAction:new(surgeon, patient, limbName)) end +---Adds the actions to the inventory context menu +---@param surgeonNum number +---@param context ISUIElement local function AddInventoryAmputationOptions(surgeonNum, context) local surgeonObj = getSpecificPlayer(surgeonNum) local option = context:addOption(getText("ContextMenu_Amputate"), nil) @@ -30,8 +37,12 @@ local function AddInventoryAmputationOptions(surgeonNum, context) end end +---Handler for OnFillInventoryObjectContextMenu +---@param player number +---@param context ISUIElement +---@param items table local function AddInventoryAmputationMenu(player, context, items) - local item = items[1] + local item = items[1] -- Selected item if CheckIfSaw(item.name) then AddInventoryAmputationOptions(player, context) end diff --git a/media/lua/client/UI/TOC_HealthPanel.lua b/media/lua/client/UI/TOC_HealthPanel.lua index 6f1b697..b2042a1 100644 --- a/media/lua/client/UI/TOC_HealthPanel.lua +++ b/media/lua/client/UI/TOC_HealthPanel.lua @@ -37,9 +37,7 @@ end --* Modification to handle visible amputation on the health menu *-- - function ISHealthPanel.GetHighestAmputation() - -- TODO Cache this instead of doing it here! ISHealthPanel.highestAmputations = {} for i=1, #PlayerHandler.amputatedLimbs do local limbName = PlayerHandler.amputatedLimbs[i] diff --git a/media/lua/client/UI/TOC_HealthPanelBaseHandler.lua b/media/lua/client/UI/TOC_HealthPanelBaseHandler.lua index 9849c6e..d5a4c04 100644 --- a/media/lua/client/UI/TOC_HealthPanelBaseHandler.lua +++ b/media/lua/client/UI/TOC_HealthPanelBaseHandler.lua @@ -1,4 +1,4 @@ --- Had to cop and paste this stuff from the base game since this is a local only class. Kinda shit, but eh +-- Had to copy and paste this stuff from the base game since this is a local only class. Kinda shit, but eh ---@class BaseHandler : ISBaseObject ---@field panel ISUIElement