Some more refactoring
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
------------- LOCAL ACTIONS --------------
|
||||
|
||||
|
||||
|
||||
function TocCutLocal(_, player, part_name)
|
||||
if TocGetSawInInventory(player) ~= nil then
|
||||
ISTimedActionQueue.add(ISCutLimb:new(player, player, part_name))
|
||||
@@ -37,7 +37,7 @@ end
|
||||
|
||||
---Unequip a prosthesis clothing item and returns it to the inventory as a normal item
|
||||
---@param part_name string
|
||||
function TheOnlyCure.UnequipProsthesis(patient, part_name, equipped_prosthesis)
|
||||
function TocUnequipProsthesis(patient, part_name, equipped_prosthesis)
|
||||
|
||||
|
||||
local toc_data = patient:getModData().TOC
|
||||
@@ -1,6 +1,6 @@
|
||||
-- TODO this should be moved
|
||||
|
||||
function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
|
||||
local function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
|
||||
sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() })
|
||||
end
|
||||
|
||||
@@ -288,6 +288,54 @@ local function OnClickTocMainUI(button, args)
|
||||
|
||||
end
|
||||
|
||||
-- Generic TOC action, used in OnClickTocDescUI
|
||||
local function TryTocAction(_, part_name, action, surgeon, patient)
|
||||
-- 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, part_name)
|
||||
elseif action == "Operate" then
|
||||
TocOperateLocal(_, surgeon, part_name, false)
|
||||
elseif action == "Equip" then
|
||||
TocEquipProsthesisLocal(_, surgeon, part_name)
|
||||
elseif action == "Unequip" then
|
||||
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
|
||||
AskCanEquipProsthesis(patient, part_name)
|
||||
elseif action == "Unequip" then
|
||||
AskCanUnequipProsthesis(patient, part_name)
|
||||
end
|
||||
|
||||
ui.actionAct = action
|
||||
ui.partNameAct = part_name
|
||||
ui.patient = patient
|
||||
|
||||
SendCommandToConfirmUIMP("Wait server")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function OnClickTocDescUI(button, args)
|
||||
|
||||
-- Gets every arg from main
|
||||
@@ -540,6 +588,24 @@ function ISNewHealthPanel.onClick_TOC(button)
|
||||
Events.OnTick.Add(TocRefreshPlayerMenu)
|
||||
end
|
||||
|
||||
|
||||
-- Set the correct main title
|
||||
-- TODO sizes of the menu are strange in MP, they're not consistent with SP
|
||||
local separated_username = {}
|
||||
|
||||
for v in string.gmatch(patient:getUsername(), "%u%l+") do
|
||||
table.insert(separated_username, v)
|
||||
end
|
||||
|
||||
local main_title
|
||||
if separated_username[1] == nil then
|
||||
main_title = patient:getUsername() .. " - TOC"
|
||||
else
|
||||
main_title = separated_username[1] .. " " .. separated_username[2] .. " - TOC"
|
||||
end
|
||||
|
||||
main_ui:setTitle(main_title)
|
||||
|
||||
main_ui:toggle()
|
||||
main_ui:setInCenterOfScreen()
|
||||
|
||||
@@ -139,7 +139,7 @@ Commands["UnequipProsthesis"] = function(arg)
|
||||
|
||||
local arg = arg["toSend"]
|
||||
|
||||
TheOnlyCure.UnequipProsthesis(arg[1], arg[2])
|
||||
TheOnlyCure.TocUnequipProsthesis(arg[1], arg[2])
|
||||
|
||||
end
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
------------ DEBUG FUNCTIONS -------------
|
||||
|
||||
|
||||
-- Side functions
|
||||
local function TocGetAmputationFullTypeFromInventory(player, side, limb)
|
||||
@@ -105,9 +110,15 @@ function TocResetClothingItemBodyLocation(player, side, limb)
|
||||
prosthesis_item = nil -- reset it
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
------ TEST FUNCTIONS, DON'T USE THESE!!! ---------------
|
||||
|
||||
function TocTestBodyLocations()
|
||||
|
||||
local group = BodyLocations.getGroup("Human")
|
||||
|
||||
@@ -9,7 +9,7 @@ end
|
||||
|
||||
-- Unequip Prosthesis
|
||||
|
||||
function PartNameToBodyLocationProsthesis(name)
|
||||
local function PartNameToBodyLocationProsthesis(name)
|
||||
if name == "Right_Hand" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Right_LowerArm" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Right_UpperArm" then return "TOC_ArmRightProsthesis" end
|
||||
@@ -18,7 +18,7 @@ function PartNameToBodyLocationProsthesis(name)
|
||||
if name == "Left_UpperArm" then return "TOC_ArmLeftProsthesis" end
|
||||
end
|
||||
|
||||
function PartNameToBodyLocationAmputation(name)
|
||||
local function PartNameToBodyLocationAmputation(name)
|
||||
if name == "Right_Hand" then return "TOC_ArmRight" end
|
||||
if name == "Right_LowerArm" then return "TOC_ArmRight" end
|
||||
if name == "Right_UpperArm" then return "TOC_ArmRight" end
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
------------- INIT FUNCTIONS -------------
|
||||
|
||||
if not TheOnlyCure then
|
||||
TheOnlyCure = {}
|
||||
end
|
||||
@@ -22,8 +27,6 @@ local function TocCutLimbForTrait(player, limbs_data, part_name)
|
||||
limbs_data[v].is_cicatrized = true
|
||||
end
|
||||
end
|
||||
|
||||
-- Sub function of TocSetInitData
|
||||
local function TocUpdateBaseData(mod_data)
|
||||
|
||||
-- TODO The prosthetic knife needs to be a weapon first and foremost, so other than a
|
||||
@@ -197,8 +200,6 @@ local function TocSetInitData(mod_data, player)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TheOnlyCure.InitTheOnlyCure(_, player)
|
||||
|
||||
local mod_data = player:getModData()
|
||||
@@ -211,8 +212,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TheOnlyCure.DeclareTraits()
|
||||
local function TocDeclareTraits()
|
||||
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8,
|
||||
getText("UI_trait_Amputee_Hand_desc"), false, false)
|
||||
amp1:addXPBoost(Perks.Left_Hand, 4)
|
||||
@@ -232,52 +232,6 @@ function TheOnlyCure.DeclareTraits()
|
||||
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
|
||||
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, part_name)
|
||||
elseif action == "Operate" then
|
||||
TocOperateLocal(_, surgeon, part_name, false)
|
||||
elseif action == "Equip" then
|
||||
TocEquipProsthesisLocal(_, surgeon, part_name)
|
||||
elseif action == "Unequip" then
|
||||
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
|
||||
AskCanEquipProsthesis(patient, part_name)
|
||||
elseif action == "Unequip" then
|
||||
AskCanUnequipProsthesis(patient, part_name)
|
||||
end
|
||||
|
||||
ui.actionAct = action
|
||||
ui.partNameAct = part_name
|
||||
ui.patient = patient
|
||||
|
||||
SendCommandToConfirmUIMP("Wait server")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
|
||||
Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits)
|
||||
Events.OnGameBoot.Add(TocDeclareTraits)
|
||||
@@ -58,7 +58,7 @@ function ISUninstallProsthesis:perform()
|
||||
|
||||
SendUnequipProsthesis(self.patient, self.part_name, self.item)
|
||||
else
|
||||
TheOnlyCure.UnequipProsthesis(self.patient, self.part_name, self.item)
|
||||
TheOnlyCure.TocUnequipProsthesis(self.patient, self.part_name, self.item)
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
|
||||
Reference in New Issue
Block a user