Rethinking structure a bit

This commit is contained in:
ZioPao
2024-01-08 10:57:01 +01:00
parent 6b1205e160
commit 312294edb8
19 changed files with 229 additions and 222 deletions

View File

@@ -2,21 +2,24 @@ local CommandsData = require("TOC/CommandsData")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
---------------- ----------------
--- Handle all mod data related stuff --- An instance will be abbreviated with dcInst
---@class ModDataHandler
--- Handle all TOC mod data related stuff
---@class DataController
---@field username string ---@field username string
---@field tocData tocModData ---@field tocData tocModDataType
---@field isDataReady boolean ---@field isDataReady boolean
---@field isResetForced boolean ---@field isResetForced boolean
local ModDataHandler = {} local DataController = {}
ModDataHandler.instances = {} DataController.instances = {}
---Setup a new Mod Data Handler ---Setup a new Mod Data Handler
---@param username string ---@param username string
---@param isResetForced boolean? ---@param isResetForced boolean?
---@return ModDataHandler ---@return DataController
function ModDataHandler:new(username, isResetForced) function DataController:new(username, isResetForced)
TOC_DEBUG.print("[ModDataHandler] NEW for " .. username) TOC_DEBUG.print("[DataController] NEW for " .. username)
--error("TEST TRIGGER") --error("TEST TRIGGER")
local o = {} local o = {}
setmetatable(o, self) setmetatable(o, self)
@@ -36,17 +39,17 @@ function ModDataHandler:new(username, isResetForced)
o.isDataReady = true o.isDataReady = true
end end
ModDataHandler.instances[username] = o DataController.instances[username] = o
return o return o
end end
---Setup a new toc mod data data class ---Setup a new toc mod data data class
---@param key string ---@param key string
function ModDataHandler:setup(key) function DataController:setup(key)
TOC_DEBUG.print("[ModDataHandler] Running setup") TOC_DEBUG.print("[DataController] Running setup")
---@type tocModData ---@type tocModDataType
self.tocData = { self.tocData = {
-- Generic stuff that does not belong anywhere else -- Generic stuff that does not belong anywhere else
isIgnoredPartInfected = false, isIgnoredPartInfected = false,
@@ -84,8 +87,8 @@ function ModDataHandler:setup(key)
end end
---In case of desync between the table on ModData and the table here ---In case of desync between the table on ModData and the table here
---@param tocData tocModData ---@param tocData tocModDataType
function ModDataHandler:reapplyTocData(tocData) function DataController:reapplyTocData(tocData)
local key = CommandsData.GetKey(self.username) local key = CommandsData.GetKey(self.username)
ModData.add(key, tocData) ModData.add(key, tocData)
self.tocData = ModData.get(key) self.tocData = ModData.get(key)
@@ -94,54 +97,54 @@ end
----------------- -----------------
--* Setters *-- --* Setters *--
function ModDataHandler:setIsDataReady(isDataReady) function DataController:setIsDataReady(isDataReady)
self.isDataReady = isDataReady self.isDataReady = isDataReady
end end
---Set a generic boolean that toggles varies function of the mod ---Set a generic boolean that toggles varies function of the mod
---@param isAnyLimbCut boolean ---@param isAnyLimbCut boolean
function ModDataHandler:setIsAnyLimbCut(isAnyLimbCut) function DataController:setIsAnyLimbCut(isAnyLimbCut)
self.tocData.isAnyLimbCut = isAnyLimbCut self.tocData.isAnyLimbCut = isAnyLimbCut
end end
---Set isIgnoredPartInfected ---Set isIgnoredPartInfected
---@param isIgnoredPartInfected boolean ---@param isIgnoredPartInfected boolean
function ModDataHandler:setIsIgnoredPartInfected(isIgnoredPartInfected) function DataController:setIsIgnoredPartInfected(isIgnoredPartInfected)
self.tocData.isIgnoredPartInfected = isIgnoredPartInfected self.tocData.isIgnoredPartInfected = isIgnoredPartInfected
end end
---Set isCut ---Set isCut
---@param limbName string ---@param limbName string
---@param isCut boolean ---@param isCut boolean
function ModDataHandler:setIsCut(limbName, isCut) function DataController:setIsCut(limbName, isCut)
self.tocData.limbs[limbName].isCut = isCut self.tocData.limbs[limbName].isCut = isCut
end end
---Set isInfected ---Set isInfected
---@param limbName string ---@param limbName string
---@param isInfected boolean ---@param isInfected boolean
function ModDataHandler:setIsInfected(limbName, isInfected) function DataController:setIsInfected(limbName, isInfected)
self.tocData.limbs[limbName].isInfected = isInfected self.tocData.limbs[limbName].isInfected = isInfected
end end
---Set isCicatrized ---Set isCicatrized
---@param limbName string ---@param limbName string
---@param isCicatrized boolean ---@param isCicatrized boolean
function ModDataHandler:setIsCicatrized(limbName, isCicatrized) function DataController:setIsCicatrized(limbName, isCicatrized)
self.tocData.limbs[limbName].isCicatrized = isCicatrized self.tocData.limbs[limbName].isCicatrized = isCicatrized
end end
---Set isCauterized ---Set isCauterized
---@param limbName string ---@param limbName string
---@param isCauterized boolean ---@param isCauterized boolean
function ModDataHandler:setIsCauterized(limbName, isCauterized) function DataController:setIsCauterized(limbName, isCauterized)
self.tocData.limbs[limbName].isCauterized = isCauterized self.tocData.limbs[limbName].isCauterized = isCauterized
end end
---Set woundDirtyness ---Set woundDirtyness
---@param limbName string ---@param limbName string
---@param woundDirtyness number ---@param woundDirtyness number
function ModDataHandler:setWoundDirtyness(limbName, woundDirtyness) function DataController:setWoundDirtyness(limbName, woundDirtyness)
self.tocData.limbs[limbName].woundDirtyness = woundDirtyness self.tocData.limbs[limbName].woundDirtyness = woundDirtyness
end end
@@ -149,21 +152,21 @@ end
---Set cicatrizationTime ---Set cicatrizationTime
---@param limbName string ---@param limbName string
---@param cicatrizationTime number ---@param cicatrizationTime number
function ModDataHandler:setCicatrizationTime(limbName, cicatrizationTime) function DataController:setCicatrizationTime(limbName, cicatrizationTime)
self.tocData.limbs[limbName].cicatrizationTime = cicatrizationTime self.tocData.limbs[limbName].cicatrizationTime = cicatrizationTime
end end
---Set isProstEquipped ---Set isProstEquipped
---@param group string ---@param group string
---@param isProstEquipped boolean ---@param isProstEquipped boolean
function ModDataHandler:setIsProstEquipped(group, isProstEquipped) function DataController:setIsProstEquipped(group, isProstEquipped)
self.tocData.prostheses[group].isProstEquipped = isProstEquipped self.tocData.prostheses[group].isProstEquipped = isProstEquipped
end end
---Set prostFactor ---Set prostFactor
---@param group string ---@param group string
---@param prostFactor number ---@param prostFactor number
function ModDataHandler:setProstFactor(group, prostFactor) function DataController:setProstFactor(group, prostFactor)
self.tocData.prostheses[group].prostFactor = prostFactor self.tocData.prostheses[group].prostFactor = prostFactor
end end
@@ -172,26 +175,26 @@ end
---comment ---comment
---@return boolean ---@return boolean
function ModDataHandler:getIsDataReady() function DataController:getIsDataReady()
return self.isDataReady return self.isDataReady
end end
---Set a generic boolean that toggles varies function of the mod ---Set a generic boolean that toggles varies function of the mod
---@return boolean ---@return boolean
function ModDataHandler:getIsAnyLimbCut() function DataController:getIsAnyLimbCut()
--if self.isDataReady == false then return false end --if self.isDataReady == false then return false end
return self.tocData.isAnyLimbCut return self.tocData.isAnyLimbCut
end end
---Get isIgnoredPartInfected ---Get isIgnoredPartInfected
---@return boolean ---@return boolean
function ModDataHandler:getIsIgnoredPartInfected() function DataController:getIsIgnoredPartInfected()
return self.tocData.isIgnoredPartInfected return self.tocData.isIgnoredPartInfected
end end
---Get isCut ---Get isCut
---@param limbName string ---@param limbName string
---@return boolean ---@return boolean
function ModDataHandler:getIsCut(limbName) function DataController:getIsCut(limbName)
if not self.isDataReady then return false end if not self.isDataReady then return false end
if self.tocData.limbs[limbName] then if self.tocData.limbs[limbName] then
@@ -204,7 +207,7 @@ end
---Get isVisible ---Get isVisible
---@param limbName string ---@param limbName string
---@return boolean ---@return boolean
function ModDataHandler:getIsVisible(limbName) function DataController:getIsVisible(limbName)
if not self.isDataReady then return false end if not self.isDataReady then return false end
return self.tocData.limbs[limbName].isVisible return self.tocData.limbs[limbName].isVisible
@@ -213,21 +216,21 @@ end
---Get isCicatrized ---Get isCicatrized
---@param limbName string ---@param limbName string
---@return boolean ---@return boolean
function ModDataHandler:getIsCicatrized(limbName) function DataController:getIsCicatrized(limbName)
return self.tocData.limbs[limbName].isCicatrized return self.tocData.limbs[limbName].isCicatrized
end end
---Get isCauterized ---Get isCauterized
---@param limbName string ---@param limbName string
---@return boolean ---@return boolean
function ModDataHandler:getIsCauterized(limbName) function DataController:getIsCauterized(limbName)
return self.tocData.limbs[limbName].isCauterized return self.tocData.limbs[limbName].isCauterized
end end
---Get woundDirtyness ---Get woundDirtyness
---@param limbName string ---@param limbName string
---@return number ---@return number
function ModDataHandler:getWoundDirtyness(limbName) function DataController:getWoundDirtyness(limbName)
return self.tocData.limbs[limbName].woundDirtyness return self.tocData.limbs[limbName].woundDirtyness
end end
@@ -235,21 +238,21 @@ end
---Get cicatrizationTime ---Get cicatrizationTime
---@param limbName string ---@param limbName string
---@return number ---@return number
function ModDataHandler:getCicatrizationTime(limbName) function DataController:getCicatrizationTime(limbName)
return self.tocData.limbs[limbName].cicatrizationTime return self.tocData.limbs[limbName].cicatrizationTime
end end
---Get isProstEquipped ---Get isProstEquipped
---@param group string ---@param group string
---@return boolean ---@return boolean
function ModDataHandler:getIsProstEquipped(group) function DataController:getIsProstEquipped(group)
return self.tocData.prostheses[group].isProstEquipped return self.tocData.prostheses[group].isProstEquipped
end end
---Get prostFactor ---Get prostFactor
---@param group string ---@param group string
---@return number ---@return number
function ModDataHandler:getProstFactor(group) function DataController:getProstFactor(group)
return self.tocData.prostheses[group].prostFactor return self.tocData.prostheses[group].prostFactor
end end
@@ -261,7 +264,7 @@ end
---@param isCicatrized boolean ---@param isCicatrized boolean
---@param isCauterized boolean ---@param isCauterized boolean
---@param surgeonFactor number? ---@param surgeonFactor number?
function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauterized, surgeonFactor) function DataController:setCutLimb(limbName, isOperated, isCicatrized, isCauterized, surgeonFactor)
local cicatrizationTime = 0 local cicatrizationTime = 0
if isCicatrized == false or isCauterized == false then if isCicatrized == false or isCauterized == false then
cicatrizationTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName] - surgeonFactor cicatrizationTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName] - surgeonFactor
@@ -292,7 +295,7 @@ end
---@param limbName string ---@param limbName string
---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isVisible} ---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isVisible}
---@param cicatrizationTime integer? ---@param cicatrizationTime integer?
function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime) function DataController:setLimbParams(limbName, ampStatus, cicatrizationTime)
local limbData = self.tocData.limbs[limbName] local limbData = self.tocData.limbs[limbName]
if ampStatus.isCut ~= nil then limbData.isCut = ampStatus.isCut end if ampStatus.isCut ~= nil then limbData.isCut = ampStatus.isCut end
if ampStatus.isInfected ~= nil then limbData.isInfected = ampStatus.isInfected end if ampStatus.isInfected ~= nil then limbData.isInfected = ampStatus.isInfected end
@@ -309,44 +312,44 @@ end
---Decreases the cicatrization time ---Decreases the cicatrization time
---@param limbName string ---@param limbName string
function ModDataHandler:decreaseCicatrizationTime(limbName) function DataController:decreaseCicatrizationTime(limbName)
self.tocData.limbs[limbName].cicatrizationTime = self.tocData.limbs[limbName].cicatrizationTime - 1 self.tocData.limbs[limbName].cicatrizationTime = self.tocData.limbs[limbName].cicatrizationTime - 1
end end
--* Global Mod Data Handling *-- --* Global Mod Data Handling *--
function ModDataHandler:apply() function DataController:apply()
ModData.transmit(CommandsData.GetKey(self.username)) ModData.transmit(CommandsData.GetKey(self.username))
end end
function ModDataHandler.ReceiveData(key, data) function DataController.ReceiveData(key, data)
if not isClient() then if not isClient() then
TOC_DEBUG.print("SP, skipping ModDataHandler.ReceiveData") TOC_DEBUG.print("SP, skipping DataController.ReceiveData")
end end
-- During startup the game can return Bob as the player username, adding a useless ModData table -- During startup the game can return Bob as the player username, adding a useless ModData table
if key == "TOC_Bob" then return end if key == "TOC_Bob" then return end
TOC_DEBUG.print("[ModDataHandler] ReceiveData for " .. key) TOC_DEBUG.print("[DataController] ReceiveData for " .. key)
if data == {} or data == nil then if data == {} or data == nil then
TOC_DEBUG.print("table is nil... returning") TOC_DEBUG.print("table is nil... returning")
return return
end end
-- Get ModDataHandler instance if there was none for that user and reapply the correct ModData table as a reference -- Get DataController instance if there was none for that user and reapply the correct ModData table as a reference
local username = key:sub(5) local username = key:sub(5)
local handler = ModDataHandler.GetInstance(username) local handler = DataController.GetInstance(username)
if handler.isResetForced or data == nil or data == {} or data == false then if handler.isResetForced or data == nil or data == {} or data == false then
TOC_DEBUG.print("[ModDataHandler] Setup") TOC_DEBUG.print("[DataController] Setup")
handler:setup(key) handler:setup(key)
handler.isResetForced = false handler.isResetForced = false
else else
TOC_DEBUG.print("[ModDataHandler] Reapply") TOC_DEBUG.print("[DataController] Reapply")
handler:reapplyTocData(data) handler:reapplyTocData(data)
end end
-- if handler.isResetForced or handler.tocData == nil or handler.tocData.limbs == nil or handler.tocData.limbs.Hand_L == nil or handler.tocData.limbs.Hand_L.isCut == nil then -- if handler.isResetForced or handler.tocData == nil or handler.tocData.limbs == nil or handler.tocData.limbs.Hand_L == nil or handler.tocData.limbs.Hand_L.isCut == nil then
-- TOC_DEBUG.print("tocData in ModDataHandler for " .. handler.username .. " is nil, creating it now") -- TOC_DEBUG.print("tocData in DataController for " .. handler.username .. " is nil, creating it now")
-- handler:setup(key) -- handler:setup(key)
-- handler.isResetForced = false -- handler.isResetForced = false
-- elseif table then -- elseif table then
@@ -361,27 +364,27 @@ function ModDataHandler.ReceiveData(key, data)
-- Transmit it to the server -- Transmit it to the server
ModData.transmit(key) ModData.transmit(key)
TOC_DEBUG.print("[ModDataHandler] Transmitting data after receiving it for: " .. handler.username) TOC_DEBUG.print("[DataController] Transmitting data after receiving it for: " .. handler.username)
end end
Events.OnReceiveGlobalModData.Add(ModDataHandler.ReceiveData) Events.OnReceiveGlobalModData.Add(DataController.ReceiveData)
------------------- -------------------
---@param username string? ---@param username string?
---@return ModDataHandler ---@return DataController
function ModDataHandler.GetInstance(username) function DataController.GetInstance(username)
if username == nil or username == "Bob" then if username == nil or username == "Bob" then
username = getPlayer():getUsername() username = getPlayer():getUsername()
end end
if ModDataHandler.instances[username] == nil then if DataController.instances[username] == nil then
TOC_DEBUG.print("[ModDataHandler] Creating NEW instance for " .. username) TOC_DEBUG.print("[DataController] Creating NEW instance for " .. username)
return ModDataHandler:new(username) return DataController:new(username)
else else
return ModDataHandler.instances[username] return DataController.instances[username]
end end
end end
return ModDataHandler return DataController

