Add quick access

Now we're telepathic
This commit is contained in:
2025-03-31 11:57:43 +02:00
parent b7d4531ec8
commit f21d288525
2 changed files with 94 additions and 1 deletions

View File

@@ -22,6 +22,8 @@ MyModGlobal = {
LOOT = Keys.L,
SONAR = Keys.X,
AOEPICKUP = Keys.Y,
QICK_FABRICATOR = Keys.K,
QICK_DECONSTRUCTOR = Keys.J,
NESTED_CONTAINERS = true,
DEBUG_MODE = true,
},
@@ -67,6 +69,7 @@ local quickreload= require("Cyka.quickreload")
local quickloot = require("Cyka.quickloot")
local sonarpinger = require("Cyka.sonarpinger")
local aoepickup = require("Cyka.aoepickup")
local quickaccess = require("Cyka.quickaccess")
require("Cyka.xpticker")
require("Cyka.zoom")
@@ -160,3 +163,13 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.AOEPICKUP) then return end
aoepickup.tryAoePickup()
end, Hook.HookMethodType.After)
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_FABRICATOR) then return end
quickaccess.tryAccessFabricator()
end, Hook.HookMethodType.After)
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_DECONSTRUCTOR) then return end
quickaccess.tryAccessDeconstructor()
end, Hook.HookMethodType.After)

View File

@@ -0,0 +1,80 @@
-- luacheck: globals MyModGlobal Character
local utils = require "Cyka.utils"
local dump = require "Cyka.dump"
local function tryAccessFabricator()
local items = utils.enqueueAllSubmarineItems({}, function(item)
return item.Prefab.Identifier.Value == "fabricator", item.Prefab.Identifier.Value == "fabricator"
end)
if #items == 0 then
MyModGlobal.debugPrint("No fabricator found")
return
end
if #items > 1 then
MyModGlobal.debugPrint("Multiple fabricators found, using first one")
end
---@type Barotrauma.Item
local fabricator = items[1]
---@type Barotrauma.Items.Components.Fabricator
local fabricatorComponent
for component in fabricator.Components do
if component.Name == "Fabricator" then
fabricatorComponent = component
end
end
if not fabricatorComponent then
MyModGlobal.debugPrint("No fabricator component found")
return
end
local me = Character.Controlled
if not me then
MyModGlobal.debugPrint("No controlled character found")
return
end
MyModGlobal.debugPrint("Selecting fabricator")
-- fabricatorComponent.Select(me)
me.SelectedItem = fabricator
end
local function tryAccessDeconstructor()
local items = utils.enqueueAllSubmarineItems({}, function(item)
return item.Prefab.Identifier.Value == "deconstructor", item.Prefab.Identifier.Value == "deconstructor"
end)
if #items == 0 then
MyModGlobal.debugPrint("No deconstructor found")
return
end
if #items > 1 then
MyModGlobal.debugPrint("Multiple deconstructors found, using first one")
end
---@type Barotrauma.Item
local deconstructor = items[1]
---@type Barotrauma.Items.Components.Deconstructor
local deconstructorComponent
for component in deconstructor.Components do
if component.Name == "Deconstructor" then
deconstructorComponent = component
end
end
if not deconstructorComponent then
MyModGlobal.debugPrint("No deconstructor component found")
return
end
local me = Character.Controlled
if not me then
MyModGlobal.debugPrint("No controlled character found")
return
end
MyModGlobal.debugPrint("Selecting deconstructor")
-- deconstructorComponent.Select(me)
me.SelectedItem = deconstructor
end
return {
tryAccessFabricator = tryAccessFabricator,
tryAccessDeconstructor = tryAccessDeconstructor,
}