/
equpiment_action.dm
92 lines (74 loc) · 2.31 KB
/
equpiment_action.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/obj/item/circuit_component/equipment_action
display_name = "Equipment Action"
desc = "Represents an action the user can take when using supported shells."
required_shells = list(/obj/item/organ/internal/cyberimp/bci, /obj/item/mod/module/circuit)
/// The icon of the button
var/datum/port/input/option/icon_options
/// The name to use for the button
var/datum/port/input/button_name
/// The mob who activated their granted action
var/datum/port/output/user
/// Called when the user presses the button
var/datum/port/output/signal
/// An assoc list of datum REF()s, linked to the actions granted.
var/list/granted_to = list()
/obj/item/circuit_component/equipment_action/Initialize(mapload, default_icon)
. = ..()
if (!isnull(default_icon))
icon_options.set_input(default_icon)
button_name = add_input_port("Name", PORT_TYPE_STRING)
user = add_output_port("User", PORT_TYPE_USER)
signal = add_output_port("Signal", PORT_TYPE_SIGNAL)
/obj/item/circuit_component/equipment_action/Destroy()
QDEL_LIST_ASSOC_VAL(granted_to)
return ..()
/obj/item/circuit_component/equipment_action/populate_options()
var/static/action_options = list(
"Blank",
"One",
"Two",
"Three",
"Four",
"Five",
"Blood",
"Bomb",
"Brain",
"Brain Damage",
"Cross",
"Electricity",
"Exclamation",
"Heart",
"Id",
"Info",
"Injection",
"Magnetism",
"Minus",
"Network",
"Plus",
"Power",
"Question",
"Radioactive",
"Reaction",
"Repair",
"Say",
"Scan",
"Shield",
"Skull",
"Sleep",
"Wireless",
)
icon_options = add_option_port("Icon", action_options)
/obj/item/circuit_component/equipment_action/register_shell(atom/movable/shell)
. = ..()
SEND_SIGNAL(shell, COMSIG_CIRCUIT_ACTION_COMPONENT_REGISTERED, src)
/obj/item/circuit_component/equipment_action/unregister_shell(atom/movable/shell)
. = ..()
SEND_SIGNAL(shell, COMSIG_CIRCUIT_ACTION_COMPONENT_UNREGISTERED, src)
/obj/item/circuit_component/equipment_action/input_received(datum/port/input/port)
if (length(granted_to))
update_actions()
/obj/item/circuit_component/equipment_action/proc/update_actions()
for(var/ref in granted_to)
var/datum/action/granted_action = granted_to[ref]
granted_action.name = button_name.value || "Action"
granted_action.button_icon_state = "bci_[replacetextEx(LOWER_TEXT(icon_options.value), " ", "_")]"