View File

@@ -3,21 +3,21 @@ local CommonMethods = require("TOC/CommonMethods")
--------------------------- ---------------------------
--- Submodule to handle spawning the correct items after certain actions (ie: cutting a hand). LOCAL ONLY! --- Submodule to handle spawning the correct items after certain actions (ie: cutting a hand). LOCAL ONLY!
---@class ItemsHandler ---@class ItemsController
local ItemsHandler = {} local ItemsController = {}
--* Player Methods *-- --* Player Methods *--
---@class ItemsHandler.Player ---@class ItemsController.Player
ItemsHandler.Player = {} ItemsController.Player = {}
---Returns the correct index for the textures of the amputation ---Returns the correct index for the textures of the amputation
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
---@param isCicatrized boolean ---@param isCicatrized boolean
---@return number ---@return number
---@private ---@private
function ItemsHandler.Player.GetAmputationTexturesIndex(playerObj, isCicatrized) function ItemsController.Player.GetAmputationTexturesIndex(playerObj, isCicatrized)
local textureString = playerObj:getHumanVisual():getSkinTexture() local textureString = playerObj:getHumanVisual():getSkinTexture()
local isHairy = textureString:sub(-1) == "a" local isHairy = textureString:sub(-1) == "a"
@@ -39,7 +39,7 @@ end
---@param clothingItem InventoryItem? ---@param clothingItem InventoryItem?
---@return boolean ---@return boolean
---@private ---@private
function ItemsHandler.Player.RemoveClothingItem(playerObj, clothingItem) function ItemsController.Player.RemoveClothingItem(playerObj, clothingItem)
if clothingItem and instanceof(clothingItem, "InventoryItem") then if clothingItem and instanceof(clothingItem, "InventoryItem") then
playerObj:removeWornItem(clothingItem) playerObj:removeWornItem(clothingItem)
@@ -53,7 +53,7 @@ end
---Search and deletes an old amputation clothing item on the same side ---Search and deletes an old amputation clothing item on the same side
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
---@param limbName string ---@param limbName string
function ItemsHandler.Player.DeleteOldAmputationItem(playerObj, limbName) function ItemsController.Player.DeleteOldAmputationItem(playerObj, limbName)
local side = CommonMethods.GetSide(limbName) local side = CommonMethods.GetSide(limbName)
for partName, _ in pairs(StaticData.PARTS_IND_STR) do for partName, _ in pairs(StaticData.PARTS_IND_STR) do
local othLimbName = partName .. "_" .. side local othLimbName = partName .. "_" .. side
@@ -65,30 +65,30 @@ function ItemsHandler.Player.DeleteOldAmputationItem(playerObj, limbName)
-- If we manage to find and remove an item, then we should stop this function. -- If we manage to find and remove an item, then we should stop this function.
---@cast othClothingItem InventoryItem ---@cast othClothingItem InventoryItem
if ItemsHandler.Player.RemoveClothingItem(playerObj, othClothingItem) then return end if ItemsController.Player.RemoveClothingItem(playerObj, othClothingItem) then return end
end end
end end
---Deletes all the old amputation items, used for resets ---Deletes all the old amputation items, used for resets
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
function ItemsHandler.Player.DeleteAllOldAmputationItems(playerObj) function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
for i=1, #StaticData.LIMBS_STR do for i=1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName
local clothItem = playerObj:getInventory():FindAndReturn(clothItemName) local clothItem = playerObj:getInventory():FindAndReturn(clothItemName)
---@cast clothItem InventoryItem ---@cast clothItem InventoryItem
ItemsHandler.Player.RemoveClothingItem(playerObj, clothItem) ItemsController.Player.RemoveClothingItem(playerObj, clothItem)
end end
end end
---Spawns and equips the correct amputation item to the player. ---Spawns and equips the correct amputation item to the player.
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
---@param limbName string ---@param limbName string
function ItemsHandler.Player.SpawnAmputationItem(playerObj, limbName) function ItemsController.Player.SpawnAmputationItem(playerObj, limbName)
TOC_DEBUG.print("clothing name " .. StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) TOC_DEBUG.print("clothing name " .. StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName)
local clothingItem = playerObj:getInventory():AddItem(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) local clothingItem = playerObj:getInventory():AddItem(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName)
local texId = ItemsHandler.Player.GetAmputationTexturesIndex(playerObj, false) local texId = ItemsController.Player.GetAmputationTexturesIndex(playerObj, false)
---@cast clothingItem InventoryItem ---@cast clothingItem InventoryItem
clothingItem:getVisual():setTextureChoice(texId) -- it counts from 0, so we have to subtract 1 clothingItem:getVisual():setTextureChoice(texId) -- it counts from 0, so we have to subtract 1
@@ -98,12 +98,12 @@ end
--* Zombie Methods *-- --* Zombie Methods *--
---@class ItemsHandler.Zombie ---@class ItemsController.Zombie
ItemsHandler.Zombie = {} ItemsController.Zombie = {}
---Set an amputation to a zombie ---Set an amputation to a zombie
---@param zombie IsoZombie ---@param zombie IsoZombie
function ItemsHandler.Zombie.SpawnAmputationItem(zombie) function ItemsController.Zombie.SpawnAmputationItem(zombie)
-- TODO Set texture ID -- TODO Set texture ID
local itemVisualsList = zombie:getItemVisuals() local itemVisualsList = zombie:getItemVisuals()
local ignoredLimbs = {} local ignoredLimbs = {}
@@ -164,4 +164,4 @@ function ISInventoryPane:refreshContainer()
end end
end end
return ItemsHandler return ItemsController

