mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-21 15:42:35 +00:00
pAIs, Computers and ntIRC (#8757)
#8005 just revived. Tasks to acomplish while here: Fix merge conflicts Add ntIRC direct messaging Things I migth consider adding in future PR: Porting IRC to VueUI Porting File Manager to VueUI.
This commit is contained in:
@@ -33,6 +33,15 @@
|
||||
else
|
||||
idle_threads.Remove(P)
|
||||
|
||||
for(var/s in enabled_services)
|
||||
var/datum/computer_file/program/service = s
|
||||
if(service.program_type & PROGRAM_SERVICE) // Safety checks
|
||||
if(service.service_state == PROGRAM_STATE_ACTIVE)
|
||||
if(active_program != service && !(service in idle_threads))
|
||||
service.process_tick()
|
||||
else
|
||||
enabled_services -= service
|
||||
|
||||
working = hard_drive && processor_unit && damage < broken_damage && computer_use_power()
|
||||
check_update_ui_need()
|
||||
|
||||
@@ -169,6 +178,13 @@
|
||||
for(var/datum/computer_file/program/P in idle_threads)
|
||||
P.kill_program(TRUE)
|
||||
idle_threads.Remove(P)
|
||||
|
||||
for(var/s in enabled_services)
|
||||
var/datum/computer_file/program/service = s
|
||||
if(service.program_type & PROGRAM_SERVICE) // Safety checks
|
||||
service.service_deactivate()
|
||||
service.service_state = PROGRAM_STATE_KILLED
|
||||
|
||||
if(loud)
|
||||
visible_message(SPAN_NOTICE("\The [src] shuts down."))
|
||||
SSvueui.close_uis(src)
|
||||
@@ -182,7 +198,13 @@
|
||||
// Autorun feature
|
||||
var/datum/computer_file/data/autorun = hard_drive ? hard_drive.find_file_by_name("autorun") : null
|
||||
if(istype(autorun))
|
||||
run_program(autorun.stored_data)
|
||||
run_program(autorun.stored_data, user)
|
||||
|
||||
for(var/s in enabled_services)
|
||||
var/datum/computer_file/program/service = s
|
||||
if(service.program_type & PROGRAM_SERVICE) // Safety checks
|
||||
service.service_activate()
|
||||
service.service_state = PROGRAM_STATE_ACTIVE
|
||||
|
||||
if(user)
|
||||
ui_interact(user)
|
||||
@@ -201,9 +223,10 @@
|
||||
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
|
||||
|
||||
|
||||
/obj/item/modular_computer/proc/run_program(prog)
|
||||
/obj/item/modular_computer/proc/run_program(prog, mob/user)
|
||||
var/datum/computer_file/program/P = null
|
||||
var/mob/user = usr
|
||||
if(!istype(user))
|
||||
user = usr
|
||||
if(hard_drive)
|
||||
P = hard_drive.find_file_by_name(prog)
|
||||
|
||||
@@ -294,6 +317,58 @@
|
||||
/obj/item/modular_computer/get_cell()
|
||||
return battery_module ? battery_module.get_cell() : DEVICE_NO_CELL
|
||||
|
||||
/obj/item/modular_computer/proc/toggle_service(service, mob/user, var/datum/computer_file/program/S = null)
|
||||
if(!S)
|
||||
S = hard_drive?.find_file_by_name(service)
|
||||
|
||||
if(!istype(S)) // Program not found or it's not executable program.
|
||||
to_chat(user, SPAN_WARNING("\The [src] displays, \"I/O ERROR - Unable to locate [service]\""))
|
||||
return
|
||||
|
||||
if(S.service_state == PROGRAM_STATE_ACTIVE)
|
||||
disable_service(null, user, S)
|
||||
else
|
||||
enable_service(null, user, S)
|
||||
|
||||
|
||||
/obj/item/modular_computer/proc/enable_service(service, mob/user, var/datum/computer_file/program/S = null)
|
||||
if(!S)
|
||||
S = hard_drive?.find_file_by_name(service)
|
||||
|
||||
if(!istype(S)) // Program not found or it's not executable program.
|
||||
to_chat(user, SPAN_WARNING("\The [src] displays, \"I/O ERROR - Unable to enable [service]\""))
|
||||
return
|
||||
|
||||
S.computer = src
|
||||
|
||||
if(!S.is_supported_by_hardware(hardware_flag, 1, user))
|
||||
return
|
||||
|
||||
if(S in enabled_services)
|
||||
return
|
||||
|
||||
enabled_services += S
|
||||
|
||||
// Start service
|
||||
S.service_activate()
|
||||
S.service_state = PROGRAM_STATE_ACTIVE
|
||||
|
||||
|
||||
/obj/item/modular_computer/proc/disable_service(service, mob/user, var/datum/computer_file/program/S = null)
|
||||
if(!S)
|
||||
S = hard_drive?.find_file_by_name(service)
|
||||
|
||||
if(!istype(S)) // Program not found or it's not executable program.
|
||||
return
|
||||
|
||||
if(!(S in enabled_services))
|
||||
return
|
||||
enabled_services -= S
|
||||
|
||||
// Stop service
|
||||
S.service_deactivate()
|
||||
S.service_state = PROGRAM_STATE_KILLED
|
||||
|
||||
/obj/item/modular_computer/proc/output_message(var/message, var/message_range)
|
||||
message_range += message_output_range
|
||||
if(message_range == 0)
|
||||
@@ -301,4 +376,4 @@
|
||||
if(istype(user))
|
||||
to_chat(user, message)
|
||||
return
|
||||
visible_message(message, range = message_range)
|
||||
visible_message(message, range = message_range)
|
||||
|
||||
@@ -51,6 +51,10 @@
|
||||
VUEUI_SET_CHECK(data["programs"][P.filename]["desc"], P.filedesc, ., data)
|
||||
VUEUI_SET_CHECK(data["programs"][P.filename]["autorun"], (istype(autorun) && (autorun.stored_data == P.filename)), ., data)
|
||||
VUEUI_SET_CHECK(data["programs"][P.filename]["running"], (P in idle_threads), ., data)
|
||||
VUEUI_SET_CHECK(data["programs"][P.filename]["type"], P.program_type, ., data)
|
||||
VUEUI_SET_CHECK_IFNOTSET(data["programs"][P.filename]["service"], list(), ., data)
|
||||
VUEUI_SET_CHECK(data["programs"][P.filename]["service"]["enabled"], (P in enabled_services), ., data)
|
||||
VUEUI_SET_CHECK(data["programs"][P.filename]["service"]["online"], (P.service_state == PROGRAM_STATE_ACTIVE), ., data)
|
||||
|
||||
// Handles user's GUI input
|
||||
/obj/item/modular_computer/Topic(href, href_list)
|
||||
@@ -90,8 +94,8 @@
|
||||
update_uis()
|
||||
to_chat(user, SPAN_NOTICE("Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed."))
|
||||
|
||||
if(href_list["PC_runprogram"])
|
||||
. = run_program(href_list["PC_runprogram"])
|
||||
if(href_list["PC_runprogram"] )
|
||||
. = run_program(href_list["PC_runprogram"], usr)
|
||||
ui_interact(usr)
|
||||
|
||||
if(href_list["PC_setautorun"])
|
||||
@@ -106,6 +110,10 @@
|
||||
autorun.stored_data = null
|
||||
else
|
||||
autorun.stored_data = href_list["PC_setautorun"]
|
||||
|
||||
if( href_list["PC_toggleservice"] )
|
||||
toggle_service(href_list["PC_toggleservice"], usr)
|
||||
return 1
|
||||
|
||||
if(.)
|
||||
update_uis()
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
var/steel_sheet_cost = 5 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
|
||||
var/light_strength = 0 // Intensity of light this computer emits. Comparable to numbers light fixtures use.
|
||||
var/list/idle_threads = list() // Idle programs on background. They still receive process calls but can't be interacted with.
|
||||
var/list/enabled_services = list() // Enabled services that run in background and handle things pasively. Supported on all CPUs.
|
||||
var/power_has_failed = FALSE
|
||||
var/is_holographic = FALSE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user