mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-14 01:24:21 +01:00
NTOS Signaler Modular App and hardware part (#58895)
Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
This commit is contained in:
@@ -20,6 +20,17 @@
|
||||
install_component(new /obj/item/computer_hardware/card_slot)
|
||||
install_component(new /obj/item/computer_hardware/printer/mini)
|
||||
|
||||
/obj/item/modular_computer/tablet/preset/science/Initialize()
|
||||
. = ..()
|
||||
var/obj/item/computer_hardware/hard_drive/small/hard_drive = new
|
||||
install_component(new /obj/item/computer_hardware/processor_unit/small)
|
||||
install_component(new /obj/item/computer_hardware/battery(src, /obj/item/stock_parts/cell/computer))
|
||||
install_component(hard_drive)
|
||||
install_component(new /obj/item/computer_hardware/card_slot)
|
||||
install_component(new /obj/item/computer_hardware/network_card)
|
||||
install_component(new /obj/item/computer_hardware/radio_card)
|
||||
hard_drive.store_file(new /datum/computer_file/program/signaler)
|
||||
|
||||
/obj/item/modular_computer/tablet/preset/cargo/Initialize()
|
||||
. = ..()
|
||||
var/obj/item/computer_hardware/hard_drive/small/hard_drive = new
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/datum/computer_file/program/signaler
|
||||
filename = "signaler"
|
||||
filedesc = "SignalCommander"
|
||||
category = PROGRAM_CATEGORY_MISC
|
||||
program_icon_state = "signal"
|
||||
extended_desc = "A small built-in frequency app that sends out signaller signals with the appropriate hardware."
|
||||
size = 2
|
||||
tgui_id = "NtosSignaler"
|
||||
program_icon = "satellite-dish"
|
||||
usage_flags = PROGRAM_TABLET | PROGRAM_LAPTOP
|
||||
///What is the saved signal frequency?
|
||||
var/signal_frequency = FREQ_SIGNALER
|
||||
/// What is the saved signal code?
|
||||
var/signal_code = DEFAULT_SIGNALER_CODE
|
||||
/// Radio connection datum used by signalers.
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
/datum/computer_file/program/signaler/run_program(mob/living/user)
|
||||
. = ..()
|
||||
if (!.)
|
||||
return
|
||||
if(!computer?.get_modular_computer_part(MC_SIGNALER)) //Giving a clue to users why the program is spitting out zeros.
|
||||
to_chat(user, "<span class='warning'>\The [computer] flashes an error: \"hardware\\signal_hardware\\startup.bin -- file not found\".</span>")
|
||||
|
||||
|
||||
/datum/computer_file/program/signaler/ui_data(mob/user)
|
||||
var/list/data = get_header_data()
|
||||
var/obj/item/computer_hardware/radio_card/sensor = computer?.get_modular_computer_part(MC_SIGNALER)
|
||||
if(sensor?.check_functionality())
|
||||
data["frequency"] = signal_frequency
|
||||
data["code"] = signal_code
|
||||
data["minFrequency"] = MIN_FREE_FREQ
|
||||
data["maxFrequency"] = MAX_FREE_FREQ
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/signaler/ui_act(action, list/params)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/obj/item/computer_hardware/radio_card/sensor = computer?.get_modular_computer_part(MC_SIGNALER)
|
||||
if(!(sensor?.check_functionality()))
|
||||
playsound(src, 'sound/machines/scanbuzz.ogg', 100, FALSE)
|
||||
return
|
||||
switch(action)
|
||||
if("signal")
|
||||
INVOKE_ASYNC(src, .proc/signal)
|
||||
. = TRUE
|
||||
if("freq")
|
||||
signal_frequency = unformat_frequency(params["freq"])
|
||||
signal_frequency = sanitize_frequency(signal_frequency, TRUE)
|
||||
set_frequency(signal_frequency)
|
||||
. = TRUE
|
||||
if("code")
|
||||
signal_code = text2num(params["code"])
|
||||
signal_code = round(signal_code)
|
||||
. = TRUE
|
||||
if("reset")
|
||||
if(params["reset"] == "freq")
|
||||
signal_frequency = initial(signal_frequency)
|
||||
else
|
||||
signal_code = initial(signal_code)
|
||||
. = TRUE
|
||||
|
||||
/datum/computer_file/program/signaler/proc/signal()
|
||||
if(!radio_connection)
|
||||
return
|
||||
|
||||
var/time = time2text(world.realtime,"hh:mm:ss")
|
||||
var/turf/T = get_turf(src)
|
||||
|
||||
var/logging_data
|
||||
if(usr)
|
||||
logging_data = "[time] <B>:</B> [usr.key] used [src] @ location ([T.x],[T.y],[T.z]) <B>:</B> [format_frequency(signal_frequency)]/[signal_code]"
|
||||
GLOB.lastsignalers.Add(logging_data)
|
||||
|
||||
var/datum/signal/signal = new(list("code" = signal_code), logging_data = logging_data)
|
||||
radio_connection.post_signal(src, signal)
|
||||
|
||||
/datum/computer_file/program/signaler/proc/set_frequency(new_frequency)
|
||||
SSradio.remove_object(src, signal_frequency)
|
||||
signal_frequency = new_frequency
|
||||
radio_connection = SSradio.add_object(src, signal_frequency, RADIO_SIGNALER)
|
||||
return
|
||||
@@ -9,17 +9,29 @@
|
||||
var/obj/item/modular_computer/holder = null
|
||||
// Computer that holds this hardware, if any.
|
||||
|
||||
var/power_usage = 0 // If the hardware uses extra power, change this.
|
||||
var/enabled = TRUE // If the hardware is turned off set this to 0.
|
||||
var/critical = FALSE // Prevent disabling for important component, like the CPU.
|
||||
var/can_install = TRUE // Prevents direct installation of removable media.
|
||||
var/expansion_hw = FALSE // Hardware that fits into expansion bays.
|
||||
var/removable = TRUE // Whether the hardware is removable or not.
|
||||
var/damage = 0 // Current damage level
|
||||
var/max_damage = 100 // Maximal damage level.
|
||||
var/damage_malfunction = 20 // "Malfunction" threshold. When damage exceeds this value the hardware piece will semi-randomly fail and do !!FUN!! things
|
||||
var/damage_failure = 50 // "Failure" threshold. When damage exceeds this value the hardware piece will not work at all.
|
||||
var/malfunction_probability = 10// Chance of malfunction when the component is damaged
|
||||
// If the hardware uses extra power, change this.
|
||||
var/power_usage = 0
|
||||
// If the hardware is turned off set this to 0.
|
||||
var/enabled = TRUE
|
||||
// Prevent disabling for important component, like the CPU.
|
||||
var/critical = FALSE
|
||||
// Prevents direct installation of removable media.
|
||||
var/can_install = TRUE
|
||||
// Hardware that fits into expansion bays.
|
||||
var/expansion_hw = FALSE
|
||||
// Whether the hardware is removable or not.
|
||||
var/removable = TRUE
|
||||
// Current damage level
|
||||
var/damage = 0
|
||||
// Maximal damage level.
|
||||
var/max_damage = 100
|
||||
// "Malfunction" threshold. When damage exceeds this value the hardware piece will semi-randomly fail and do !!FUN!! things
|
||||
var/damage_malfunction = 20
|
||||
// "Failure" threshold. When damage exceeds this value the hardware piece will not work at all.
|
||||
var/damage_failure = 50
|
||||
// Chance of malfunction when the component is damaged
|
||||
var/malfunction_probability = 10
|
||||
// What define is used to qualify this piece of hardware? Important for upgraded versions of the same hardware.
|
||||
var/device_type
|
||||
|
||||
/obj/item/computer_hardware/New(obj/L)
|
||||
|
||||
@@ -6,3 +6,12 @@
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
device_type = MC_SENSORS
|
||||
expansion_hw = TRUE
|
||||
|
||||
/obj/item/computer_hardware/radio_card
|
||||
name = "integrated radio card"
|
||||
desc = "An integrated signaling assembly for computers to send an outgoing frequency signal. Required by certain programs."
|
||||
icon_state = "signal_card"
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
device_type = MC_SIGNALER
|
||||
expansion_hw = TRUE
|
||||
power_usage = 10
|
||||
|
||||
Reference in New Issue
Block a user