View File

@@ -1,4 +1,4 @@
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
@@ -11,36 +11,36 @@ local StaticData = require("TOC/StaticData")
-- Update current player status (infection checks) -- Update current player status (infection checks)
-- handle stats increase\decrease -- handle stats increase\decrease
---@class PlayerHandler ---@class LocalPlayerController
---@field playerObj IsoPlayer ---@field playerObj IsoPlayer
---@field username string ---@field username string
---@field hasBeenDamaged boolean ---@field hasBeenDamaged boolean
local PlayerHandler = {} local LocalPlayerController = {}
---Setup the Player Handler and modData, only for local client ---Setup the Player Handler and modData, only for local client
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
---@param isForced boolean? ---@param isForced boolean?
function PlayerHandler.InitializePlayer(playerObj, isForced) function LocalPlayerController.InitializePlayer(playerObj, isForced)
local username = playerObj:getUsername() local username = playerObj:getUsername()
TOC_DEBUG.print("[PlayerHandler] Initializing local player: " .. username) TOC_DEBUG.print("[PlayerHandler] Initializing local player: " .. username)
ModDataHandler:new(username, isForced) DataController:new(username, isForced)
PlayerHandler.playerObj = playerObj LocalPlayerController.playerObj = playerObj
PlayerHandler.username = username LocalPlayerController.username = username
-- Calculate amputated limbs and highest point of amputations at startup -- Calculate amputated limbs and highest point of amputations at startup
--CachedDataHandler.CalculateAmputatedLimbs(username) --CachedDataHandler.CalculateAmputatedLimbs(username)
--CachedDataHandler.CalculateHighestAmputatedLimbs(username) --CachedDataHandler.CalculateHighestAmputatedLimbs(username)
--Setup the CicatrizationUpdate event and triggers it once --Setup the CicatrizationUpdate event and triggers it once
Events.OnAmputatedLimb.Add(PlayerHandler.ToggleUpdateAmputations) Events.OnAmputatedLimb.Add(LocalPlayerController.ToggleUpdateAmputations)
PlayerHandler.ToggleUpdateAmputations() LocalPlayerController.ToggleUpdateAmputations()
-- 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
local ItemsHandler = require("TOC/Handlers/ItemsHandler") local ItemsController = require("TOC/Handlers/ItemsController")
ItemsHandler.Player.DeleteAllOldAmputationItems(playerObj) ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
CachedDataHandler.Reset(username) CachedDataHandler.Reset(username)
end end
@@ -51,7 +51,7 @@ end
---Handles the traits ---Handles the traits
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
function PlayerHandler.ManageTraits(playerObj) function LocalPlayerController.ManageTraits(playerObj)
local AmputationHandler = require("Handlers/TOC_AmputationHandler") local AmputationHandler = require("Handlers/TOC_AmputationHandler")
for k, v in pairs(StaticData.TRAITS_BP) do for k, v in pairs(StaticData.TRAITS_BP) do
if playerObj:HasTrait(k) then if playerObj:HasTrait(k) then
@@ -68,7 +68,7 @@ end
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently ---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
---@param bodyPart BodyPart ---@param bodyPart BodyPart
function PlayerHandler.HealArea(bodyPart) function LocalPlayerController.HealArea(bodyPart)
bodyPart:setBleeding(false) bodyPart:setBleeding(false)
bodyPart:setBleedingTime(0) bodyPart:setBleedingTime(0)
@@ -90,8 +90,8 @@ end
---@param bodyDamage BodyDamage ---@param bodyDamage BodyDamage
---@param bodyPart BodyPart ---@param bodyPart BodyPart
---@param limbName string ---@param limbName string
---@param modDataHandler ModDataHandler ---@param dcInst DataController
function PlayerHandler.HealZombieInfection(bodyDamage, bodyPart, limbName, modDataHandler) function LocalPlayerController.HealZombieInfection(bodyDamage, bodyPart, limbName, dcInst)
if bodyDamage:isInfected() == false then return end if bodyDamage:isInfected() == false then return end
bodyDamage:setInfected(false) bodyDamage:setInfected(false)
@@ -100,16 +100,16 @@ function PlayerHandler.HealZombieInfection(bodyDamage, bodyPart, limbName, modDa
bodyDamage:setInfectionLevel(-1) bodyDamage:setInfectionLevel(-1)
bodyPart:SetInfected(false) bodyPart:SetInfected(false)
modDataHandler:setIsInfected(limbName, false) dcInst:setIsInfected(limbName, false)
modDataHandler:apply() dcInst:apply()
end end
---comment ---comment
---@param character IsoPlayer ---@param character IsoPlayer
---@param limbName string ---@param limbName string
function PlayerHandler.TryRandomBleed(character, limbName) function LocalPlayerController.TryRandomBleed(character, limbName)
-- Chance should be determined by the cicatrization time -- Chance should be determined by the cicatrization time
local cicTime = ModDataHandler.GetInstance():getCicatrizationTime(limbName) local cicTime = DataController.GetInstance():getCicatrizationTime(limbName)
if cicTime == 0 then return end if cicTime == 0 then return end
-- TODO Sometimes we get cicTime = 0... Shouldn't really do it -- TODO Sometimes we get cicTime = 0... Shouldn't really do it
@@ -129,37 +129,37 @@ end
------------------------- -------------------------
--* Events *-- --* Events *--
--- Locks OnPlayerGetDamage event, to prevent it from getting spammed constantly --- Locks OnPlayerGetDamage event, to prevent it from getting spammed constantly
PlayerHandler.hasBeenDamaged = false LocalPlayerController.hasBeenDamaged = false
---Check if the player has in infected body part or if they have been hit in a cut area ---Check if the player has in infected body part or if they have been hit in a cut area
---@param character IsoPlayer ---@param character IsoPlayer
function PlayerHandler.HandleDamage(character) function LocalPlayerController.HandleDamage(character)
-- TOC_DEBUG.print("Player got hit!") -- TOC_DEBUG.print("Player got hit!")
-- TOC_DEBUG.print(damageType) -- TOC_DEBUG.print(damageType)
if character ~= getPlayer() then return end if character ~= getPlayer() then return end
local bd = character:getBodyDamage() local bd = character:getBodyDamage()
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
local modDataNeedsUpdate = false local modDataNeedsUpdate = false
for i=1, #StaticData.LIMBS_STR do for i=1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName] local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName]
local bodyPart = bd:getBodyPart(bptEnum) local bodyPart = bd:getBodyPart(bptEnum)
if modDataHandler:getIsCut(limbName) then if dcInst:getIsCut(limbName) then
-- Generic injury, let's heal it since they already cut the limb off -- Generic injury, let's heal it since they already cut the limb off
if bodyPart:HasInjury() then if bodyPart:HasInjury() then
PlayerHandler.HealArea(bodyPart) LocalPlayerController.HealArea(bodyPart)
end end
-- Special case for bites\zombie infections -- Special case for bites\zombie infections
if bodyPart:IsInfected() then if bodyPart:IsInfected() then
TOC_DEBUG.print("Healed from zombie infection " .. tostring(bodyPart)) TOC_DEBUG.print("Healed from zombie infection " .. tostring(bodyPart))
PlayerHandler.HealZombieInfection(bd, bodyPart, limbName, modDataHandler) LocalPlayerController.HealZombieInfection(bd, bodyPart, limbName, dcInst)
end end
else else
if bodyPart:bitten() or bodyPart:IsInfected() then if bodyPart:bitten() or bodyPart:IsInfected() then
modDataHandler:setIsInfected(limbName, true) dcInst:setIsInfected(limbName, true)
modDataNeedsUpdate = true modDataNeedsUpdate = true
end end
end end
@@ -167,24 +167,24 @@ function PlayerHandler.HandleDamage(character)
-- Check other body parts that are not included in the mod, if there's a bite there then the player is fucked -- Check other body parts that are not included in the mod, if there's a bite there then the player is fucked
-- We can skip this loop if the player has been infected. The one before we kinda need it to handle correctly the bites in case the player wanna cut stuff off anyway -- We can skip this loop if the player has been infected. The one before we kinda need it to handle correctly the bites in case the player wanna cut stuff off anyway
if modDataHandler:getIsIgnoredPartInfected() then return end if dcInst:getIsIgnoredPartInfected() then return end
for i=1, #StaticData.IGNORED_BODYLOCS_BPT do for i=1, #StaticData.IGNORED_BODYLOCS_BPT do
local bodyPartType = StaticData.IGNORED_BODYLOCS_BPT[i] local bodyPartType = StaticData.IGNORED_BODYLOCS_BPT[i]
local bodyPart = bd:getBodyPart(bodyPartType) local bodyPart = bd:getBodyPart(bodyPartType)
if bodyPart and (bodyPart:bitten() or bodyPart:IsInfected()) then if bodyPart and (bodyPart:bitten() or bodyPart:IsInfected()) then
modDataHandler:setIsIgnoredPartInfected(true) dcInst:setIsIgnoredPartInfected(true)
modDataNeedsUpdate = true modDataNeedsUpdate = true
end end
end end
-- TODO in theory should sync modData, but it's gonna be expensive as fuck. Figure it out -- TODO in theory should sync modData, but it's gonna be expensive as fuck. Figure it out
if modDataNeedsUpdate then if modDataNeedsUpdate then
modDataHandler:apply() dcInst:apply()
end end
-- Disable the lock -- Disable the lock
PlayerHandler.hasBeenDamaged = false LocalPlayerController.hasBeenDamaged = false
end end
@@ -192,29 +192,29 @@ end
---@param character IsoGameCharacter ---@param character IsoGameCharacter
---@param damageType string ---@param damageType string
---@param damageAmount number ---@param damageAmount number
function PlayerHandler.OnGetDamage(character, damageType, damageAmount) function LocalPlayerController.OnGetDamage(character, damageType, damageAmount)
-- TODO Check if other players in the online triggers this -- TODO Check if other players in the online triggers this
if PlayerHandler.hasBeenDamaged == false then if LocalPlayerController.hasBeenDamaged == false then
-- Start checks -- Start checks
-- TODO Add a timer before we can re-enable this bool? -- TODO Add a timer before we can re-enable this bool?
PlayerHandler.hasBeenDamaged = true LocalPlayerController.hasBeenDamaged = true
PlayerHandler.HandleDamage(character) LocalPlayerController.HandleDamage(character)
end end
end end
Events.OnPlayerGetDamage.Add(PlayerHandler.OnGetDamage) Events.OnPlayerGetDamage.Add(LocalPlayerController.OnGetDamage)
---Updates the cicatrization process, run when a limb has been cut. Run it every 1 hour ---Updates the cicatrization process, run when a limb has been cut. Run it every 1 hour
function PlayerHandler.UpdateAmputations() function LocalPlayerController.UpdateAmputations()
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
if modDataHandler:getIsAnyLimbCut() == false then if dcInst:getIsAnyLimbCut() == false then
Events.EveryHours.Remove(PlayerHandler.UpdateAmputations) Events.EveryHours.Remove(LocalPlayerController.UpdateAmputations)
end end
local pl = PlayerHandler.playerObj local pl = LocalPlayerController.playerObj
local bd = pl:getBodyDamage() local bd = pl:getBodyDamage()
local visual = pl:getHumanVisual() local visual = pl:getHumanVisual()
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername()) local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
@@ -222,11 +222,11 @@ function PlayerHandler.UpdateAmputations()
for k, _ in pairs(amputatedLimbs) do for k, _ in pairs(amputatedLimbs) do
local limbName = k local limbName = k
local isCicatrized = modDataHandler:getIsCicatrized(limbName) local isCicatrized = dcInst:getIsCicatrized(limbName)
if not isCicatrized then if not isCicatrized then
needsUpdate = true needsUpdate = true
local cicTime = modDataHandler:getCicatrizationTime(limbName) local cicTime = dcInst:getCicatrizationTime(limbName)
TOC_DEBUG.print("updating cicatrization for " .. tostring(limbName)) TOC_DEBUG.print("updating cicatrization for " .. tostring(limbName))
-- TODO Check if bandaged, sutured, whatever -- TODO Check if bandaged, sutured, whatever
@@ -245,7 +245,7 @@ function PlayerHandler.UpdateAmputations()
-- TEST SECTION -- TEST SECTION
local dirtynessVis = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum) local dirtynessVis = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum)
local dirtynessWound = modDataHandler:getWoundDirtyness(limbName) + modifier local dirtynessWound = dcInst:getWoundDirtyness(limbName) + modifier
-------------- --------------
local dirtyness = dirtynessVis + dirtynessWound local dirtyness = dirtynessVis + dirtynessWound
@@ -254,44 +254,44 @@ function PlayerHandler.UpdateAmputations()
dirtyness = 1 dirtyness = 1
end end
modDataHandler:setWoundDirtyness(limbName, dirtyness) dcInst:setWoundDirtyness(limbName, dirtyness)
TOC_DEBUG.print("dirtyness for this zone: " .. tostring(dirtyness)) TOC_DEBUG.print("dirtyness for this zone: " .. tostring(dirtyness))
cicTime = cicTime - SandboxVars.TOC.CicatrizationSpeed cicTime = cicTime - SandboxVars.TOC.CicatrizationSpeed
modDataHandler:setCicatrizationTime(limbName, cicTime) dcInst:setCicatrizationTime(limbName, cicTime)
TOC_DEBUG.print("new cicatrization time: " .. tostring(cicTime)) TOC_DEBUG.print("new cicatrization time: " .. tostring(cicTime))
if cicTime <= 0 then if cicTime <= 0 then
TOC_DEBUG.print(tostring(limbName) .. " is cicatrized") TOC_DEBUG.print(tostring(limbName) .. " is cicatrized")
modDataHandler:setIsCicatrized(limbName, true) dcInst:setIsCicatrized(limbName, true)
end end
end end
end end
if needsUpdate then if needsUpdate then
TOC_DEBUG.print("updating modData from cicatrization loop") TOC_DEBUG.print("updating modData from cicatrization loop")
modDataHandler:apply() -- TODO This is gonna be heavy. Not entirely sure dcInst:apply() -- TODO This is gonna be heavy. Not entirely sure
else else
TOC_DEBUG.print("Removing UpdateAmputations") TOC_DEBUG.print("Removing UpdateAmputations")
Events.EveryHours.Remove(PlayerHandler.UpdateAmputations) -- We can remove it safely, no cicatrization happening here boys Events.EveryHours.Remove(LocalPlayerController.UpdateAmputations) -- We can remove it safely, no cicatrization happening here boys
end end
TOC_DEBUG.print("updating cicatrization and wound dirtyness!") TOC_DEBUG.print("updating cicatrization and wound dirtyness!")
end end
---Starts safely the loop to update cicatrzation ---Starts safely the loop to update cicatrzation
function PlayerHandler.ToggleUpdateAmputations() function LocalPlayerController.ToggleUpdateAmputations()
TOC_DEBUG.print("[PlayerHandler] Activating amputation handling loop (if it wasn't active before)") TOC_DEBUG.print("[PlayerHandler] Activating amputation handling loop (if it wasn't active before)")
CommonMethods.SafeStartEvent("EveryHours", PlayerHandler.UpdateAmputations) CommonMethods.SafeStartEvent("EveryHours", LocalPlayerController.UpdateAmputations)
end end
--* Helper functions for overrides *-- --* Helper functions for overrides *--
local function CheckHandFeasibility(limbName) local function CheckHandFeasibility(limbName)
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
return not modDataHandler:getIsCut(limbName) or modDataHandler:getIsProstEquipped(StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName]) return not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName])
end end
------------------------------------------ ------------------------------------------
@@ -310,14 +310,14 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
if queue and queue.current and queue.current.skipTOC then return time end if queue and queue.current and queue.current.skipTOC then return time end
-- Action is valid, check if we have any cut limb and then modify maxTime -- Action is valid, check if we have any cut limb and then modify maxTime
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
if time ~= -1 and modDataHandler and modDataHandler:getIsAnyLimbCut() then if time ~= -1 and dcInst and dcInst:getIsAnyLimbCut() then
local pl = getPlayer() local pl = getPlayer()
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername()) local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
for k, _ in pairs(amputatedLimbs) do for k, _ in pairs(amputatedLimbs) do
local limbName = k local limbName = k
--if modDataHandler:getIsCut(limbName) then --if dcInst:getIsCut(limbName) then
local perk = Perks["Side_" .. CommonMethods.GetSide(limbName)] local perk = Perks["Side_" .. CommonMethods.GetSide(limbName)]
local perkLevel = pl:getPerkLevel(perk) local perkLevel = pl:getPerkLevel(perk)
local perkLevelScaled local perkLevelScaled
@@ -337,20 +337,20 @@ local og_ISBaseTimedAction_perform = ISBaseTimedAction.perform
function ISBaseTimedAction:perform() function ISBaseTimedAction:perform()
og_ISBaseTimedAction_perform(self) og_ISBaseTimedAction_perform(self)
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
if not modDataHandler:getIsAnyLimbCut() then return end if not dcInst:getIsAnyLimbCut() then return end
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(PlayerHandler.username) local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(LocalPlayerController.username)
for k, _ in pairs(amputatedLimbs) do for k, _ in pairs(amputatedLimbs) do
local limbName = k local limbName = k
if modDataHandler:getIsCut(limbName) then if dcInst:getIsCut(limbName) then
local side = CommonMethods.GetSide(limbName) local side = CommonMethods.GetSide(limbName)
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 1) -- TODO Make it dynamic LocalPlayerController.playerObj:getXp():AddXP(Perks["Side_" .. side], 1) -- TODO Make it dynamic
local prostGroup = StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName] local prostGroup = StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName]
if not modDataHandler:getIsCicatrized(limbName) and modDataHandler:getIsProstEquipped(prostGroup) then if not dcInst:getIsCicatrized(limbName) and dcInst:getIsProstEquipped(prostGroup) then
TOC_DEBUG.print("Trying for bleed, player met the criteria") TOC_DEBUG.print("Trying for bleed, player met the criteria")
-- TODO If we have cut a forearm, it will try to check the hand too, with cicatrization time = 0. We should skip this -- TODO If we have cut a forearm, it will try to check the hand too, with cicatrization time = 0. We should skip this
PlayerHandler.TryRandomBleed(self.character, limbName) LocalPlayerController.TryRandomBleed(self.character, limbName)
end end
end end
end end
@@ -368,8 +368,8 @@ local og_ISEquipWeaponAction_isValid = ISEquipWeaponAction.isValid
---@diagnostic disable-next-line: duplicate-set-field ---@diagnostic disable-next-line: duplicate-set-field
function ISEquipWeaponAction:isValid() function ISEquipWeaponAction:isValid()
local isValid = og_ISEquipWeaponAction_isValid(self) local isValid = og_ISEquipWeaponAction_isValid(self)
local modDataHandler = ModDataHandler.GetInstance(self.character:getUsername()) local dcInst = DataController.GetInstance(self.character:getUsername())
if isValid and modDataHandler:getIsAnyLimbCut() then if isValid and dcInst:getIsAnyLimbCut() then
local isPrimaryHandValid = CheckHandFeasibility(primaryHand) local isPrimaryHandValid = CheckHandFeasibility(primaryHand)
local isSecondaryHandValid = CheckHandFeasibility(secondaryHand) local isSecondaryHandValid = CheckHandFeasibility(secondaryHand)
@@ -405,8 +405,8 @@ end
---@field character IsoPlayer ---@field character IsoPlayer
---A recreation of the original method, but with amputations in mind ---A recreation of the original method, but with amputations in mind
---@param modDataHandler ModDataHandler ---@param dcInst DataController
function ISEquipWeaponAction:performWithAmputation(modDataHandler) function ISEquipWeaponAction:performWithAmputation(dcInst)
-- TODO Simplify this -- TODO Simplify this
local hand = nil local hand = nil
@@ -446,12 +446,12 @@ function ISEquipWeaponAction:performWithAmputation(modDataHandler)
end end
else else
setMethodSecond(self.character, nil) setMethodSecond(self.character, nil)
-- TODO We should use the CachedData indexable instead of modDataHandler -- TODO We should use the CachedData indexable instead of dcInst
if not modDataHandler:getIsCut(hand) then if not dcInst:getIsCut(hand) then
setMethodSecond(self.character, self.item) setMethodSecond(self.character, self.item)
-- Check other HAND! -- Check other HAND!
elseif not modDataHandler:getIsCut(otherHand) then elseif not dcInst:getIsCut(otherHand) then
setMethodFirst(self.character, self.item) setMethodFirst(self.character, self.item)
end end
end end
@@ -489,10 +489,10 @@ function ISEquipWeaponAction:perform()
og_ISEquipWeaponAction_perform(self) og_ISEquipWeaponAction_perform(self)
-- TODO Can we do it earlier? -- TODO Can we do it earlier?
local modDataHandler = ModDataHandler.GetInstance(self.character:getUsername()) local dcInst = DataController.GetInstance(self.character:getUsername())
-- Just check it any limb has been cut. If not, we can just return from here -- Just check it any limb has been cut. If not, we can just return from here
if modDataHandler:getIsAnyLimbCut() == true then if dcInst:getIsAnyLimbCut() == true then
self:performWithAmputation(modDataHandler) self:performWithAmputation(dcInst)
end end
end end
@@ -531,4 +531,4 @@ function ISInventoryPaneContextMenu.doEquipOption(context, playerObj, isWeapon,
end end
return PlayerHandler return LocalPlayerController

View File

@@ -1,7 +1,7 @@
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local ItemsHandler = require("TOC/Handlers/ItemsHandler") local ItemsController = require("TOC/Handlers/ItemsController")
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local PlayerHandler = require("TOC/Handlers/PlayerHandler") local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
--------------------------- ---------------------------
@@ -132,9 +132,9 @@ function AmputationHandler:execute(damagePlayer)
local surgeonFactor = self.surgeonPl:getPerkLevel(Perks.Doctor) * SandboxVars.TOC.SurgeonAbilityImportance local surgeonFactor = self.surgeonPl:getPerkLevel(Perks.Doctor) * SandboxVars.TOC.SurgeonAbilityImportance
-- Set the data in modData -- Set the data in modData
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
modDataHandler:setCutLimb(self.limbName, false, false, false, surgeonFactor) dcInst:setCutLimb(self.limbName, false, false, false, surgeonFactor)
modDataHandler:apply() -- This will force rechecking the cached amputated limbs on the other client dcInst:apply() -- This will force rechecking the cached amputated limbs on the other client
-- Heal the area, we're gonna re-set the damage after (if it's enabled) -- Heal the area, we're gonna re-set the damage after (if it's enabled)
local bd = self.patientPl:getBodyDamage() local bd = self.patientPl:getBodyDamage()
@@ -142,8 +142,8 @@ function AmputationHandler:execute(damagePlayer)
PlayerHandler.HealArea(bodyPart) PlayerHandler.HealArea(bodyPart)
-- Give the player the correct amputation item -- Give the player the correct amputation item
ItemsHandler.Player.DeleteOldAmputationItem(self.patientPl, self.limbName) ItemsController.Player.DeleteOldAmputationItem(self.patientPl, self.limbName)
ItemsHandler.Player.SpawnAmputationItem(self.patientPl, self.limbName) ItemsController.Player.SpawnAmputationItem(self.patientPl, self.limbName)
-- Add it to the list of cut limbs on this local client -- Add it to the list of cut limbs on this local client
local username = self.patientPl:getUsername() local username = self.patientPl:getUsername()
@@ -158,8 +158,8 @@ function AmputationHandler:execute(damagePlayer)
CachedDataHandler.CalculateHighestAmputatedLimbs(username) CachedDataHandler.CalculateHighestAmputatedLimbs(username)
-- If the part was actually infected, heal the player, if they were in time (infectionLevel < 20) -- If the part was actually infected, heal the player, if they were in time (infectionLevel < 20)
if bd:getInfectionLevel() < 20 and bodyPart:IsInfected() and not modDataHandler:getIsIgnoredPartInfected() then if bd:getInfectionLevel() < 20 and bodyPart:IsInfected() and not dcInst:getIsIgnoredPartInfected() then
PlayerHandler.HealZombieInfection(bd, bodyPart, self.limbName, modDataHandler) PlayerHandler.HealZombieInfection(bd, bodyPart, self.limbName, dcInst)
end end
-- The last part is to handle the damage that the player will receive after the amputation -- The last part is to handle the damage that the player will receive after the amputation

