diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 9204d5ec524..1d9f173dcc5 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -15,6 +15,8 @@ var/global/list/crafting_recipes = list() //list of all crafting recipes var/global/list/all_areas = list() var/global/list/machines = list() +var/global/list/machine_processing = list() +var/global/list/fast_processing = list() var/global/list/processing_power_items = list() //items that ask to be called every cycle var/global/list/rcd_list = list() //list of Rapid Construction Devices. diff --git a/code/controllers/Processes/fast_process.dm b/code/controllers/Processes/fast_process.dm new file mode 100644 index 00000000000..0954c7894b8 --- /dev/null +++ b/code/controllers/Processes/fast_process.dm @@ -0,0 +1,32 @@ +var/datum/controller/process/fast_process/fast_processes + +/datum/controller/process/fast_process + var/list/currentrun = list() + +/datum/controller/process/fast_process/setup() + name = "fast processing" + schedule_interval = 2 //every 0.2 seconds + start_delay = 9 + fast_processes = src + log_startup_progress("Fast Processing starting up.") + +/datum/controller/process/fast_process/statProcess() + ..() + stat(null, "[fast_processing.len] fast machines") + +/datum/controller/process/fast_process/doWork() + src.currentrun = fast_processing.Copy() + //cache for sanic speed (lists are references anyways) + var/list/currentrun = src.currentrun + + while(currentrun.len) + var/obj/thing = currentrun[1] + currentrun.Cut(1, 2) + if(thing) + try + thing.process() + catch(var/exception/e) + catchException(e, thing) + else + catchBadType(thing) + fast_processing -= thing \ No newline at end of file diff --git a/code/controllers/Processes/machinery.dm b/code/controllers/Processes/machinery.dm index eddccf62293..85007e4f492 100644 --- a/code/controllers/Processes/machinery.dm +++ b/code/controllers/Processes/machinery.dm @@ -7,7 +7,7 @@ /datum/controller/process/machinery/statProcess() ..() - stat(null, "[machines.len] machines") + stat(null, "[machine_processing.len] machines") stat(null, "[powernets.len] powernets, [deferred_powernet_rebuilds.len] deferred") /datum/controller/process/machinery/doWork() @@ -19,15 +19,15 @@ /datum/controller/process/machinery/proc/process_sort() if(machinery_sort_required) machinery_sort_required = 0 - machines = dd_sortedObjectList(machines) + machine_processing = dd_sortedObjectList(machine_processing) /datum/controller/process/machinery/proc/process_machines() - for(last_object in machines) + for(last_object in machine_processing) var/obj/machinery/M = last_object if(istype(M) && isnull(M.gcDestroyed)) try if(M.process() == PROCESS_KILL) - machines.Remove(M) + machine_processing.Remove(M) continue if(M.use_power) @@ -36,7 +36,7 @@ catchException(e, M) else catchBadType(M) - machines -= M + machine_processing -= M SCHECK_EVERY(100) diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 5a36a900e61..d37aa23cf64 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -81,7 +81,7 @@ assembly.upgrades.Add(new /obj/item/device/assembly/prox_sensor(assembly)) setPowerUsage() // Add it to machines that process - machines |= src + machine_processing |= src /obj/machinery/camera/proc/setPowerUsage() var/mult = 1 diff --git a/code/game/machinery/computer/pod.dm b/code/game/machinery/computer/pod.dm index 84b467d2072..cc9ff3831eb 100644 --- a/code/game/machinery/computer/pod.dm +++ b/code/game/machinery/computer/pod.dm @@ -19,8 +19,6 @@ ..() spawn(5) driver_sync() - machines += src - return /obj/machinery/computer/pod/proc/driver_sync() diff --git a/code/game/machinery/doors/airlock_control.dm b/code/game/machinery/doors/airlock_control.dm index e33d3e4d9c4..af45540c40b 100644 --- a/code/game/machinery/doors/airlock_control.dm +++ b/code/game/machinery/doors/airlock_control.dm @@ -36,7 +36,7 @@ obj/machinery/door/airlock/proc/execute_current_command() if(command_completed(cur_command)) cur_command = null else - if(!(src in machines)) + if(!(src in machine_processing)) addAtProcessing() obj/machinery/door/airlock/proc/do_command(var/command) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index b0be899942d..f5cccf01735 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -98,7 +98,7 @@ // Set releasetime releasetime = world.timeofday + timetoset - if(!(src in machines)) + if(!(src in machine_processing)) addAtProcessing() for(var/obj/machinery/door/window/brigdoor/door in targets) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 17552c3fe1c..518304fda5f 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -117,6 +117,7 @@ Class Procs: var/use_log = list() var/list/settagwhitelist = list()//WHITELIST OF VARIABLES THAT THE set_tag HREF CAN MODIFY, DON'T PUT SHIT YOU DON'T NEED ON HERE, AND IF YOU'RE GONNA USE set_tag (format_tag() proc), ADD TO THIS LIST. atom_say_verb = "beeps" + var/speed_process = 0 // Process as fast as possible? /obj/machinery/initialize() addAtProcessing() @@ -128,17 +129,17 @@ Class Procs: myArea = get_area_master(src) machines += src - -/obj/machinery/proc/removeAtProcessing() - if(myArea) - myArea = null - - machines -= src + if(!speed_process) + machine_processing += src + else + fast_processing += src /obj/machinery/Destroy() - if(src in machines) - removeAtProcessing() - + if(myArea) + myArea = null + fast_processing -= src + machine_processing -= src + machines -= src return ..() /obj/machinery/proc/locate_machinery() diff --git a/code/game/machinery/recycler.dm b/code/game/machinery/recycler.dm index c7ddfc84c38..4cdc3494927 100644 --- a/code/game/machinery/recycler.dm +++ b/code/game/machinery/recycler.dm @@ -2,22 +2,23 @@ var/const/SAFETY_COOLDOWN = 100 /obj/machinery/recycler name = "recycler" - desc = "A large crushing machine which is used to recycle small items ineffeciently; there are lights on the side of it." + desc = "A large crushing machine used to recycle small items inefficiently. There are lights on the side." icon = 'icons/obj/recycling.dmi' icon_state = "grinder-o0" layer = MOB_LAYER+1 // Overhead anchored = 1 density = 1 - var/safety_mode = 0 // Temporality stops the machine if it detects a mob - var/grinding = 0 + var/safety_mode = 0 // Temporarily stops machine if it detects a mob var/icon_name = "grinder-o" var/blood = 0 var/eat_dir = WEST var/amount_produced = 1 var/datum/material_container/materials + var/crush_damage = 1000 + var/eat_victim_items = 1 + var/item_recycle_sound = 'sound/machines/recycler.ogg' /obj/machinery/recycler/New() - // On us ..() component_parts = list() component_parts += new /obj/item/weapon/circuitboard/recycler(null) @@ -56,8 +57,6 @@ var/const/SAFETY_COOLDOWN = 100 /obj/machinery/recycler/attackby(obj/item/I, mob/user, params) if(default_deconstruction_screwdriver(user, "grinder-oOpen", "grinder-o0", I)) - if(!panel_open) - update_icon() return if(exchange_parts(user, I)) @@ -69,7 +68,6 @@ var/const/SAFETY_COOLDOWN = 100 default_deconstruction_crowbar(I) ..() add_fingerprint(user) - return /obj/machinery/recycler/emag_act(mob/user) if(!emagged) @@ -77,8 +75,8 @@ var/const/SAFETY_COOLDOWN = 100 if(safety_mode) safety_mode = 0 update_icon() - playsound(src.loc, "sparks", 75, 1, -1) - to_chat(user, "You use the cryptographic sequencer on the [src.name].") + playsound(loc, "sparks", 75, 1, -1) + to_chat(user, "You use the cryptographic sequencer on the [name].") /obj/machinery/recycler/update_icon() ..() @@ -88,48 +86,51 @@ var/const/SAFETY_COOLDOWN = 100 icon_state = icon_name + "[is_powered]" + "[(blood ? "bld" : "")]" // add the blood tag at the end // This is purely for admin possession !FUN!. -/obj/machinery/recycler/Bump(var/atom/movable/AM) +/obj/machinery/recycler/Bump(atom/movable/AM) ..() if(AM) Bumped(AM) -/obj/machinery/recycler/Bumped(var/atom/movable/AM) +/obj/machinery/recycler/Bumped(atom/movable/AM) if(stat & (BROKEN|NOPOWER)) return - if(safety_mode) - return if(!anchored) return - // If we're not already grinding something. - if(!grinding) - grinding = 1 - spawn(1) - grinding = 0 - else + if(safety_mode) return var/move_dir = get_dir(loc, AM.loc) if(move_dir == eat_dir) + eat(AM) + +/obj/machinery/recycler/proc/eat(atom/AM0, sound = 1) + var/list/to_eat = list(AM0) + if(istype(AM0, /obj/item)) + to_eat += AM0.GetAllContents() + var/items_recycled = 0 + + for(var/i in to_eat) + var/atom/movable/AM = i if(isliving(AM)) if(emagged) - eat(AM) + crush_living(AM) else - stop(AM) + emergency_stop(AM) else if(istype(AM, /obj/item)) - recycle(AM) - else // Can't recycle - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) - AM.loc = src.loc + recycle_item(AM) + items_recycled++ + else + playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0) + AM.loc = loc -/obj/machinery/recycler/proc/recycle(obj/item/I, sound = 1) - I.loc = src.loc - if(!istype(I)) - return + if(items_recycled && sound) + playsound(loc, item_recycle_sound, 100, 0) + +/obj/machinery/recycler/proc/recycle_item(obj/item/I) + I.loc = loc - if(sound) - playsound(src.loc, 'sound/machines/recycler.ogg', 100, 0) var/material_amount = materials.get_item_material_amount(I) if(!material_amount) qdel(I) @@ -139,25 +140,26 @@ var/const/SAFETY_COOLDOWN = 100 materials.retrieve_all() -/obj/machinery/recycler/proc/stop(var/mob/living/L) - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) +/obj/machinery/recycler/proc/emergency_stop(mob/living/L) + playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0) safety_mode = 1 update_icon() - L.loc = src.loc + L.loc = loc + addtimer(src, "reboot", SAFETY_COOLDOWN) - spawn(SAFETY_COOLDOWN) - playsound(src.loc, 'sound/machines/ping.ogg', 50, 0) - safety_mode = 0 - update_icon() +/obj/machinery/recycler/proc/reboot() + playsound(loc, 'sound/machines/ping.ogg', 50, 0) + safety_mode = 0 + update_icon() -/obj/machinery/recycler/proc/eat(var/mob/living/L) +/obj/machinery/recycler/proc/crush_living(mob/living/L) - L.loc = src.loc + L.loc = loc if(issilicon(L)) - playsound(src.loc, 'sound/machines/recycler.ogg', 100, 0) + playsound(loc, 'sound/items/Welder.ogg', 50, 1) else - playsound(src.loc, 'sound/effects/splat.ogg', 50, 1) + playsound(loc, 'sound/effects/splat.ogg', 50, 1) var/gib = 1 // By default, the emagged recycler will gib all non-carbons. (human simple animal mobs don't count) @@ -171,10 +173,11 @@ var/const/SAFETY_COOLDOWN = 100 blood = 1 update_icon() - // Remove and recycle the equipped items. - for(var/obj/item/I in L.get_equipped_items()) - if(L.unEquip(I)) - recycle(I, 0) + // Remove and recycle the equipped items + if(eat_victim_items) + for(var/obj/item/I in L.get_equipped_items()) + if(L.unEquip(I)) + eat(I, sound = 0) // Instantly lie down, also go unconscious from the pain, before you die. L.Paralyse(5) @@ -183,7 +186,8 @@ var/const/SAFETY_COOLDOWN = 100 if(gib || emagged == 2) L.gib() else if(emagged == 1) - L.adjustBruteLoss(1000) + L.adjustBruteLoss(crush_damage) + /obj/machinery/recycler/verb/rotate() set name = "Rotate Clockwise" @@ -192,9 +196,9 @@ var/const/SAFETY_COOLDOWN = 100 var/mob/living/user = usr - if(usr.stat || !usr.canmove || usr.restrained()) + if(usr.incapacitated()) return - if(src.anchored) + if(anchored) to_chat(usr, "[src] is fastened to the floor!") return 0 eat_dir = turn(eat_dir, 270) @@ -208,15 +212,22 @@ var/const/SAFETY_COOLDOWN = 100 var/mob/living/user = usr - if(usr.stat || !usr.canmove || usr.restrained()) + if(usr.incapacitated()) return - if(src.anchored) + if(anchored) to_chat(usr, "[src] is fastened to the floor!") return 0 eat_dir = turn(eat_dir, 90) to_chat(user, "[src] will now accept items from [dir2text(eat_dir)].") return 1 + +/obj/machinery/recycler/deathtrap + name = "dangerous old crusher" + emagged = 1 + crush_damage = 120 + + /obj/item/weapon/paper/recycler name = "paper - 'garbage duty instructions'" info = "