[MIRROR] Circuit action button refactor [MDB IGNORE] (#25798)

* Circuit action button refactor (#80379)

## About The Pull Request

This PR makes several changes to how circuit action buttons work:
- The MOD action and BCI action components have been merged into a
single component.
- MOD circuit actions can be pinned from the configuration menu. This
works the same way as pinning individual modules, and can be done both
by the wearer and a suit AI.
- Action components have an output pin for the user of the action. This
allows MOD module circuits to distinguish between the wearer and an AI.
- Creates a supertype for `/datum/action/item_action/mod/pinned_module`
named `/datum/action/item_action/mod/pinnable`, which implements common
functionality for pinned modules and pinned circuit module actions.

## Why It's Good For The Game

The prior functionality of circuit MOD actions was somewhat unintuitive,
requiring the user to select an action from a radial menu *after*
activating the module, whether from a pinned action or from the module
radial. Providing similar pinning functionality to modules themselves
makes MOD actions more readily usable.

Merging the two different types of circuit components into one was made
with the idea that adding new types of shells with equipment actions
would inflate the number of subtypes of
`/obj/item/circuit_component/equipment_action` without adding much
meaningful functionality.

## Changelog

🆑
qol: MOD wearers and internal AIs can pin the individual actions in a
MOD circuit module in a similar way to how they can pin modules. Circuit
module actions can be pinned from the configuration menu of the circuit
refactor: The MOD action and BCI action components have been merged into
one component - the Equipment Action component.
/🆑

* Circuit action button refactor

---------

Co-authored-by: Y0SH1M4S73R <legoboyo@earthlink.net>
This commit is contained in:
SkyratBot
2023-12-24 01:26:25 +01:00
committed by GitHub
parent d0105dfe0f
commit 899063da95
13 changed files with 271 additions and 187 deletions
@@ -10,8 +10,11 @@
/obj/item/organ/internal/cyberimp/bci/Initialize(mapload)
. = ..()
RegisterSignal(src, COMSIG_CIRCUIT_ACTION_COMPONENT_REGISTERED, PROC_REF(action_comp_registered))
RegisterSignal(src, COMSIG_CIRCUIT_ACTION_COMPONENT_UNREGISTERED, PROC_REF(action_comp_unregistered))
var/obj/item/integrated_circuit/circuit = new(src)
circuit.add_component(new /obj/item/circuit_component/equipment_action/bci(null, "One"))
circuit.add_component(new /obj/item/circuit_component/equipment_action(null, "One"))
AddComponent(/datum/component/shell, list(
new /obj/item/circuit_component/bci_core,
@@ -33,41 +36,17 @@
else
return ..()
/obj/item/circuit_component/equipment_action/bci
display_name = "BCI Action"
desc = "Represents an action the user can take when implanted with the brain-computer interface."
required_shells = list(/obj/item/organ/internal/cyberimp/bci)
/obj/item/organ/internal/cyberimp/bci/proc/action_comp_registered(datum/source, obj/item/circuit_component/equipment_action/action_comp)
SIGNAL_HANDLER
LAZYADD(actions, new/datum/action/innate/bci_action(src, action_comp))
/// A reference to the action button itself
var/datum/action/innate/bci_action/bci_action
/obj/item/circuit_component/equipment_action/bci/Destroy()
QDEL_NULL(bci_action)
return ..()
/obj/item/circuit_component/equipment_action/bci/register_shell(atom/movable/shell)
. = ..()
var/obj/item/organ/internal/cyberimp/bci/bci = shell
if(istype(bci))
bci_action = new(src)
update_action()
bci.actions += list(bci_action)
/obj/item/circuit_component/equipment_action/bci/unregister_shell(atom/movable/shell)
var/obj/item/organ/internal/cyberimp/bci/bci = shell
if(istype(bci))
bci.actions -= bci_action
QDEL_NULL(bci_action)
return ..()
/obj/item/circuit_component/equipment_action/bci/input_received(datum/port/input/port)
if (!isnull(bci_action))
update_action()
/obj/item/circuit_component/equipment_action/bci/update_action()
bci_action.name = button_name.value
bci_action.button_icon_state = "bci_[replacetextEx(lowertext(icon_options.value), " ", "_")]"
/obj/item/organ/internal/cyberimp/bci/proc/action_comp_unregistered(datum/source, obj/item/circuit_component/equipment_action/action_comp)
SIGNAL_HANDLER
var/datum/action/innate/bci_action/action = action_comp.granted_to[REF(src)]
if(!istype(action))
return
LAZYREMOVE(actions, action)
QDEL_LIST_ASSOC_VAL(action_comp.granted_to)
/datum/action/innate/bci_action
name = "Action"
@@ -75,20 +54,23 @@
check_flags = AB_CHECK_CONSCIOUS
button_icon_state = "bci_power"
var/obj/item/circuit_component/equipment_action/bci/circuit_component
var/obj/item/organ/internal/cyberimp/bci/bci
var/obj/item/circuit_component/equipment_action/circuit_component
/datum/action/innate/bci_action/New(obj/item/circuit_component/equipment_action/bci/circuit_component)
/datum/action/innate/bci_action/New(obj/item/organ/internal/cyberimp/bci/_bci, obj/item/circuit_component/equipment_action/circuit_component)
..()
bci = _bci
circuit_component.granted_to[REF(_bci)] = src
src.circuit_component = circuit_component
/datum/action/innate/bci_action/Destroy()
circuit_component.bci_action = null
circuit_component.granted_to -= REF(bci)
circuit_component = null
return ..()
/datum/action/innate/bci_action/Activate()
circuit_component.user.set_output(owner)
circuit_component.signal.set_output(COMPONENT_SIGNAL)
/obj/item/circuit_component/bci_core