View File

@@ -1,5 +1,5 @@
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
--------------------------- ---------------------------
@@ -21,12 +21,12 @@ CachedDataHandler.amputatedLimbs = {}
function CachedDataHandler.CalculateAmputatedLimbs(username) function CachedDataHandler.CalculateAmputatedLimbs(username)
TOC_DEBUG.print("[CachedDataHandler] Calculating amputated limbs for " .. username) TOC_DEBUG.print("[CachedDataHandler] Calculating amputated limbs for " .. username)
CachedDataHandler.amputatedLimbs[username] = {} CachedDataHandler.amputatedLimbs[username] = {}
local modDataHandler = ModDataHandler.GetInstance(username) local dcInst = DataController.GetInstance(username)
-- TODO If the data hasn't arrived, this won't work -- TODO If the data hasn't arrived, this won't work
for i=1, #StaticData.LIMBS_STR do for i=1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
if modDataHandler:getIsCut(limbName) then if dcInst:getIsCut(limbName) then
CachedDataHandler.AddAmputatedLimb(username, limbName) CachedDataHandler.AddAmputatedLimb(username, limbName)
end end
end end
@@ -58,9 +58,9 @@ CachedDataHandler.highestAmputatedLimbs = {}
---@param username string ---@param username string
function CachedDataHandler.CalculateHighestAmputatedLimbs(username) function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
TOC_DEBUG.print("[CachedDataHandler] Triggered CalculateHighestAmputatedLimbs") TOC_DEBUG.print("[CachedDataHandler] Triggered CalculateHighestAmputatedLimbs")
local modDataHandler = ModDataHandler.GetInstance(username) local dcInst = DataController.GetInstance(username)
if modDataHandler == nil then if dcInst == nil then
TOC_DEBUG.print("ModDataHandler not found for " .. username) TOC_DEBUG.print("DataController not found for " .. username)
return return
end end
@@ -83,7 +83,7 @@ function CachedDataHandler.CalculateHighestAmputatedLimbs(username)
for k, _ in pairs(amputatedLimbs) do for k, _ in pairs(amputatedLimbs) do
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 dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then
TOC_DEBUG.print("[CachedDataHandler] Added Highest Amputation: " .. limbName) TOC_DEBUG.print("[CachedDataHandler] Added Highest Amputation: " .. limbName)
CachedDataHandler.highestAmputatedLimbs[username][index] = limbName CachedDataHandler.highestAmputatedLimbs[username][index] = limbName
end end

