-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathconsole.dm
265 lines (245 loc) · 8.42 KB
/
console.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/obj/machinery/computer/cargo
name = "supply console"
desc = "Used to order supplies, approve requests, and control the shuttle."
icon_screen = "supply"
circuit = /obj/item/circuitboard/computer/cargo
light_color = "#E2853D"//orange
///Can the supply console send the shuttle back and forth? Used in the UI backend.
var/can_send = TRUE
///Can this console only send requests?
var/requestonly = FALSE
///Can you approve requests placed for cargo? Works differently between the app and the computer.
var/can_approve_requests = TRUE
var/contraband = FALSE
var/safety_warning = "For safety reasons, the automated supply shuttle \
cannot transport live organisms, human remains, classified nuclear weaponry, \
homing beacons or pneumatic disposal segments. Additionally, remove any privately ordered crates from the shuttle."
var/blockade_warning = "Bluespace instability detected. Shuttle movement impossible."
var/self_paid = FALSE
/obj/machinery/computer/cargo/request
name = "supply request console"
desc = "Used to request supplies from cargo."
icon_screen = "request"
circuit = /obj/item/circuitboard/computer/cargo/request
requestonly = TRUE
can_send = FALSE
can_approve_requests = FALSE
/obj/machinery/computer/cargo/Initialize(mapload)
. = ..()
var/obj/item/circuitboard/computer/cargo/board = circuit
contraband = board.contraband
if (board.obj_flags & EMAGGED)
obj_flags |= EMAGGED
else
obj_flags &= ~EMAGGED
/obj/machinery/computer/cargo/proc/get_export_categories()
. = EXPORT_CARGO
if(contraband)
. |= EXPORT_CONTRABAND
if(obj_flags & EMAGGED)
. |= EXPORT_EMAG
/obj/machinery/computer/cargo/emag_act(mob/user, obj/item/card/emag/emag_card)
if(obj_flags & EMAGGED)
return FALSE
user.visible_message(span_warning("[user] swipes a suspicious card through [src]!"),
span_notice("You adjust [src]'s routing and receiver spectrum, unlocking special supplies and contraband."))
obj_flags |= EMAGGED
contraband = TRUE
// This also permamently sets this on the circuit board
var/obj/item/circuitboard/computer/cargo/board = circuit
board.contraband = TRUE
board.obj_flags |= EMAGGED
update_static_data(user)
return TRUE
/obj/machinery/computer/cargo/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Cargo", name)
ui.open()
/obj/machinery/computer/cargo/ui_data()
var/list/data = list()
data["location"] = SSshuttle.supply.getStatusText()
var/datum/bank_account/D = SSeconomy.get_dep_account(ACCOUNT_CAR)
if(D)
data["points"] = D.account_balance
data["away"] = SSshuttle.supply.getDockedId() == "supply_away"
data["self_paid"] = self_paid
data["docked"] = SSshuttle.supply.mode == SHUTTLE_IDLE
data["loan"] = !!SSshuttle.shuttle_loan
data["loan_dispatched"] = SSshuttle.shuttle_loan && SSshuttle.shuttle_loan.dispatched
data["can_send"] = can_send
data["can_approve_requests"] = can_approve_requests
var/message = "Remember to stamp and send back the supply manifests."
if(SSshuttle.centcom_message)
message = SSshuttle.centcom_message
if(SSshuttle.supply_blocked)
message = blockade_warning
data["message"] = message
data["cart"] = list()
for(var/datum/supply_order/SO in SSshuttle.shopping_list)
data["cart"] += list(list(
"object" = SO.pack.name,
"cost" = SO.pack.get_cost(),
"id" = SO.id,
"orderer" = SO.orderer,
"paid" = !isnull(SO.paying_account), //paid by requester
"budget" = SO.budget
))
data["requests"] = list()
for(var/datum/supply_order/SO in SSshuttle.request_list)
data["requests"] += list(list(
"object" = SO.pack.name,
"cost" = SO.pack.get_cost(),
"orderer" = SO.orderer,
"reason" = SO.reason,
"id" = SO.id,
"budget" = SO.budget
))
return data
/obj/machinery/computer/cargo/ui_static_data(mob/user)
var/list/data = list()
data["requestonly"] = requestonly
data["supplies"] = list()
for(var/pack in SSshuttle.supply_packs)
var/datum/supply_pack/P = SSshuttle.supply_packs[pack]
if(!data["supplies"][P.group])
data["supplies"][P.group] = list(
"name" = P.group,
"packs" = list()
)
if((P.hidden && !(obj_flags & EMAGGED)) || (P.contraband && !contraband) || (P.special && !P.special_enabled) || P.DropPodOnly)
continue
data["supplies"][P.group]["packs"] += list(list(
"name" = P.name,
"cost" = P.get_cost(),
"id" = pack,
"desc" = P.desc || P.name, // If there is a description, use it. Otherwise use the pack's name.
"small_item" = P.small_item,
"access" = P.access
))
return data
/obj/machinery/computer/cargo/ui_act(action, params, datum/tgui/ui)
if(..())
return
switch(action)
if("send")
if(!SSshuttle.supply.canMove())
say(safety_warning)
return
if(SSshuttle.supply_blocked)
say(blockade_warning)
return
if(SSshuttle.supply.getDockedId() == "supply_home")
SSshuttle.supply.export_categories = get_export_categories()
SSshuttle.moveShuttle("supply", "supply_away", TRUE)
say("The supply shuttle is departing.")
investigate_log("[key_name(usr)] sent the supply shuttle away.", INVESTIGATE_CARGO)
else
investigate_log("[key_name(usr)] called the supply shuttle.", INVESTIGATE_CARGO)
var/call_time = SSshuttle.supply.timeLeft(10) //how many seconds
var/unit = "seconds"
if(call_time >= 60) //if more than 60 seconds,
call_time = SSshuttle.supply.timeLeft(600) //go to minutes instead
unit = "minute"
if(call_time > 1) //handles more than 1 minute
unit = "minutes"
say("The supply shuttle has been called and will arrive in [call_time] [unit].")
SSshuttle.moveShuttle("supply", "supply_home", TRUE)
. = TRUE
if("loan")
if(!SSshuttle.shuttle_loan)
return
if(SSshuttle.supply_blocked)
say(blockade_warning)
return
else if(SSshuttle.supply.mode != SHUTTLE_IDLE)
return
else if(SSshuttle.supply.getDockedId() != "supply_away")
return
else
SSshuttle.shuttle_loan.loan_shuttle()
say("The supply shuttle has been loaned to CentCom.")
. = TRUE
if("add")
var/id = text2path(params["id"])
var/self_paid = text2num(params["self_paid"])
var/datum/supply_pack/pack = SSshuttle.supply_packs[id]
if(!istype(pack))
return
if((pack.hidden && !(obj_flags & EMAGGED)) || (pack.contraband && !contraband) || pack.DropPodOnly)
return
var/name = "*None Provided*"
var/rank = "*None Provided*"
var/ckey = usr.ckey
if(ishuman(usr))
var/mob/living/carbon/human/H = usr
name = H.get_authentification_name()
rank = H.get_assignment(hand_first = TRUE)
else if(issilicon(usr))
name = usr.real_name
rank = "Silicon"
var/datum/bank_account/account
if(self_paid && ishuman(usr))
var/mob/living/carbon/human/H = usr
var/obj/item/card/id/id_card = H.get_idcard(TRUE)
if(!istype(id_card))
say("No ID card detected.")
return
account = id_card.registered_account
if(!istype(account))
say("Invalid bank account.")
return
var/reason = ""
if(requestonly && !self_paid)
reason = stripped_input("Reason:", name, "")
if(isnull(reason) || ..())
return
var/turf/T = get_turf(src)
var/datum/supply_order/SO = new(pack, name, rank, ckey, reason, account)
SO.generateRequisition(T)
if(requestonly && !self_paid)
SSshuttle.request_list += SO
else
SSshuttle.shopping_list += SO
if(self_paid)
say("Order processed. The price will be charged to [account.account_holder]'s bank account on delivery.")
. = TRUE
if("remove")
var/id = text2num(params["id"])
for(var/datum/supply_order/SO in SSshuttle.shopping_list)
if(SO.id == id)
SSshuttle.shopping_list -= SO
. = TRUE
break
if("clear")
SSshuttle.shopping_list.Cut()
. = TRUE
if("approve")
var/id = text2num(params["id"])
for(var/datum/supply_order/SO in SSshuttle.request_list)
if(SO.id == id)
SSshuttle.request_list -= SO
SSshuttle.shopping_list += SO
. = TRUE
break
if("deny")
var/id = text2num(params["id"])
for(var/datum/supply_order/SO in SSshuttle.request_list)
if(SO.id == id)
SSshuttle.request_list -= SO
. = TRUE
break
if("denyall")
SSshuttle.request_list.Cut()
. = TRUE
if("toggleprivate")
self_paid = !self_paid
. = TRUE
if(.)
post_signal("supply")
/obj/machinery/computer/cargo/proc/post_signal(command)
var/datum/radio_frequency/frequency = SSradio.return_frequency(FREQ_STATUS_DISPLAYS)
if(!frequency)
return
var/datum/signal/status_signal = new(list("command" = command))
frequency.post_signal(src, status_signal)