-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
robocontrol.dm
92 lines (82 loc) · 3.52 KB
/
robocontrol.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
/datum/computer_file/program/robocontrol
filename = "robocontrol"
filedesc = "Bot Remote Controller"
category = PROGRAM_CATEGORY_SCIENCE
program_icon_state = "robot"
extended_desc = "A remote controller used for giving basic commands to non-sentient robots."
requires_ntnet = TRUE
network_destination = "robotics control network"
size = 12
tgui_id = "NtosRoboControl"
program_icon = "robot"
///Number of simple robots on-station.
var/botcount = 0
///Used to find the location of the user for the purposes of summoning robots.
var/mob/current_user
///Access granted by the used to summon robots.
var/list/current_access = list()
/datum/computer_file/program/robocontrol/ui_data(mob/user)
var/list/data = get_header_data()
var/turf/current_turf = get_turf(ui_host())
var/zlevel = current_turf.z
var/list/botlist = list()
var/list/mulelist = list()
var/obj/item/computer_hardware/card_slot/card_slot = computer ? computer.all_components[MC_CARD] : null
data["have_id_slot"] = !!card_slot
if(computer)
var/obj/item/card/id/id_card = card_slot ? card_slot.stored_card : null
data["has_id"] = !!id_card
data["id_owner"] = id_card ? id_card.registered_name : "No Card Inserted."
data["access_on_card"] = id_card ? id_card.access : null
botcount = 0
current_user = user
for(var/B in GLOB.bots_list)
var/mob/living/simple_animal/bot/Bot = B
if(Bot.z != zlevel || Bot.remote_disabled || !Bot.bot_core.check_access(computer))
continue //Only non-emagged bots on the same Z-level are detected! Also, the PDA must have access to the bot type.
var/list/newbot = list("name" = Bot.name, "mode" = Bot.get_mode_ui(), "model" = Bot.model, "locat" = get_area(Bot), "bot_ref" = REF(Bot), "mule_check" = FALSE, "enabled" = Bot.on)
if(Bot.bot_type == MULE_BOT)
var/mob/living/simple_animal/bot/mulebot/MULE = Bot
mulelist += list(list("name" = MULE.name, "dest" = MULE.destination, "power" = MULE.cell ? MULE.cell.percent() : 0, "home" = MULE.home_destination, "autoReturn" = MULE.auto_return, "autoPickup" = MULE.auto_pickup, "reportDelivery" = MULE.report_delivery, "mule_ref" = REF(MULE)))
if(MULE.load)
data["load"] = MULE.load.name
newbot["mule_check"] = TRUE
botlist += list(newbot)
data["bots"] = botlist
data["mules"] = mulelist
data["botcount"] = botlist.len
return data
/datum/computer_file/program/robocontrol/ui_act(action, list/params)
if(..())
return TRUE
var/obj/item/computer_hardware/card_slot/card_slot
var/obj/item/card/id/id_card
if(computer)
computer.play_interact_sound()
card_slot = computer.all_components[MC_CARD]
if(card_slot)
id_card = card_slot.stored_card
var/list/standard_actions = list("patroloff", "patrolon", "ejectpai")
var/list/MULE_actions = list("stop", "go", "home", "destination", "setid", "sethome", "unload", "autoret", "autopick", "report", "ejectpai")
var/mob/living/simple_animal/bot/Bot = locate(params["robot"]) in GLOB.bots_list
if (action in standard_actions)
Bot.bot_control(action, current_user, current_access)
if (action in MULE_actions)
Bot.bot_control(action, current_user, current_access, TRUE)
switch(action)
if("toggle")
if(Bot.on)
Bot.turn_off()
else
Bot.turn_on()
if("summon")
Bot.bot_control(action, current_user, id_card ? id_card.access : current_access)
if("ejectcard")
if(!computer || !card_slot)
return
if(id_card)
GLOB.data_core.manifest_modify(id_card.registered_name, id_card.assignment)
card_slot.try_eject(current_user)
else
playsound(get_turf(ui_host()) , 'sound/machines/buzz-sigh.ogg', 25, FALSE)
return