View File

@@ -1,6 +1,6 @@
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
------------------------- -------------------------
@@ -67,9 +67,9 @@ function ProsthesisHandler.SearchAndSetupProsthesis(item, isEquipping)
local group = ProsthesisHandler.GetGroup(item) local group = ProsthesisHandler.GetGroup(item)
TOC_DEBUG.print("applying prosthesis stuff for " .. group) TOC_DEBUG.print("applying prosthesis stuff for " .. group)
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
modDataHandler:setIsProstEquipped(group, isEquipping) dcInst:setIsProstEquipped(group, isEquipping)
modDataHandler:apply() dcInst:apply()
end end

View File

@@ -1,4 +1,4 @@
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
---@class SurgeryHandler ---@class SurgeryHandler
---@field type string ---@field type string
@@ -28,7 +28,7 @@ function SurgeryHandler:execute()
if self.type == "oven" then if self.type == "oven" then
ModDataHandler.GetInstance():setIsCauterized(self.limbName, true) DataController.GetInstance():setIsCauterized(self.limbName, true)
end end
end end

View File

@@ -1,4 +1,4 @@
local PlayerHandler = require("TOC/Handlers/PlayerHandler") local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
local CommandsData = require("TOC/CommandsData") local CommandsData = require("TOC/CommandsData")
------------------ ------------------

