More cleaning, fixing up interactions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local CommonMethods = require("TOC/CommonMethods")
|
||||
---------------------------
|
||||
|
||||
@@ -23,7 +24,6 @@ function CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||
CachedDataHandler.amputatedLimbs[username] = {}
|
||||
local dcInst = DataController.GetInstance(username)
|
||||
|
||||
-- TODO If the data hasn't arrived, this won't work
|
||||
for i=1, #StaticData.LIMBS_STR do
|
||||
local limbName = StaticData.LIMBS_STR[i]
|
||||
if dcInst:getIsCut(limbName) then
|
||||
|
||||
@@ -22,17 +22,9 @@ end
|
||||
---@param item InventoryItem
|
||||
---@return string
|
||||
function ProsthesisHandler.GetGroup(item)
|
||||
|
||||
local bodyLocation = item:getBodyLocation()
|
||||
local side = CommonMethods.GetSide(bodyLocation)
|
||||
local index
|
||||
|
||||
if bodyLocation:contains(bodyLocArmProst) then
|
||||
index = "Top_" .. side
|
||||
else
|
||||
index = "Bottom_" .. side
|
||||
end
|
||||
|
||||
local index = bodyLocation:contains(bodyLocArmProst) and "Top_" .. side or "Bottom_" .. side
|
||||
local group = StaticData.PROSTHESES_GROUPS_IND_STR[index]
|
||||
return group
|
||||
end
|
||||
@@ -41,15 +33,15 @@ end
|
||||
---@param bodyLocation string
|
||||
---@return boolean
|
||||
function ProsthesisHandler.CheckIfEquippable(bodyLocation)
|
||||
TOC_DEBUG.print("current item is a prosthesis")
|
||||
TOC_DEBUG.print("Current item is a prosthesis")
|
||||
local side = CommonMethods.GetSide(bodyLocation)
|
||||
TOC_DEBUG.print("checking side: " .. tostring(side))
|
||||
TOC_DEBUG.print("Checking side: " .. tostring(side))
|
||||
|
||||
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(getPlayer():getUsername())
|
||||
for k, _ in pairs(amputatedLimbs) do
|
||||
local limbName = k
|
||||
if string.contains(limbName, side) and not string.contains(limbName, "UpperArm") then
|
||||
TOC_DEBUG.print("found acceptable limb to use prosthesis")
|
||||
TOC_DEBUG.print("Found acceptable limb to use prosthesis")
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -66,20 +58,12 @@ function ProsthesisHandler.SearchAndSetupProsthesis(item, isEquipping)
|
||||
if not ProsthesisHandler.CheckIfProst(item) then return end
|
||||
|
||||
local group = ProsthesisHandler.GetGroup(item)
|
||||
TOC_DEBUG.print("applying prosthesis stuff for " .. group)
|
||||
TOC_DEBUG.print("Applying prosthesis stuff for " .. group)
|
||||
local dcInst = DataController.GetInstance()
|
||||
dcInst:setIsProstEquipped(group, isEquipping)
|
||||
dcInst:apply()
|
||||
|
||||
end
|
||||
|
||||
|
||||
-------------------------
|
||||
--* Events *--
|
||||
|
||||
|
||||
|
||||
|
||||
-------------------------
|
||||
--* Overrides *--
|
||||
|
||||
@@ -136,7 +120,6 @@ function ISClothingExtraAction:isValid()
|
||||
return isEquippable
|
||||
end
|
||||
|
||||
|
||||
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
|
||||
function ISClothingExtraAction:perform()
|
||||
og_ISClothingExtraAction_perform(self)
|
||||
@@ -150,5 +133,4 @@ function ISUnequipAction:perform()
|
||||
end
|
||||
|
||||
|
||||
|
||||
return ProsthesisHandler
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
|
||||
---@class SurgeryHandler
|
||||
---@field type string
|
||||
---@field limbName string
|
||||
local SurgeryHandler = {}
|
||||
|
||||
function SurgeryHandler:new(type, limbName)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
|
||||
|
||||
-- TODO use getjob for this
|
||||
o.type = type
|
||||
o.limbName = limbName
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
|
||||
-- TODO Should we consider stitching as "operating?"
|
||||
|
||||
function SurgeryHandler:execute()
|
||||
if self.type == "needle" then
|
||||
-- TODO
|
||||
end
|
||||
|
||||
|
||||
if self.type == "oven" then
|
||||
DataController.GetInstance():setIsCauterized(self.limbName, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Cauterize
|
||||
|
||||
|
||||
-- Needle and stitching (scrap surgery kits and crap like that)
|
||||
|
||||
|
||||
|
||||
|
||||
return SurgeryHandler
|
||||
Reference in New Issue
Block a user