MODsuit Action Circuit Component (+ MODsuit circuit module fixes) (#63755)

This makes several small changes to the MODsuit circuit module:

Adds the MODsuit Action component. When selected, the circuit module opens a radial menu with which to select an action component to trigger.
Due to its similarity to the BCI Action component, both it and the BCI Action component have been made subtypes of an abstract equipment_action component that implements their shared functionality.
Renames the MOD component to the MOD circuit adapter core component.
Changes the "selected module" port on the MOD circuit adapter core to a string port, for consistency with the corresponding input port.
The circuit in the circuit module can be removed. Consequentually, the circuit module no longer comes with a pre-installed circuit.
The "Toggle Suit" signal port on the MOD circuit adapter core can now activate the modsuit.
Makes the circuit module printable in the component printer, for consistency.
Moves the circuit module's code to modules/wiremod, for consistency.
BCI action component properly typechecks the shell it's inserted in.
Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
This commit is contained in:
Y0SH1M4S73R
2022-01-25 22:54:08 +00:00
committed by GitHub
parent 7cdbcf4c2c
commit db94f78511
9 changed files with 259 additions and 190 deletions
-105
View File
@@ -55,111 +55,6 @@
return
to_chat(mod.wearer, span_notice("Explosion detected! Epicenter: [devastation_range], Outer: [heavy_impact_range], Shock: [light_impact_range]"))
//Circuit Adapter
/obj/item/mod/module/circuit
name = "MOD circuit adapter module"
desc = "A popular aftermarket module, seen in wide varieties with wide applications by those across the galaxy. \
This is able to fit any sort of integrated circuit, hooking it into controls in the suit and displaying information \
to the HUD. Useful for universal translation, or perhaps as a calculator."
module_type = MODULE_USABLE
complexity = 3
idle_power_cost = DEFAULT_CHARGE_DRAIN * 0.5
incompatible_modules = list(/obj/item/mod/module/circuit)
cooldown_time = 0.5 SECONDS
var/obj/item/integrated_circuit/circuit
/obj/item/mod/module/circuit/Initialize(mapload)
. = ..()
circuit = new()
AddComponent(/datum/component/shell, \
list(new /obj/item/circuit_component/mod()), \
capacity = SHELL_CAPACITY_LARGE, \
shell_flags = SHELL_FLAG_CIRCUIT_UNREMOVABLE, \
starting_circuit = circuit, \
)
/obj/item/mod/module/circuit/on_install()
circuit.set_cell(mod.get_cell())
/obj/item/mod/module/circuit/on_uninstall()
circuit.set_cell(mod.get_cell())
/obj/item/mod/module/circuit/on_suit_activation()
circuit.set_on(TRUE)
/obj/item/mod/module/circuit/on_suit_deactivation()
circuit.set_on(FALSE)
/obj/item/mod/module/circuit/on_use()
. = ..()
if(!.)
return
circuit.interact(mod.wearer)
/obj/item/circuit_component/mod
display_name = "MOD"
desc = "Used to send and receive signals from a MODsuit."
var/obj/item/mod/module/attached_module
var/datum/port/input/module_to_select
var/datum/port/input/toggle_suit
var/datum/port/input/select_module
var/datum/port/output/wearer
var/datum/port/output/selected_module
/obj/item/circuit_component/mod/populate_ports()
// Input Signals
module_to_select = add_input_port("Module to Select", PORT_TYPE_STRING)
toggle_suit = add_input_port("Toggle Suit", PORT_TYPE_SIGNAL)
select_module = add_input_port("Select Module", PORT_TYPE_SIGNAL)
// States
wearer = add_output_port("Wearer", PORT_TYPE_ATOM)
selected_module = add_output_port("Selected Module", PORT_TYPE_ATOM)
/obj/item/circuit_component/mod/register_shell(atom/movable/shell)
if(istype(shell, /obj/item/mod/module))
attached_module = shell
RegisterSignal(attached_module, COMSIG_MOVABLE_MOVED, .proc/on_move)
/obj/item/circuit_component/mod/unregister_shell(atom/movable/shell)
UnregisterSignal(attached_module, COMSIG_MOVABLE_MOVED)
attached_module = null
/obj/item/circuit_component/mod/input_received(datum/port/input/port)
var/obj/item/mod/module/module
for(var/obj/item/mod/module/potential_module as anything in attached_module.mod.modules)
if(potential_module.name == module_to_select.value)
module = potential_module
if(COMPONENT_TRIGGERED_BY(toggle_suit, port))
INVOKE_ASYNC(attached_module.mod, /obj/item/mod/control.proc/toggle_activate, attached_module.mod.wearer)
if(module && COMPONENT_TRIGGERED_BY(select_module, port))
INVOKE_ASYNC(module, /obj/item/mod/module.proc/on_select)
/obj/item/circuit_component/mod/proc/on_move(atom/movable/source, atom/old_loc, dir, forced)
SIGNAL_HANDLER
if(istype(source.loc, /obj/item/mod/control))
RegisterSignal(source.loc, COMSIG_MOD_MODULE_SELECTED, .proc/on_module_select)
RegisterSignal(source.loc, COMSIG_ITEM_EQUIPPED, .proc/equip_check)
equip_check()
else if(istype(old_loc, /obj/item/mod/control))
UnregisterSignal(old_loc, list(COMSIG_MOD_MODULE_SELECTED, COMSIG_ITEM_EQUIPPED))
selected_module.set_output(null)
wearer.set_output(null)
/obj/item/circuit_component/mod/proc/on_module_select()
SIGNAL_HANDLER
selected_module.set_output(attached_module.mod.selected_module)
/obj/item/circuit_component/mod/proc/equip_check()
SIGNAL_HANDLER
if(!attached_module.mod?.wearer)
return
wearer.set_output(attached_module.mod.wearer)
///Anti-Gravity - Makes the user weightless.
/obj/item/mod/module/anomaly_locked/antigrav
name = "MOD anti-gravity module"