View File

@@ -2,9 +2,9 @@ if not getActivatedMods():contains("TEST_FRAMEWORK") or not isDebugEnabled() the
local TestFramework = require("TestFramework/TestFramework") local TestFramework = require("TestFramework/TestFramework")
local TestUtils = require("TestFramework/TestUtils") local TestUtils = require("TestFramework/TestUtils")
local PlayerHandler = require("TOC/Handlers/PlayerHandler") local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
local AmputationHandler = require("TOC/Handlers/AmputationHandler") local AmputationHandler = require("TOC/Handlers/AmputationHandler")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
@@ -52,11 +52,11 @@ TestFramework.registerTestModule("PlayerHandler", "Cicatrization", function()
function Tests.SetCicatrizationTimeToOne() function Tests.SetCicatrizationTimeToOne()
for i=1, #StaticData.LIMBS_STR do for i=1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
ModDataHandler.GetInstance():setCicatrizationTime(limbName, 1) DataController.GetInstance():setCicatrizationTime(limbName, 1)
TestUtils.assert(ModDataHandler.GetInstance():getCicatrizationTime(limbName) == 1) TestUtils.assert(DataController.GetInstance():getCicatrizationTime(limbName) == 1)
end end
ModDataHandler.GetInstance():apply() DataController.GetInstance():apply()
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("Hand_L")) TestUtils.assert(DataController.GetInstance():getIsCut("Hand_L"))
end end
return Tests return Tests
@@ -69,19 +69,19 @@ TestFramework.registerTestModule("AmputationHandler", "Top Left", function()
function Tests.CutLeftHand() function Tests.CutLeftHand()
local handler = AmputationHandler:new("Hand_L") local handler = AmputationHandler:new("Hand_L")
handler:execute(true) handler:execute(true)
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("Hand_L")) TestUtils.assert(DataController.GetInstance():getIsCut("Hand_L"))
end end
function Tests.CutLeftForearm() function Tests.CutLeftForearm()
local handler = AmputationHandler:new("ForeArm_L") local handler = AmputationHandler:new("ForeArm_L")
handler:execute(true) handler:execute(true)
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("ForeArm_L") and ModDataHandler.GetInstance():getIsCut("Hand_L")) TestUtils.assert(DataController.GetInstance():getIsCut("ForeArm_L") and DataController.GetInstance():getIsCut("Hand_L"))
end end
function Tests.CutLeftUpperarm() function Tests.CutLeftUpperarm()
local handler = AmputationHandler:new("UpperArm_L") local handler = AmputationHandler:new("UpperArm_L")
handler:execute(true) handler:execute(true)
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("UpperArm_L") and ModDataHandler.GetInstance():getIsCut("ForeArm_L") and ModDataHandler.GetInstance():getIsCut("Hand_L")) TestUtils.assert(DataController.GetInstance():getIsCut("UpperArm_L") and DataController.GetInstance():getIsCut("ForeArm_L") and DataController.GetInstance():getIsCut("Hand_L"))
end end
return Tests return Tests
@@ -93,19 +93,19 @@ TestFramework.registerTestModule("AmputationHandler", "Top Right", function()
function Tests.CutRightHand() function Tests.CutRightHand()
local handler = AmputationHandler:new("Hand_R") local handler = AmputationHandler:new("Hand_R")
handler:execute(true) handler:execute(true)
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("Hand_R")) TestUtils.assert(DataController.GetInstance():getIsCut("Hand_R"))
end end
function Tests.CutRightForearm() function Tests.CutRightForearm()
local handler = AmputationHandler:new("ForeArm_R") local handler = AmputationHandler:new("ForeArm_R")
handler:execute(true) handler:execute(true)
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("ForeArm_R") and ModDataHandler.GetInstance():getIsCut("Hand_R")) TestUtils.assert(DataController.GetInstance():getIsCut("ForeArm_R") and DataController.GetInstance():getIsCut("Hand_R"))
end end
function Tests.CutRightUpperarm() function Tests.CutRightUpperarm()
local handler = AmputationHandler:new("UpperArm_R") local handler = AmputationHandler:new("UpperArm_R")
handler:execute(true) handler:execute(true)
TestUtils.assert(ModDataHandler.GetInstance():getIsCut("UpperArm_R") and ModDataHandler.GetInstance():getIsCut("ForeArm_R") and ModDataHandler.GetInstance():getIsCut("Hand_R")) TestUtils.assert(DataController.GetInstance():getIsCut("UpperArm_R") and DataController.GetInstance():getIsCut("ForeArm_R") and DataController.GetInstance():getIsCut("Hand_R"))
end end
return Tests return Tests

