From b4615d16652e79a5e10f7c1d826d2d0f2a78e074 Mon Sep 17 00:00:00 2001 From: Geeves Date: Thu, 25 Mar 2021 15:31:08 +0200 Subject: [PATCH] Remote Disposal Flushing (#11517) --- aurorastation.dme | 1 + code/datums/wires/disposals.dm | 37 +++++++++ code/datums/wires/wires.dm | 1 - code/modules/recycling/disposal.dm | 89 +++++++++++++++------- html/changelogs/geeves-wired_disposals.yml | 6 ++ 5 files changed, 107 insertions(+), 27 deletions(-) create mode 100644 code/datums/wires/disposals.dm create mode 100644 html/changelogs/geeves-wired_disposals.yml diff --git a/aurorastation.dme b/aurorastation.dme index db419061de1..044638a4979 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -381,6 +381,7 @@ #include "code\datums\wires\apc.dm" #include "code\datums\wires\autolathe.dm" #include "code\datums\wires\camera.dm" +#include "code\datums\wires\disposals.dm" #include "code\datums\wires\explosive.dm" #include "code\datums\wires\ipc_tag_scanner.dm" #include "code\datums\wires\mulebot.dm" diff --git a/code/datums/wires/disposals.dm b/code/datums/wires/disposals.dm new file mode 100644 index 00000000000..73ba69619ee --- /dev/null +++ b/code/datums/wires/disposals.dm @@ -0,0 +1,37 @@ +/datum/wires/disposal + random = TRUE + holder_type = /obj/machinery/disposal + wire_count = 3 + +var/const/DISPOSAL_WIRE_FLUSH = 1 + +/datum/wires/disposal/GetInteractWindow() + . = ..() + + var/obj/machinery/disposal/D = holder + . += "
\nThe light indicator inserted within the flush handle is [D.can_flush ? "on" : "off"]." + return . + +/datum/wires/disposal/UpdateCut(var/index, var/mended) + var/obj/machinery/disposal/D = holder + switch(index) + if(DISPOSAL_WIRE_FLUSH) + if(!mended) + D.can_flush = FALSE + D.visible_message(SPAN_WARNING("\The [D] whines loudly."), range = 3) + else + D.can_flush = TRUE + D.visible_message(SPAN_NOTICE("\The [D] hums soothingly."), range = 3) + +/datum/wires/disposal/UpdatePulsed(var/index) + var/obj/machinery/disposal/D = holder + switch(index) + if(DISPOSAL_WIRE_FLUSH) + if(D.air_contents.return_pressure() >= (700 + ONE_ATMOSPHERE) || !D.uses_air) + D.flush() + +/datum/wires/disposal/CanUse(var/mob/living/L) + var/obj/machinery/disposal/D = holder + if(D.mode <= 0) + return TRUE + return FALSE \ No newline at end of file diff --git a/code/datums/wires/wires.dm b/code/datums/wires/wires.dm index 5f1c07332aa..f7044c59e82 100644 --- a/code/datums/wires/wires.dm +++ b/code/datums/wires/wires.dm @@ -129,7 +129,6 @@ var/list/wireColours = list("red", "blue", "green", "darkred", "orange", "brown" var/obj/item/O = Detach(colour) if(O) L.put_in_hands(O) - return if(href_list["cut"]) // Toggles the cut/mend status var/obj/item/I = L.get_active_hand() diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index e70b2ae8ad4..be5618db146 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -9,6 +9,11 @@ #define PRESSURE_TANK_VOLUME 150 //L #define PUMP_MAX_FLOW_RATE 90 //L/s - 4 m/s using a 15 cm by 15 cm inlet +#define MODE_UNSCREWED -1 +#define MODE_OFF 0 +#define MODE_CHARGING 1 +#define MODE_FLUSHING 2 + /obj/machinery/disposal name = "disposal unit" desc = "A pneumatic waste disposal unit." @@ -16,9 +21,11 @@ icon_state = "disposal" anchored = 1 density = 1 + var/datum/wires/disposal/wires var/datum/gas_mixture/air_contents // internal reservoir - var/mode = 1 // item mode 0=off 1=charging 2=charged - var/flush = 0 // true if flush handle is pulled + var/mode = MODE_CHARGING + var/can_flush = TRUE + var/flush = FALSE // true if flush handle is pulled var/obj/structure/disposalpipe/trunk/trunk = null // the attached pipe trunk var/flushing = 0 // true if flushing in progress var/flush_every_ticks = 30 //Every 30 ticks it will look whether it is ready to flush @@ -85,11 +92,12 @@ . = ..() trunk = locate() in src.loc if(!trunk) - mode = 0 + mode = MODE_OFF flush = 0 else trunk.linked = src // link the pipe trunk to self + wires = new(src) air_contents = new/datum/gas_mixture(PRESSURE_TANK_VOLUME) update() @@ -99,39 +107,49 @@ trunk.linked = null return ..() +/obj/machinery/disposal/proc/contents_count() + var/things = 0 + for(var/thing in contents) + if(istype(thing, /obj/item/device/assembly/signaler)) + var/obj/item/device/assembly/signaler/S = thing + if(S.connected == wires) + continue + things++ + return things + // attack by item places it in to disposal /obj/machinery/disposal/attackby(var/obj/item/I, var/mob/user) if(stat & BROKEN || !I || !user) return src.add_fingerprint(user) - if(mode<=0) // It's off + if(mode <= MODE_OFF) // It's off if(I.isscrewdriver()) - if(contents.len > 0) - to_chat(user, "Eject the items first!") + if(contents_count()) + to_chat(user, SPAN_WARNING("Eject the items first!")) return - if(mode==0) // It's off but still not unscrewed - mode=-1 // Set it to doubleoff l0l - playsound(src.loc, I.usesound, 50, 1) - to_chat(user, "You remove the screws around the power connection.") - return - else if(mode==-1) - mode=0 - playsound(src.loc, I.usesound, 50, 1) - to_chat(user, "You attach the screws around the power connection.") - return - else if(I.iswelder() && mode==-1) - if(contents.len > 0) - to_chat(user, "Eject the items first!") + playsound(src.loc, I.usesound, 50, 1) + switch(mode) + if(MODE_OFF) + mode = MODE_UNSCREWED + to_chat(user, SPAN_NOTICE("You remove the screws around the power connection.")) + return + if(MODE_UNSCREWED) + mode = MODE_OFF + to_chat(user, SPAN_NOTICE("You attach the screws around the power connection.")) + return + else if(I.iswelder() && mode == MODE_UNSCREWED) + if(contents_count()) + to_chat(user, SPAN_WARNING("Eject the items first!")) return var/obj/item/weldingtool/W = I if(W.remove_fuel(0,user)) playsound(src.loc, 'sound/items/welder_pry.ogg', 100, 1) - to_chat(user, "You start slicing the floorweld off the disposal unit.") - - if(do_after(user,20/W.toolspeed)) - if(!src || !W.isOn()) return - to_chat(user, "You sliced the floorweld off the disposal unit.") + to_chat(user, SPAN_NOTICE("You start slicing the floorweld off the disposal unit.")) + if(do_after(user, 20 / W.toolspeed)) + if(!src || !W.isOn()) + return + to_chat(user, SPAN_NOTICE("You sliced the floorweld off the disposal unit.")) if(!istype(src, /obj/machinery/disposal/small)) var/obj/structure/disposalconstruct/C = new (src.loc) src.transfer_fingerprints_to(C) @@ -148,10 +166,14 @@ qdel(src) return else - to_chat(user, "You need more welding fuel to complete this task.") + to_chat(user, SPAN_WARNING("You need more welding fuel to complete this task.")) return + else if(I.ismultitool() || I.iswirecutter() || issignaler(I)) + wires.Interact(user) + return + if(istype(I, /obj/item/melee/energy/blade)) - to_chat(user, "You can't place that item inside the disposal unit.") + to_chat(user, SPAN_WARNING("You can't place that item inside the disposal unit.")) return if(istype(I, /obj/item/storage) && length(I.contents) && user.a_intent != I_HURT) @@ -493,6 +515,12 @@ /obj/machinery/disposal/proc/flush() set waitfor = FALSE + if(!can_flush) + shake_animation() + visible_message(SPAN_WARNING("\The [src] groans violently!"), range = 3) + flush = FALSE + return + flushing = 1 flick("[icon_state]-flush", src) @@ -610,6 +638,10 @@ // now everything inside the disposal gets put into the holder // note AM since can contain mobs or objs for(var/atom/movable/AM in D) + if(istype(AM, /obj/item/device/assembly/signaler)) + var/obj/item/device/assembly/signaler/S = AM + if(S.connected == D.wires) + continue AM.forceMove(src) if(istype(AM, /obj/structure/bigDelivery) && !hasmob) var/obj/structure/bigDelivery/T = AM @@ -1617,3 +1649,8 @@ dirs = alldirs.Copy() src.streak(dirs) + +#undef MODE_UNSCREWED +#undef MODE_OFF +#undef MODE_CHARGING +#undef MODE_FLUSHING \ No newline at end of file diff --git a/html/changelogs/geeves-wired_disposals.yml b/html/changelogs/geeves-wired_disposals.yml new file mode 100644 index 00000000000..8c23b2e3aec --- /dev/null +++ b/html/changelogs/geeves-wired_disposals.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "Disposals now have wires you can cut and pulse. Cutting one of the wires will disable flushing, pulsing that same one will cause it to flush." \ No newline at end of file