Cleaning
This commit is contained in:
@@ -55,6 +55,7 @@ Events.OnFillInventoryObjectContextMenu.Add(AddInventoryAmputationMenu)
|
|||||||
|
|
||||||
---@class CutLimbHandler : BaseHandler
|
---@class CutLimbHandler : BaseHandler
|
||||||
---@field items table
|
---@field items table
|
||||||
|
---@field limbName string
|
||||||
local CutLimbHandler = BaseHandler:derive("CutLimbHandler")
|
local CutLimbHandler = BaseHandler:derive("CutLimbHandler")
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ local CutLimbHandler = BaseHandler:derive("CutLimbHandler")
|
|||||||
function CutLimbHandler:new(panel, bodyPart)
|
function CutLimbHandler:new(panel, bodyPart)
|
||||||
local o = BaseHandler.new(self, panel, bodyPart)
|
local o = BaseHandler.new(self, panel, bodyPart)
|
||||||
o.items.ITEMS = {}
|
o.items.ITEMS = {}
|
||||||
|
o.limbName = BodyPartType.ToString(self.bodyPart:getType())
|
||||||
TOC_DEBUG.print("init CutLimbHandler")
|
TOC_DEBUG.print("init CutLimbHandler")
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
@@ -80,10 +82,9 @@ end
|
|||||||
---@param context ISContextMenu
|
---@param context ISContextMenu
|
||||||
function CutLimbHandler:addToMenu(context)
|
function CutLimbHandler:addToMenu(context)
|
||||||
local types = self:getAllItemTypes(self.items.ITEMS)
|
local types = self:getAllItemTypes(self.items.ITEMS)
|
||||||
local limbName = BodyPartType.ToString(self.bodyPart:getType())
|
if #types > 0 and StaticData.BODYPARTSTYPES_ENUM[self.limbName] then
|
||||||
if #types > 0 and StaticData.BODYPARTSTYPES_ENUM[limbName] then
|
|
||||||
TOC_DEBUG.print("addToMenu, types > 0")
|
TOC_DEBUG.print("addToMenu, types > 0")
|
||||||
if not ModDataHandler.GetInstance():getIsCut(limbName) then
|
if not ModDataHandler.GetInstance():getIsCut(self.limbName) then
|
||||||
context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected)
|
context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -91,8 +92,7 @@ end
|
|||||||
|
|
||||||
function CutLimbHandler:dropItems(items)
|
function CutLimbHandler:dropItems(items)
|
||||||
local types = self:getAllItemTypes(items)
|
local types = self:getAllItemTypes(items)
|
||||||
local limbName = BodyPartType.ToString(self.bodyPart:getType())
|
if #self.items.ITEMS > 0 and #types == 1 and StaticData.BODYPARTSTYPES_ENUM[self.limbName] then
|
||||||
if #self.items.ITEMS > 0 and #types == 1 and StaticData.BODYPARTSTYPES_ENUM[limbName] then
|
|
||||||
self:onMenuOptionSelected(types[1])
|
self:onMenuOptionSelected(types[1])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -100,16 +100,14 @@ function CutLimbHandler:dropItems(items)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CutLimbHandler:isValid(itemType)
|
function CutLimbHandler:isValid(itemType)
|
||||||
local limbName = BodyPartType.ToString(self.bodyPart:getType())
|
return (not ModDataHandler.GetInstance():getIsCut(self.limbName)) and self:getItemOfType(self.items.ITEMS, itemType)
|
||||||
return (not ModDataHandler.GetInstance():getIsCut(limbName)) and self:getItemOfType(self.items.ITEMS, itemType)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CutLimbHandler:perform(previousAction, itemType)
|
function CutLimbHandler:perform(previousAction, itemType)
|
||||||
local item = self:getItemOfType(self.items.ITEMS, itemType)
|
local item = self:getItemOfType(self.items.ITEMS, itemType)
|
||||||
previousAction = self:toPlayerInventory(item, previousAction)
|
previousAction = self:toPlayerInventory(item, previousAction)
|
||||||
local limbName = BodyPartType.ToString(self.bodyPart:getType())
|
TOC_DEBUG.print("perform CutLimbHandler on " .. self.limbName)
|
||||||
TOC_DEBUG.print("perform CutLimbHandler on " .. limbName)
|
local action = CutLimbAction:new(self:getDoctor(),self:getPatient(), self.limbName, item)
|
||||||
local action = CutLimbAction:new(self:getDoctor(),self:getPatient(), limbName, item)
|
|
||||||
ISTimedActionQueue.addAfter(previousAction, action)
|
ISTimedActionQueue.addAfter(previousAction, action)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local StaticData = require("TOC/StaticData")
|
local StaticData = require("TOC/StaticData")
|
||||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||||
---@diagnostic disable: duplicate-set-field
|
|
||||||
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
|
local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
@@ -9,6 +8,7 @@ local CutLimbHandler = require("TOC/UI/CutLimbInteractions")
|
|||||||
-- By doing so we can show the player which limbs have been cut without having to use another menu
|
-- By doing so we can show the player which limbs have been cut without having to use another menu
|
||||||
-- We can show prosthesis too this way
|
-- We can show prosthesis too this way
|
||||||
-- We also manage the drag'n drop of items on the body to let the players use the saw this way too
|
-- We also manage the drag'n drop of items on the body to let the players use the saw this way too
|
||||||
|
---@diagnostic disable: duplicate-set-field
|
||||||
|
|
||||||
ISHealthBodyPartPanel = ISBodyPartPanel:derive("ISHealthBodyPartPanel")
|
ISHealthBodyPartPanel = ISBodyPartPanel:derive("ISHealthBodyPartPanel")
|
||||||
|
|
||||||
@@ -44,27 +44,6 @@ function ISHealthPanel:doBodyPartContextMenu(bodyPart, x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--* Modifications to handle visible amputation on the health menu *--
|
--* Modifications to handle visible amputation on the health menu *--
|
||||||
|
|
||||||
local og_ISHealthPanel_initialise = ISHealthPanel.initialise
|
local og_ISHealthPanel_initialise = ISHealthPanel.initialise
|
||||||
|
|||||||
Reference in New Issue
Block a user