View File

@@ -1,4 +1,4 @@
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
---- ----
@@ -70,8 +70,8 @@ function CleanWoundAction:perform()
local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart) local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart)
-- TODO CHeck if correct in MP -- TODO CHeck if correct in MP
local modDataHandler = ModDataHandler.GetInstance(self.otherPlayer:getUsername()) local dcInst = DataController.GetInstance(self.otherPlayer:getUsername())
modDataHandler:setWoundDirtyness(limbName, 0) dcInst:setWoundDirtyness(limbName, 0)
-- Clean visual -- Clean visual

View File

@@ -1,8 +1,12 @@
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
local WoundCleaningHandler = require("TOC/UI/WoundCleaningInteraction") local CutLimbHandler = require("TOC/UI/Interactions/CutLimbHandler")
local WoundCleaningHandler = require("TOC/UI/Interactions/WoundCleaningHandler")
------------------------
local isReady = false local isReady = false
@@ -105,7 +109,7 @@ 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 = DataController.GetInstance(username):getCicatrizationTime(limbName)
redColor = GetColorFromCicatrizationTime(cicTime, limbName) redColor = GetColorFromCicatrizationTime(cicTime, limbName)
local sexPl local sexPl
@@ -204,16 +208,16 @@ end
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType()) local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr] local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
if limbName then if limbName then
local modDataHandler = ModDataHandler.GetInstance(username) local dcInst = DataController.GetInstance(username)
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then if dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then
if modDataHandler:getIsCicatrized(limbName) then if dcInst:getIsCicatrized(limbName) then
if modDataHandler:getIsCauterized(limbName) then if dcInst:getIsCauterized(limbName) then
self:drawText("- " .. getText("IGUI_HealthPanel_Cauterized"), x, y, 0.58, 0.75, 0.28, 1, UIFont.Small) self:drawText("- " .. getText("IGUI_HealthPanel_Cauterized"), x, y, 0.58, 0.75, 0.28, 1, UIFont.Small)
else else
self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrized"), x, y, 0.28, 0.89, 0.28, 1, UIFont.Small) self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrized"), x, y, 0.28, 0.89, 0.28, 1, UIFont.Small)
end end
else else
local cicaTime = modDataHandler:getCicatrizationTime(limbName) local cicaTime = dcInst:getCicatrizationTime(limbName)
-- Show it in percentage -- Show it in percentage
local maxCicaTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName] local maxCicaTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName]
@@ -221,7 +225,7 @@ end
self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrization") .. string.format(" %.2f", percentage) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small) self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrization") .. string.format(" %.2f", percentage) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
y = y + fontHgt y = y + fontHgt
local scaledDirtyness = math.floor(modDataHandler:getWoundDirtyness(limbName) * 100) local scaledDirtyness = math.floor(dcInst:getWoundDirtyness(limbName) * 100)
self:drawText("- " .. getText("IGUI_HealthPanel_WoundDirtyness") .. string.format(" %d", scaledDirtyness) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small) self:drawText("- " .. getText("IGUI_HealthPanel_WoundDirtyness") .. string.format(" %d", scaledDirtyness) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
end end
y = y + fontHgt y = y + fontHgt
@@ -247,7 +251,7 @@ end
end end
local patientUsername = self:getPatient():getUsername() local patientUsername = self:getPatient():getUsername()
local mdh = ModDataHandler.GetInstance(patientUsername) local mdh = DataController.GetInstance(patientUsername)
for i=1,bodyParts:size() do for i=1,bodyParts:size() do
local bodyPart = bodyParts:get(i-1) local bodyPart = bodyParts:get(i-1)
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType()) local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())

