mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
Ports the Bot Control PDA program to Modular Computers. (#50351)
* Startwork. * Time to break this later * How do I map lists again * So close I can almost TASTE ITTTT I GOTTA GET A MOVE ON WITH MY LIIIIFE * Hey, it almost works! * Finally actually ready to PR * Nothing to see here but documentation and dead code * Take 2. * Revert "Take 2." This reverts commit 0882d96a30ba79ebead4b5dd3e6f32e65bbf2a76. * Cleans up tgui compile errors. * WIP changes, still not happy with this for now. * I am satisified. * Rework that UI Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor())
|
||||
hard_drive.store_file(new/datum/computer_file/program/chatclient())
|
||||
hard_drive.store_file(new/datum/computer_file/program/aidiag())
|
||||
hard_drive.store_file(new/datum/computer_file/program/robocontrol())
|
||||
|
||||
|
||||
// ===== COMMAND CONSOLE =====
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
/datum/computer_file/program/robocontrol
|
||||
filename = "robocontrol"
|
||||
filedesc = "Bot Remote Controller"
|
||||
program_icon_state = "robot"
|
||||
extended_desc = "A remote controller used for giving basic commands to non-sentient robots."
|
||||
transfer_access = ACCESS_ROBOTICS
|
||||
requires_ntnet = TRUE
|
||||
network_destination = "robotics control network"
|
||||
size = 12
|
||||
tgui_id = "ntos_robocontrol"
|
||||
ui_x = 550
|
||||
ui_y = 550
|
||||
///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.on || Bot.z != zlevel || Bot.remote_disabled) //Only non-emagged bots on the same Z-level are detected!
|
||||
continue //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)
|
||||
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)
|
||||
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("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(TRUE, current_user)
|
||||
else
|
||||
playsound(get_turf(ui_host()) , 'sound/machines/buzz-sigh.ogg', 25, FALSE)
|
||||
return
|
||||
Reference in New Issue
Block a user