First stuff for prosthesis rewrite

This commit is contained in:
Pao
2023-01-15 15:48:14 +01:00
parent 81cd386457
commit eeb7076c13
7 changed files with 101 additions and 147 deletions

View File

@@ -6,111 +6,6 @@ end
function TryTocAction(_, part_name, action, surgeon, patient)
-- TODO add checks so that we don't show these menus if a player has already beeen operated or amputated
-- TODO at this point surgeon doesnt do anything. We'll fix this later
-- Check if SinglePlayer
if not isServer() and not isClient() then
if action == "Cut" then
TocCutLocal(_, surgeon, surgeon, part_name)
elseif action == "Operate" then
TocOperateLocal(_, surgeon, surgeon, part_name, false)
elseif action == "Equip" then
-- TODO finish this
local item
TocEquipProsthesisLocal(_, surgeon, surgeon, part_name)
elseif action == "Unequip" then
-- TODO finish this
local item
TocUnequipProsthesisLocal(_, surgeon, part_name)
end
else
local ui = GetConfirmUIMP()
if not ui then
CreateTocConfirmUIMP()
ui = GetConfirmUIMP()
end
if patient == nil then
patient = surgeon
end
if action == "Cut" then
AskCanCutLimb(patient, part_name)
elseif action == "Operate" then
AskCanOperateLimb(patient, part_name)
elseif action == "Equip" then
local surgeon_inventory = surgeon:getInventory()
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
surgeon_inventory:getItemFromType('TOC.MetalHook') or
surgeon_inventory:getItemFromType('TOC.WoodenHook')
if prosthesis_to_equip then
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name))))
else
surgeon:Say("I need a prosthesis")
end
--AskCanEquipProsthesis(patient, part_name, item)
elseif action == "Unequip" then
--AskCanUnequipProsthesis(patient, part_name)
local equipped_prosthesis = FindTocItemWorn(part_name, patient)
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name))))
end
ui.actionAct = action
ui.partNameAct = part_name
ui.patient = patient
--TODO just a workaround for now
if action ~= "Equip" and action ~= "Unequip" then
SendCommandToConfirmUIMP("Wait server")
end
end
end
-- function TryTocActionOnAnotherPlayer(_, part_name, action, surgeon, patient)
-- if action == "Cut" then
-- AskCanCutLimb(patient, part_name)
-- elseif action == "Operate" then
-- AskCanOperateLimb(patient, part_name)
-- end
-- end
-- local function CheckIfCanBeOperated(modData)
-- if modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.is_operated
-- or modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.is_operated
-- or modData.TOC.RightArm.is_cut and not modData.TOC.RightArm.is_operated
-- or modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.is_operated
-- or modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.is_operated
-- or modData.TOC.LeftArm.is_cut and not modData.TOC.LeftArm.is_operated then
-- return true
-- else
-- return false
-- end
-- end
local function CloseAllMenus(player_index)
local contextMenu = getPlayerContextMenu(player_index)
if contextMenu:isVisible() then
contextMenu:closeAll()
end
end
----------------------------------------------------------------------------------------------------------