View File

@@ -1,7 +1,8 @@
local BaseHandler = require("TOC/UI/HealthPanelBaseHandler") local BaseHandler = require("TOC/UI/Interactions/HealthPanelBaseHandler")
local CutLimbAction = require("TOC/TimedActions/CutLimbAction")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CutLimbAction = require("TOC/TimedActions/CutLimbAction")
--------------------- ---------------------
-- TODO Add interaction to cut and bandage! -- TODO Add interaction to cut and bandage!
@@ -96,7 +97,7 @@ local function AddInvAmputationOptions(player, context, sawItem, stitchesItem, b
for i = 1, #StaticData.LIMBS_STR do for i = 1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
if not ModDataHandler.GetInstance():getIsCut(limbName) then if not DataController.GetInstance():getIsCut(limbName) then
local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName) local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName)
subMenu:addOption(limbTranslatedName, player, PerformAction, player, limbName, sawItem, stitchesItem, bandageItem) subMenu:addOption(limbTranslatedName, player, PerformAction, player, limbName, sawItem, stitchesItem, bandageItem)
end end
@@ -177,7 +178,7 @@ end
function CutLimbHandler:addToMenu(context) function CutLimbHandler:addToMenu(context)
TOC_DEBUG.print("CutLimbHandler addToMenu") TOC_DEBUG.print("CutLimbHandler addToMenu")
local types = self:getAllItemTypes(self.items.ITEMS) local types = self:getAllItemTypes(self.items.ITEMS)
if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not ModDataHandler.GetInstance():getIsCut(self.limbName) then if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance():getIsCut(self.limbName) then
TOC_DEBUG.print("addToMenu, types > 0") TOC_DEBUG.print("addToMenu, types > 0")
for i=1, #types do for i=1, #types do
context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i]) context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i])
@@ -199,7 +200,7 @@ end
function CutLimbHandler:isValid() function CutLimbHandler:isValid()
TOC_DEBUG.print("CutLimbHandler isValid") TOC_DEBUG.print("CutLimbHandler isValid")
self:checkItems() self:checkItems()
return not ModDataHandler.GetInstance():getIsCut(self.limbName) return not DataController.GetInstance():getIsCut(self.limbName)
end end
function CutLimbHandler:perform(previousAction, itemType) function CutLimbHandler:perform(previousAction, itemType)

View File

@@ -1,7 +1,7 @@
local BaseHandler = require("TOC/UI/HealthPanelBaseHandler") local BaseHandler = require("TOC/UI/Interactions/HealthPanelBaseHandler")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
local CleanWoundAction = require("TOC/TimedActions/CleanWoundAction") local CleanWoundAction = require("TOC/TimedActions/CleanWoundAction")
------------------------- -------------------------
@@ -60,11 +60,11 @@ function WoundCleaningHandler:isValid()
-- todo get username -- todo get username
if self.limbName == nil then return false end if self.limbName == nil then return false end
local modDataHandler = ModDataHandler.GetInstance(self.username) local dcInst = DataController.GetInstance(self.username)
--and modDataHandler:getWoundDirtyness(self.limbName) > 0.1 --and dcInst:getWoundDirtyness(self.limbName) > 0.1
return modDataHandler:getIsCut(self.limbName) and not modDataHandler:getIsCicatrized(self.limbName) return dcInst:getIsCut(self.limbName) and not dcInst:getIsCicatrized(self.limbName)
--return self:getItemOfType(self.items.ITEMS, itemType) --return self:getItemOfType(self.items.ITEMS, itemType)
end end

View File

@@ -1 +0,0 @@
-- TODO Separate UI to craft prosthesis... No just use the crafting menu you mook

View File

@@ -1,5 +1,5 @@
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local ModDataHandler = require("TOC/Handlers/ModDataHandler") local DataController = require("TOC/Controllers/DataController")
--------------- ---------------
@@ -17,14 +17,14 @@ Events.OnFillInventoryObjectContextMenu.Add(AddInventorySurgeryMenu)
-- TODO We need a class to handle operations, this is just a placeholder -- TODO We need a class to handle operations, this is just a placeholder
local function Cauterize(limbName) local function Cauterize(limbName)
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
modDataHandler:setCicatrizationTime(limbName, 0) dcInst:setCicatrizationTime(limbName, 0)
modDataHandler:setIsCicatrized(limbName, true) dcInst:setIsCicatrized(limbName, true)
modDataHandler:setIsCauterized(limbName, true) dcInst:setIsCauterized(limbName, true)
-- we don't care bout the depended limbs, since they're alread "cicatrized" -- we don't care bout the depended limbs, since they're alread "cicatrized"
modDataHandler:apply() dcInst:apply()
end end
---@param playerNum number ---@param playerNum number
@@ -36,8 +36,8 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
local pl = getSpecificPlayer(playerNum) local pl = getSpecificPlayer(playerNum)
local modDataHandler = ModDataHandler.GetInstance() local dcInst = DataController.GetInstance()
if not modDataHandler:getIsAnyLimbCut() then return end if not dcInst:getIsAnyLimbCut() then return end
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername()) local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
local stoveObj = nil local stoveObj = nil
@@ -63,7 +63,7 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
-- We need to let the player cauterize ONLY the visible one! -- We need to let the player cauterize ONLY the visible one!
local limbName = k local limbName = k
if modDataHandler:getIsVisible(limbName) and not modDataHandler:getIsCicatrized(limbName) then if dcInst:getIsVisible(limbName) and not dcInst:getIsCicatrized(limbName) then
if addMainOption == false then if addMainOption == false then
-- Adds the cauterize option ONLY when it's needed -- Adds the cauterize option ONLY when it's needed
local optionMain = context:addOption(getText("ContextMenu_Cauterize"), nil) local optionMain = context:addOption(getText("ContextMenu_Cauterize"), nil)

View File

@@ -1,4 +1,4 @@
local ItemsHandler = require("TOC/Handlers/ItemsHandler") local ItemsController = require("TOC/Handlers/ItemsController")
-------------------- --------------------
@@ -8,7 +8,7 @@ local ItemsHandler = require("TOC/Handlers/ItemsHandler")
------------------- -------------------
local function test(zombie, character, bodyPartType, handWeapon) local function test(zombie, character, bodyPartType, handWeapon)
--ItemsHandler.Zombie.SpawnAmputationItem(zombie) --ItemsController.Zombie.SpawnAmputationItem(zombie)
end end
Events.OnHitZombie.Add(test) Events.OnHitZombie.Add(test)

View File

@@ -8,14 +8,14 @@ ServerDataHandler.modData = {}
---Get the server mod data table containing that player TOC data ---Get the server mod data table containing that player TOC data
---@param key string ---@param key string
---@return tocModData ---@return tocModDataType
function ServerDataHandler.GetTable(key) function ServerDataHandler.GetTable(key)
return ServerDataHandler.modData[key] return ServerDataHandler.modData[key]
end end
---Add table to the ModData and a local table ---Add table to the ModData and a local table
---@param key string ---@param key string
---@param table tocModData ---@param table tocModDataType
function ServerDataHandler.AddTable(key, table) function ServerDataHandler.AddTable(key, table)
-- Check if key is valid -- Check if key is valid
if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end

View File

@@ -2,7 +2,7 @@
---@alias limbsTable {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData } ---@alias limbsTable {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData }
---@alias prosthesisData {isProstEquipped : boolean, prostFactor : number } ---@alias prosthesisData {isProstEquipped : boolean, prostFactor : number }
---@alias prosthesesTable {Top_L : prosthesisData, Top_R : prosthesisData } -- TODO add Bottom_L and Bottom_R ---@alias prosthesesTable {Top_L : prosthesisData, Top_R : prosthesisData } -- TODO add Bottom_L and Bottom_R
---@alias tocModData { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean } ---@alias tocModDataType { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean }
--------------------------- ---------------------------