Cleaning
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -76,9 +76,6 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------
|
||||
-- Visuals and clothing
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user