fix: switched to multiple body locs to fix some old issues and prepare for better visuals overhaul

This commit is contained in:
ZioPao
2025-10-04 02:32:48 +02:00
parent 1caf4a4b49
commit a74e33134d
9 changed files with 73 additions and 56 deletions

View File

@@ -78,13 +78,16 @@ end
---Deletes all the old amputation items, used for resets
---@param playerObj IsoPlayer
function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
-- TODO Fix visual bug
-- This part is a workaround for a pretty shitty implementation on the java side. Check ProsthesisHandler for more infos
local group = BodyLocations.getGroup("Human")
group:setMultiItem("TOC_Arm", false)
group:setMultiItem("TOC_ArmProst", false)
-- local group = BodyLocations.getGroup("Human")
-- group:setMultiItem("TOC_Arm", false)
-- group:setMultiItem("TOC_ArmProst", false)
for i = 1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i]
-- TODO Won't work with dedicated clothingItems for multi amps
local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName
local clothItem = playerObj:getInventory():FindAndReturn(clothItemName)
---@cast clothItem InventoryItem
@@ -93,8 +96,8 @@ function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
-- Reset model just in case
playerObj:resetModel()
group:setMultiItem("TOC_Arm", true)
group:setMultiItem("TOC_ArmProst", true)
-- group:setMultiItem("TOC_Arm", true)
-- group:setMultiItem("TOC_ArmProst", true)
end
---Spawns and equips the correct amputation item to the player.

View File

@@ -64,18 +64,18 @@ end
---@param obj any self
---@param wrappedFunc function
function TourniquetController.WrapClothingAction(obj, wrappedFunc)
local isTourniquet = TourniquetController.IsItemTourniquet(obj.item:getFullType())
local group
if isTourniquet then
group = BodyLocations.getGroup("Human")
group:setMultiItem(TourniquetController.bodyLoc, false)
end
-- local isTourniquet = TourniquetController.IsItemTourniquet(obj.item:getFullType())
-- local group
-- if isTourniquet then
-- group = BodyLocations.getGroup("Human")
-- group:setMultiItem(TourniquetController.bodyLoc, false)
-- end
local ogValue = wrappedFunc(obj)
if isTourniquet then
group:setMultiItem(TourniquetController.bodyLoc, true)
end
-- if isTourniquet then
-- group:setMultiItem(TourniquetController.bodyLoc, true)
-- end
return ogValue -- Needed for isValid
end

View File

@@ -167,15 +167,15 @@ function ISUnequipAction:perform()
]]
local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, false)
local group
if isProst then
group = BodyLocations.getGroup("Human")
group:setMultiItem("TOC_ArmProst", false)
end
-- local group
-- if isProst then
-- group = BodyLocations.getGroup("Human")
-- group:setMultiItem("TOC_ArmProst", false)
-- end
og_ISUnequipAction_perform(self)
if isProst then
group:setMultiItem("TOC_ArmProst", true)
-- group:setMultiItem("TOC_ArmProst", true)
-- we need to fetch the limbname associated to the prosthesis
local side = CommonMethods.GetSide(self.item:getFullType())

View File

@@ -9,8 +9,19 @@ local group = BodyLocations.getGroup("Human")
---@type ArrayList
local list = customGetVal(group, 1)
-- TODO Not sure if this method actually works as intende with b42, but for our use case it's fine...
---@param bodyLoc string
function BodyLocationsAPI.New(bodyLoc)
local curItem
if StaticData.COMPAT_42 then
curItem = BodyLocation.new(group, bodyLoc) -- create new item
group:getAllLocations():add(curItem) -- add to the list
else
curItem = group:getOrCreateLocation(bodyLoc) -- get current item - or create
end
return curItem
end
-- TODO Not sure if this method actually works as intende with b42, but for our use case it's fine...
---@param toRelocateOrCreate string
---@param locationElement string
---@param afterBoolean boolean
@@ -23,14 +34,7 @@ function BodyLocationsAPI.MoveOrCreateBeforeOrAfter(toRelocateOrCreate, location
-- Check type of arg 1 == string - if not, error out.
if type(toRelocateOrCreate) ~= "string" then error("Argument 1 is not of type string. Please re-check!", 2) end
local curItem
if StaticData.COMPAT_42 then
curItem = BodyLocation.new(group, toRelocateOrCreate) -- create new item
group:getAllLocations():add(curItem) -- add to the list
else
curItem = group:getOrCreateLocation(toRelocateOrCreate) -- get current item - or create
end
local curItem = BodyLocationsAPI.New(toRelocateOrCreate)
list:remove(curItem) -- remove from the list
local index = group:indexOf(locationElement) -- get current index after removal of the location to move to
if afterBoolean then index = index + 1 end -- if we want it after it, we increase the index to move to by one
@@ -43,6 +47,8 @@ function BodyLocationsAPI.MoveOrCreateBeforeOrAfter(toRelocateOrCreate, location
end
end
-- function TestBodyLocations()
-- local group = BodyLocations.getGroup("Human")
-- local x = group:getAllLocations()
@@ -58,11 +64,17 @@ end
-- MultiItem causes a ton of issues... fucking hell
BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_Arm", "FullTop", true)
group:setMultiItem("TOC_Arm", true)
-- local curItem = BodyLocation.new(group, "TOC_Arm_L")
-- group:getAllLocations():add(curItem)
BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmProst", "TOC_Arm", true)
group:setMultiItem("TOC_ArmProst", true)
-- local curItem = BodyLocation.new(group, "TOC_Arm_R")
-- group:getAllLocations():add(curItem)
BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmAccessory", "TOC_ArmProst", true)
group:setMultiItem("TOC_ArmAccessory", true)
BodyLocationsAPI.New("TOC_Arm_L")
BodyLocationsAPI.New("TOC_Arm_R")
BodyLocationsAPI.New("TOC_Arm_LR")
BodyLocationsAPI.New("TOC_ArmProst_L")
BodyLocationsAPI.New("TOC_ArmProst_R")
BodyLocationsAPI.New("TOC_ArmAccessory_L")
BodyLocationsAPI.New("TOC_ArmAccessory_R")