Mostly working base
This commit is contained in:
@@ -75,7 +75,7 @@ function AmputationHandler:execute()
|
||||
ModDataHandler.GetInstance():setCutLimb(self.limbName, false, false, false, surgeonFactor)
|
||||
|
||||
-- Give the player the correct amputation item
|
||||
self:deleteOldAmputationItem()
|
||||
AmputationHandler.DeleteOldAmputationItem(self.patient, self.limbName)
|
||||
self:spawnAmputationItem()
|
||||
end
|
||||
|
||||
@@ -92,16 +92,22 @@ end
|
||||
--* Amputation Items *--
|
||||
|
||||
---Search and deletes an old amputation clothing item
|
||||
---@private
|
||||
function AmputationHandler:deleteOldAmputationItem()
|
||||
local side = CommonMethods.GetSide(self.limbName)
|
||||
|
||||
---@param player IsoPlayer
|
||||
---@param limbName string
|
||||
function AmputationHandler.DeleteOldAmputationItem(player, limbName)
|
||||
local side = CommonMethods.GetSide(limbName)
|
||||
for partName, _ in pairs(StaticData.PARTS_STRINGS) do
|
||||
local othLimbName = partName .. "_" .. side
|
||||
local othClothingItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. othLimbName
|
||||
local othClothingItem = self.patient:getInventory():FindAndReturn(othClothingItemName)
|
||||
if othClothingItem then
|
||||
self.patient:getInventory():Remove(othClothingItem) -- It accepts it as an Item, not a string
|
||||
|
||||
-- TODO FindAndReturn could return an ArrayList. We need to check for that
|
||||
|
||||
local othClothingItem = player:getInventory():FindAndReturn(othClothingItemName)
|
||||
|
||||
---@cast othClothingItem InventoryItem
|
||||
if othClothingItem and instanceof(othClothingItem, "InventoryItem") then
|
||||
player:removeWornItem(othClothingItem)
|
||||
player:getInventory():Remove(othClothingItem) -- Can be a InventoryItem too.. I guess? todo check it
|
||||
print("TOC: found and deleted " .. othClothingItemName)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -25,6 +25,10 @@ function PlayerHandler.InitializePlayer(_, playerObj, isForced)
|
||||
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
||||
if isForced then
|
||||
ISHealthPanel.highestAmputations = {}
|
||||
|
||||
-- TODO Hacky way to check both limbs
|
||||
AmputationHandler.DeleteOldAmputationItem(playerObj, "Hand_L")
|
||||
AmputationHandler.DeleteOldAmputationItem(playerObj, "Hand_R")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user