mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
[READY] General Circuit Improvements (#38742)
* [WIP] General circuit improvements * Fix * s * Adds sound logging * oops * mob user
This commit is contained in:
committed by
yogstation13-bot
parent
cdcd8ed54c
commit
90d43ec7c7
@@ -10,6 +10,7 @@
|
||||
icon_state = "setup_small"
|
||||
item_flags = NOBLUDGEON
|
||||
materials = list() // To be filled later
|
||||
datum_flags = DF_USE_TAG
|
||||
var/list/assembly_components = list()
|
||||
var/list/ckeys_allowed_to_scan = list() // Players who built the circuit can scan it as a ghost.
|
||||
var/max_components = IC_MAX_SIZE_BASE
|
||||
@@ -30,6 +31,8 @@
|
||||
var/combat_circuits = 0 //number of combat cicuits in the assembly, used for diagnostic hud
|
||||
var/long_range_circuits = 0 //number of long range cicuits in the assembly, used for diagnostic hud
|
||||
var/prefered_hud_icon = "hudstat" // Used by the AR circuit to change the hud icon.
|
||||
var/creator // circuit creator if any
|
||||
var/static/next_assembly_id = 0
|
||||
hud_possible = list(DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_TRACK_HUD, DIAG_CIRCUIT_HUD) //diagnostic hud overlays
|
||||
max_integrity = 50
|
||||
pass_flags = 0
|
||||
@@ -56,6 +59,9 @@
|
||||
COLOR_ASSEMBLY_PURPLE
|
||||
)
|
||||
|
||||
/obj/item/electronic_assembly/GenerateTag()
|
||||
tag = "assembly_[next_assembly_id++]"
|
||||
|
||||
/obj/item/electronic_assembly/examine(mob/user)
|
||||
. = ..()
|
||||
if(can_anchor)
|
||||
@@ -351,6 +357,7 @@
|
||||
to_chat(user, "<span class='notice'>You slide [IC] inside [src].</span>")
|
||||
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
add_allowed_scanner(user.ckey)
|
||||
investigate_log("had [IC]([IC.type]) inserted by [key_name(user)].", INVESTIGATE_CIRCUIT)
|
||||
|
||||
add_component(IC)
|
||||
return TRUE
|
||||
@@ -390,6 +397,7 @@
|
||||
playsound(src, 'sound/items/crowbar.ogg', 50, 1)
|
||||
user.put_in_hands(IC)
|
||||
add_allowed_scanner(user.ckey)
|
||||
investigate_log("had [IC]([IC.type]) removed by [key_name(user)].", INVESTIGATE_CIRCUIT)
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
var/category_text = "NO CATEGORY THIS IS A BUG" // To show up on circuit printer, and perhaps other places.
|
||||
var/removable = TRUE // Determines if a circuit is removable from the assembly.
|
||||
var/displayed_name = ""
|
||||
|
||||
|
||||
/*
|
||||
Integrated circuits are essentially modular machines. Each circuit has a specific function, and combining them inside Electronic Assemblies allows
|
||||
a creative player the means to solve many problems. Circuits are held inside an electronic assembly, and are wired using special tools.
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
var/debug = FALSE // If it's upgraded and can clone, even without config settings.
|
||||
var/current_category = null
|
||||
var/cloning = FALSE // If the printer is currently creating a circuit
|
||||
var/clone_countdown = 0 // Timestamp for when to print the circuit
|
||||
var/recycling = FALSE // If an assembly is being emptied into this printer
|
||||
var/list/program // Currently loaded save, in form of list
|
||||
|
||||
@@ -29,26 +28,22 @@
|
||||
debug = TRUE
|
||||
upgraded = TRUE
|
||||
can_clone = TRUE
|
||||
fast_clone = TRUE
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
|
||||
/obj/item/integrated_circuit_printer/Initialize()
|
||||
. = ..()
|
||||
AddComponent(/datum/component/material_container, list(MAT_METAL), MINERAL_MATERIAL_AMOUNT * 25, TRUE, list(/obj/item/stack, /obj/item/integrated_circuit, /obj/item/electronic_assembly))
|
||||
|
||||
/obj/item/integrated_circuit_printer/Destroy()
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/integrated_circuit_printer/process()
|
||||
/obj/item/integrated_circuit_printer/proc/print_program(mob/user)
|
||||
if(!cloning)
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
if(world.time >= clone_countdown || fast_clone)
|
||||
var/turf/T = get_turf(src)
|
||||
T.visible_message("<span class='notice'>[src] has finished printing its assembly!</span>")
|
||||
playsound(get_turf(T), 'sound/items/poster_being_created.ogg', 50, TRUE)
|
||||
SScircuit.load_electronic_assembly(T, program)
|
||||
cloning = FALSE
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
return
|
||||
visible_message("<span class='notice'>[src] has finished printing its assembly!</span>")
|
||||
playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE)
|
||||
var/obj/item/electronic_assembly/assembly = SScircuit.load_electronic_assembly(get_turf(src), program)
|
||||
assembly.creator = key_name(user)
|
||||
assembly.investigate_log("was printed by [assembly.creator].", INVESTIGATE_CIRCUIT)
|
||||
cloning = FALSE
|
||||
|
||||
/obj/item/integrated_circuit_printer/attackby(obj/item/O, mob/user)
|
||||
if(istype(O, /obj/item/disk/integrated_circuit/upgrade/advanced))
|
||||
@@ -141,7 +136,7 @@
|
||||
if(!program)
|
||||
HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}"
|
||||
else if(cloning)
|
||||
HTML += " <A href='?src=[REF(src)];print=cancel'>{Cancel Print}</a> - [DisplayTimeText(max(0, clone_countdown - world.time))] remaining until completion"
|
||||
HTML += " <A href='?src=[REF(src)];print=cancel'>{Cancel Print}</a>"
|
||||
else
|
||||
HTML += " <A href='?src=[REF(src)];print=print'>{[fast_clone ? "Print" : "Begin Printing"] Assembly}</a>"
|
||||
|
||||
@@ -206,6 +201,7 @@
|
||||
|
||||
if(istype(built, /obj/item/electronic_assembly))
|
||||
var/obj/item/electronic_assembly/E = built
|
||||
E.creator = key_name(usr)
|
||||
E.opened = TRUE
|
||||
E.update_icon()
|
||||
//reupdate diagnostic hud because it was put_in_hands() and not pickup()'ed
|
||||
@@ -213,6 +209,7 @@
|
||||
E.diag_hud_set_circuitcell()
|
||||
E.diag_hud_set_circuitstat()
|
||||
E.diag_hud_set_circuittracking()
|
||||
E.investigate_log("was printed by [E.creator].", INVESTIGATE_CIRCUIT)
|
||||
|
||||
to_chat(usr, "<span class='notice'>[capitalize(built.name)] printed.</span>")
|
||||
playsound(src, 'sound/items/jaws_pry.ogg', 50, TRUE)
|
||||
@@ -226,8 +223,10 @@
|
||||
return
|
||||
switch(href_list["print"])
|
||||
if("load")
|
||||
if(cloning)
|
||||
return
|
||||
var/input = input("Put your code there:", "loading", null, null) as message | null
|
||||
if(!check_interactivity(usr))
|
||||
if(!check_interactivity(usr) || cloning)
|
||||
return
|
||||
if(!input)
|
||||
program = null
|
||||
@@ -254,7 +253,7 @@
|
||||
to_chat(usr, "<span class='notice'>Metal cost: [program["metal_cost"]].</span>")
|
||||
|
||||
if("print")
|
||||
if(!program)
|
||||
if(!program || cloning)
|
||||
return
|
||||
|
||||
if(program["requires_upgrades"] && !upgraded && !debug)
|
||||
@@ -263,12 +262,11 @@
|
||||
if(program["unsupported_circuit"] && !debug)
|
||||
to_chat(usr, "<span class='warning'>This program uses components not supported by the specified assembly. Please change the assembly type in the save file to a supported one.</span>")
|
||||
return
|
||||
else if(fast_clone || debug)
|
||||
else if(fast_clone)
|
||||
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
|
||||
if(debug || materials.use_amount_type(program["metal_cost"], MAT_METAL))
|
||||
var/obj/item/assembly = SScircuit.load_electronic_assembly(get_turf(src), program)
|
||||
to_chat(usr, "<span class='notice'>[assembly] has been printed from the provided template!</span>")
|
||||
playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE)
|
||||
cloning = TRUE
|
||||
print_program(usr)
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>You need [program["metal_cost"]] metal to build that!</span>")
|
||||
else
|
||||
@@ -279,11 +277,10 @@
|
||||
var/cloning_time = round(program["metal_cost"] / 15)
|
||||
cloning_time = min(cloning_time, MAX_CIRCUIT_CLONE_TIME)
|
||||
cloning = TRUE
|
||||
clone_countdown = world.time + cloning_time
|
||||
to_chat(usr, "<span class='notice'>You begin printing a custom assembly. This will take approximately [DisplayTimeText(cloning_time)]. You can still print \
|
||||
off normal parts during this time.</span>")
|
||||
playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE)
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
addtimer(CALLBACK(src, .proc/print_program, usr), cloning_time)
|
||||
|
||||
if("cancel")
|
||||
if(!cloning || !program)
|
||||
@@ -291,7 +288,6 @@
|
||||
|
||||
to_chat(usr, "<span class='notice'>Cloning has been canceled. Metal cost has been refunded.</span>")
|
||||
cloning = FALSE
|
||||
clone_countdown = FALSE
|
||||
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
|
||||
materials.use_amount_type(-program["metal_cost"], MAT_METAL) //use negative amount to regain the cost
|
||||
|
||||
|
||||
@@ -151,6 +151,8 @@
|
||||
return
|
||||
vol = CLAMP(vol ,0 , 100)
|
||||
playsound(get_turf(src), selected_sound, vol, freq, -1)
|
||||
if(assembly)
|
||||
assembly.investigate_log("played a sound ([selected_sound]) with [type].", INVESTIGATE_CIRCUIT)
|
||||
|
||||
/obj/item/integrated_circuit/output/sound/on_data_written()
|
||||
power_draw_per_use = get_pin_data(IC_INPUT, 2) * 15
|
||||
@@ -234,8 +236,10 @@
|
||||
text = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(text))
|
||||
var/atom/movable/A = get_object()
|
||||
A.say(sanitize(text))
|
||||
|
||||
var/sanitized_text = sanitize(text)
|
||||
A.say(sanitized_text)
|
||||
if (assembly)
|
||||
log_say("[assembly] [REF(assembly)] : [sanitized_text]")
|
||||
|
||||
/obj/item/integrated_circuit/output/video_camera
|
||||
name = "video camera circuit"
|
||||
|
||||
Reference in New Issue
Block a user