Mostly working base
This commit is contained in:
@@ -75,7 +75,7 @@ function AmputationHandler:execute()
|
|||||||
ModDataHandler.GetInstance():setCutLimb(self.limbName, false, false, false, surgeonFactor)
|
ModDataHandler.GetInstance():setCutLimb(self.limbName, false, false, false, surgeonFactor)
|
||||||
|
|
||||||
-- Give the player the correct amputation item
|
-- Give the player the correct amputation item
|
||||||
self:deleteOldAmputationItem()
|
AmputationHandler.DeleteOldAmputationItem(self.patient, self.limbName)
|
||||||
self:spawnAmputationItem()
|
self:spawnAmputationItem()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -92,16 +92,22 @@ end
|
|||||||
--* Amputation Items *--
|
--* Amputation Items *--
|
||||||
|
|
||||||
---Search and deletes an old amputation clothing item
|
---Search and deletes an old amputation clothing item
|
||||||
---@private
|
---@param player IsoPlayer
|
||||||
function AmputationHandler:deleteOldAmputationItem()
|
---@param limbName string
|
||||||
local side = CommonMethods.GetSide(self.limbName)
|
function AmputationHandler.DeleteOldAmputationItem(player, limbName)
|
||||||
|
local side = CommonMethods.GetSide(limbName)
|
||||||
for partName, _ in pairs(StaticData.PARTS_STRINGS) do
|
for partName, _ in pairs(StaticData.PARTS_STRINGS) do
|
||||||
local othLimbName = partName .. "_" .. side
|
local othLimbName = partName .. "_" .. side
|
||||||
local othClothingItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. othLimbName
|
local othClothingItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. othLimbName
|
||||||
local othClothingItem = self.patient:getInventory():FindAndReturn(othClothingItemName)
|
|
||||||
if othClothingItem then
|
-- TODO FindAndReturn could return an ArrayList. We need to check for that
|
||||||
self.patient:getInventory():Remove(othClothingItem) -- It accepts it as an Item, not a string
|
|
||||||
|
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)
|
print("TOC: found and deleted " .. othClothingItemName)
|
||||||
return
|
return
|
||||||
end
|
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
|
-- 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 = {}
|
ISHealthPanel.highestAmputations = {}
|
||||||
|
|
||||||
|
-- TODO Hacky way to check both limbs
|
||||||
|
AmputationHandler.DeleteOldAmputationItem(playerObj, "Hand_L")
|
||||||
|
AmputationHandler.DeleteOldAmputationItem(playerObj, "Hand_R")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user