Readded translations, finalized folder struct
This commit is contained in:
@@ -6,8 +6,43 @@ local CommonMethods = require("TOC/CommonMethods")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
|
||||
-----------------
|
||||
---@class LimitActionsController
|
||||
local LimitActionsController = {}
|
||||
|
||||
|
||||
--* DISABLE WEARING CERTAIN ITEMS WHEN NO LIMB
|
||||
|
||||
function LimitActionsController.CheckLimbFeasibility(limbName)
|
||||
local dcInst = DataController.GetInstance()
|
||||
local isFeasible = not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName)
|
||||
--TOC_DEBUG.print("isFeasible="..tostring(isFeasible))
|
||||
return isFeasible
|
||||
end
|
||||
|
||||
---@param obj any
|
||||
---@param wrappedFunc function
|
||||
---@param item InventoryItem
|
||||
---@return boolean
|
||||
function LimitActionsController.WrapClothingAction(obj, wrappedFunc, item)
|
||||
local isEquippable = wrappedFunc(obj)
|
||||
if not isEquippable then return isEquippable end
|
||||
|
||||
local itemBodyLoc = item:getBodyLocation()
|
||||
|
||||
local limbToCheck = StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[itemBodyLoc]
|
||||
if LimitActionsController.CheckLimbFeasibility(limbToCheck) then return isEquippable else return false end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------
|
||||
--* TIMED ACTIONS *--
|
||||
-- We want to be able to modify how long actions are gonna take,
|
||||
-- depending on amputation status and kind of action. Also, when the
|
||||
@@ -328,42 +363,16 @@ function ISWorldObjectContextMenu.createMenu(player, worldobjects, x, y, test)
|
||||
return ogContext
|
||||
end
|
||||
|
||||
--* DISABLE WEARING CERTAIN ITEMS WHEN NO LIMB
|
||||
|
||||
local function CheckLimbFeasibility(limbName)
|
||||
local dcInst = DataController.GetInstance()
|
||||
local isFeasible = not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName)
|
||||
--TOC_DEBUG.print("isFeasible="..tostring(isFeasible))
|
||||
return isFeasible
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
---@param obj any
|
||||
---@param wrappedFunc function
|
||||
---@param item InventoryItem
|
||||
---@return boolean
|
||||
local function WrapClothingAction(obj, wrappedFunc, item)
|
||||
local isEquippable = wrappedFunc(obj)
|
||||
if not isEquippable then return isEquippable end
|
||||
|
||||
local itemBodyLoc = item:getBodyLocation()
|
||||
|
||||
local limbToCheck = StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[itemBodyLoc]
|
||||
if CheckLimbFeasibility(limbToCheck) then return isEquippable else return false end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
local og_ISWearClothing_isValid = ISWearClothing.isValid
|
||||
function ISWearClothing:isValid()
|
||||
return WrapClothingAction(self, og_ISWearClothing_isValid, self.item)
|
||||
return LimitActionsController.WrapClothingAction(self, og_ISWearClothing_isValid, self.item)
|
||||
end
|
||||
|
||||
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function ISClothingExtraAction:isValid()
|
||||
return WrapClothingAction(self, og_ISClothingExtraAction_isValid, InventoryItemFactory.CreateItem(self.extra))
|
||||
end
|
||||
return LimitActionsController.WrapClothingAction(self, og_ISClothingExtraAction_isValid, InventoryItemFactory.CreateItem(self.extra))
|
||||
end
|
||||
|
||||
return LimitActionsController
|
||||
@@ -88,14 +88,7 @@ function ProsthesisHandler.SearchAndSetupProsthesis(item, isEquipping)
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------
|
||||
--* Overrides *--
|
||||
|
||||
|
||||
---@param item InventoryItem
|
||||
---@param isEquippable boolean
|
||||
---@return unknown
|
||||
local function HandleProsthesisValidation(item, isEquippable)
|
||||
function ProsthesisHandler.Validate(item, isEquippable)
|
||||
local isProst = ProsthesisHandler.CheckIfProst(item)
|
||||
if not isProst then return isEquippable end
|
||||
|
||||
@@ -110,11 +103,16 @@ local function HandleProsthesisValidation(item, isEquippable)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-------------------------
|
||||
--* Overrides *--
|
||||
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
local og_ISWearClothing_isValid = ISWearClothing.isValid
|
||||
function ISWearClothing:isValid()
|
||||
local isEquippable = og_ISWearClothing_isValid(self)
|
||||
return HandleProsthesisValidation(self.item, isEquippable)
|
||||
return ProsthesisHandler.Validate(self.item, isEquippable)
|
||||
end
|
||||
|
||||
local og_ISWearClothing_perform = ISWearClothing.perform
|
||||
@@ -128,14 +126,14 @@ local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
||||
function ISClothingExtraAction:isValid()
|
||||
local isEquippable = og_ISClothingExtraAction_isValid(self)
|
||||
-- self.extra is a string, not the item
|
||||
local testItem = instanceItem(self.extra)
|
||||
return HandleProsthesisValidation(testItem, isEquippable)
|
||||
local testItem = InventoryItemFactory.CreateItem(self.extra)
|
||||
return ProsthesisHandler.Validate(testItem, isEquippable)
|
||||
end
|
||||
|
||||
|
||||
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
|
||||
function ISClothingExtraAction:perform()
|
||||
local extraItem = instanceItem(self.extra)
|
||||
local extraItem = InventoryItemFactory.CreateItem(self.extra)
|
||||
ProsthesisHandler.SearchAndSetupProsthesis(extraItem, true)
|
||||
og_ISClothingExtraAction_perform(self)
|
||||
end
|
||||
|
||||
@@ -122,14 +122,18 @@ function ISDrinkFromBottle:new(character, item, uses)
|
||||
return action
|
||||
end
|
||||
|
||||
-- FIX This doesn't exist anymore in B42
|
||||
-- local og_ISFinalizeDealAction_new = ISFinalizeDealAction.new
|
||||
-- function ISFinalizeDealAction:new(player, otherPlayer, itemsToGive, itemsToReceive, time)
|
||||
-- local action = og_ISFinalizeDealAction_new(self, player, otherPlayer, itemsToGive, itemsToReceive, time)
|
||||
-- --TOC_DEBUG.print("Override ISFinalizeDealAction")
|
||||
-- action.skipTOC = true
|
||||
-- return action
|
||||
-- end
|
||||
if luautils.stringStarts(getGameVersion(), "41") then
|
||||
-- This doesn't exist anymore in B42
|
||||
local og_ISFinalizeDealAction_new = ISFinalizeDealAction.new
|
||||
function ISFinalizeDealAction:new(player, otherPlayer, itemsToGive, itemsToReceive, time)
|
||||
local action = og_ISFinalizeDealAction_new(self, player, otherPlayer, itemsToGive, itemsToReceive, time)
|
||||
--TOC_DEBUG.print("Override ISFinalizeDealAction")
|
||||
action.skipTOC = true
|
||||
return action
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local og_ISCampingInfoAction_new = ISCampingInfoAction.new
|
||||
function ISCampingInfoAction:new(character, campfireObject, campfire)
|
||||
|
||||
Reference in New Issue
Block a user