diff --git a/code/modules/genetics/machinery/genetics_cloner.dm b/code/modules/genetics/machinery/genetics_cloner.dm index 0d44009bac6..d3ddb28c09a 100644 --- a/code/modules/genetics/machinery/genetics_cloner.dm +++ b/code/modules/genetics/machinery/genetics_cloner.dm @@ -302,7 +302,6 @@ This makes cloning vat is probably the most dangerous tool in Genetics. Because /obj/machinery/genetics/cloner/proc/init_disposal_holder() var/obj/structure/disposalholder/holder = new() - holder.gas = air_contents// transfer gas resv. into holder object -- let's be explicit about the data this proc consumes, please. holder.from_cloner = TRUE //Check for any living mobs trigger hasmob. diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index 533f27bf477..c0f4fc96780 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -289,7 +289,7 @@ P.base_icon_state = base_state P.set_dir(dir) P.pipe_dir = pipe_dir - P.updateicon() + P.update_icon() //Needs some special treatment ;) if(pipe_type in list(PIPE_TYPE_JUNC_SORT, PIPE_TYPE_JUNC_SORT_FLIP)) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 1237fcf9994..12b0f345f3a 100755 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -8,6 +8,7 @@ #define SEND_PRESSURE (700 + ONE_ATMOSPHERE) //kPa - assume the inside of a dispoal pipe is 1 atm, so that needs to be added. #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 PERCENT_PER_PROCESS 0.084 // ~12 cycles = 24 seconds #define DISPOSALS_OFF "Off" #define DISPOSALS_CHARGING "Pressurizing" @@ -22,7 +23,7 @@ anchored = TRUE density = TRUE layer = LOW_OBJ_LAYER //This allows disposal bins to be underneath tables - var/datum/gas_mixture/air_contents // internal reservoir + var/percent_charged = 1 var/mode = DISPOSALS_CHARGED var/flush = 0 // true if flush handle is pulled var/obj/structure/disposalpipe/trunk/trunk = null // the attached pipe trunk @@ -30,32 +31,41 @@ var/flush_every_ticks = 30 //Every 30 ticks it will look whether it is ready to flush var/flush_count = 0 //this var adds 1 once per tick. When it reaches flush_every_ticks it resets and tries to flush. var/last_sound = 0 - active_power_usage = 2200 //the pneumatic pump power. 3 HP ~ 2200W + active_power_usage = 1100 // per tick, goal is 13,210 power over 12 cycles = 1100 idle_power_usage = 100 -// create a new disposal -// find the attached trunk (if present) and init gas resvr. -/obj/machinery/disposal/New() +/obj/machinery/disposal/Initialize(mapload, d) ..() - spawn(5) - trunk = locate() in src.loc - if(!trunk) - mode = DISPOSALS_OFF - flush = 0 - else - trunk.linked = src // link the pipe trunk to self + return INITIALIZE_HINT_LATELOAD + +// create a new disposal +// find the attached trunk (if present) +/obj/machinery/disposal/LateInitialize(mapload) + . = ..() - air_contents = new/datum/gas_mixture(PRESSURE_TANK_VOLUME) - update() + trunk = locate() in loc + if(!trunk) + mode = DISPOSALS_OFF + flush = 0 + else + trunk.linked = src // link the pipe trunk to self + + update() /obj/machinery/disposal/Destroy() eject() if(trunk) trunk.linked = null + trunk = null return ..() -/obj/machinery/disposal/affect_grab(var/mob/living/user, var/mob/living/target) +/obj/machinery/disposal/affect_grab(mob/living/user, mob/living/target) + if(target.mob_size > MOB_MEDIUM) //We cant stuff in anything bigger then 20 + to_chat(user, SPAN_WARNING("[target] is too big to go in [src].")) + return + user.visible_message("[user] starts putting [target] into the disposal.") + var/time_to_put = target.mob_size //size is perfectly suit if(do_after(user, time_to_put, src) && Adjacent(target)) user.face_atom(src) @@ -63,19 +73,15 @@ visible_message(SPAN_NOTICE("[target] has been placed in the [src] by [user].")) user.attack_log += text("\[[time_stamp()]\] Has placed [target] ([target.ckey]) in disposals.") target.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [user.name] ([user.ckey])") - msg_admin_attack("[user] ([user.ckey]) placed [target] ([target.ckey]) in a disposals unit. (JMP)") + msg_admin_attack("[key_name_admin(user)] placed [key_name_admin(target)] in a disposals unit.") return TRUE -/obj/machinery/disposal/MouseDrop_T(var/obj/item/I, mob/user, src_location, over_location, src_control, over_control, params) - - - // attack by item places it in to disposal -/obj/machinery/disposal/attackby(var/obj/item/I, var/mob/user) +/obj/machinery/disposal/attackby(obj/item/I, mob/user) if(stat & BROKEN || !I || !user) return - src.add_fingerprint(user) + add_fingerprint(user) var/list/usable_qualities = list() if(mode == DISPOSALS_OFF) @@ -83,10 +89,8 @@ if(panel_open) usable_qualities.Add(QUALITY_WELDING) - var/tool_type = I.get_tool_type(user, usable_qualities, src) switch(tool_type) - if(QUALITY_SCREW_DRIVING) if(length(contents) > 0) to_chat(user, "Eject the items first!") @@ -100,8 +104,6 @@ if(I.use_tool(user, src, WORKTIME_NEAR_INSTANT, tool_type, FAILCHANCE_EASY, required_stat = STAT_MEC, instant_finish_tier = 30, forced_sound = used_sound)) to_chat(user, "You [panel_open ? "attach" : "remove"] the screws around the power connection.") panel_open = !panel_open - return - return if(QUALITY_WELDING) @@ -115,23 +117,21 @@ if(I.use_tool(user, src, WORKTIME_NORMAL, tool_type, FAILCHANCE_EASY, required_stat = STAT_MEC)) to_chat(user, "You sliced the floorweld off the disposal unit.") - var/obj/structure/disposalconstruct/C = new (src.loc) - src.transfer_fingerprints_to(C) + var/obj/structure/disposalconstruct/C = new(loc) + transfer_fingerprints_to(C) C.pipe_type = PIPE_TYPE_BIN C.anchored = TRUE C.density = TRUE C.update() qdel(src) - return if(ABORT_CHECK) return - if(istype(I, /obj/item/storage/bag)) var/obj/item/storage/bag/T = I - to_chat(user, "\blue You empty the bag.") + to_chat(user, SPAN_NOTICE("You empty [I] into [src].")) for(var/obj/item/O in T.contents) T.remove_from_storage(O,src) T.update_icon() @@ -142,10 +142,11 @@ return if(user.unEquip(I, src)) - user.visible_message("[user.name] places \the [I] into \the [src].", \ - "You place \the [I] into the [src].") + user.visible_message( + "[user.name] places [I] into [src].", + "You place [I] into the [src]." + ) playsound(loc, 'sound/machines/vending_drop.ogg', 100, 1) - update() // mouse drop another mob or self @@ -153,61 +154,60 @@ /obj/machinery/disposal/MouseDrop_T(atom/movable/A, mob/user) if(ismob(A)) var/mob/target = A - if(user.stat || !user.canmove) + if(user.incapacitated(INCAPACITATION_ALL)) return - if(target.buckled || get_dist(user, src) > 1 || get_dist(user, target) > 1) + if(target.buckled || target.anchored || get_dist(user, src) > 1 || get_dist(user, target) > 1) return //animals cannot put mobs other than themselves into disposal if(isanimal(user) && target != user) + to_chat(user, SPAN_WARNING("Animals cannot put mobs other than themselves into disposals.")) return - if (target.mob_size < MOB_MEDIUM) //We cant stuff in anything bigger then 20 + if(target.mob_size > MOB_MEDIUM) //We cant stuff in anything bigger then 20 + to_chat(user, SPAN_WARNING("[target] is too big to go in [src].")) return - src.add_fingerprint(user) - var/target_loc = target.loc - var/msg - for (var/mob/V in viewers(usr)) - if(target == user && !user.stat && !user.weakened && !user.stunned && !user.paralysis) - V.show_message("[usr] starts climbing into the disposal.", 3) - if(target != user && !user.restrained() && !user.stat && !user.weakened && !user.stunned && !user.paralysis) - if(target.anchored) return - V.show_message("[usr] starts stuffing [target.name] into the disposal.", 3) + add_fingerprint(user) + + if(target == user) + user.visible_message(SPAN_DANGER("[user] starts climbing into [src]."), SPAN_DANGER("You start climbing into [src].")) + else + user.visible_message(SPAN_DANGER("[user] starts stuffing [target] into [src]."), SPAN_DANGER("You start stuffing [target] into [src].")) var/delay = 20 - if(!do_after(usr, max(delay * usr.stats.getMult(STAT_VIG, STAT_LEVEL_EXPERT), delay * 0.66), src)) + var/target_loc = target.loc + if(!do_after(user, max(delay * user.stats.getMult(STAT_VIG, STAT_LEVEL_EXPERT), delay * 0.66), src)) return if(target_loc != target.loc) return - if(target == user && !user.incapacitated(INCAPACITATION_ALL)) // if drop self, then climbed in - // must be awake, not stunned or whatever - msg = "[user.name] climbs into the [src]." - to_chat(user, "You climb into the [src].") - else if(target != user && !user.restrained() && !user.stat && !user.weakened && !user.stunned && !user.paralysis) - msg = "[user.name] stuffs [target.name] into the [src]!" - to_chat(user, "You stuff [target.name] into the [src]!") - - user.attack_log += text("\[[time_stamp()]\] Has placed [target.name] ([target.ckey]) in disposals.") - target.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [user.name] ([user.ckey])") - msg_admin_attack("[user] ([user.ckey]) placed [target] ([target.ckey]) in a disposals unit. (JMP)") - else + // do_after incapacitation_flags don't work yet + if(user.incapacitated(INCAPACITATION_ALL)) return - if (target.client) - target.client.perspective = EYE_PERSPECTIVE - target.client.eye = src + user.attack_log += text("\[[time_stamp()]\] Has placed [key_name(target)]]) in disposals.") + target.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [key_name(user)]") + msg_admin_attack("[key_name_admin(user)] placed [key_name_admin(target)] in a disposals unit.") + + if(target == user) + user.visible_message( + SPAN_DANGER("[user] climbs into [src]."), + SPAN_DANGER("You climb into [src].") + ) + else + user.visible_message( + SPAN_DANGER("[user] stuffs [target] into [src]."), + SPAN_DANGER("You stuff [target] into [src].") + ) + + target.reset_view(src) target.simple_move_animation(src) target.forceMove(src) - for (var/mob/C in viewers(src)) - if(C == user) - continue - C.show_message(msg, 3) - update() return - else if (istype(A, /obj/item)) + + else if(isitem(A)) var/obj/item/I = A if(!Adjacent(user) || !I.Adjacent(user) || user.stat) return ..() @@ -224,42 +224,41 @@ return I.add_fingerprint(user) - if(user.drop_from_inventory(I)) - user.drop_from_inventory(I) - I.forceMove(src) - user.visible_message("[user.name] places \the [I] into \the [src].", \ - "You place \the [I] into the [src].") + + if(user.unEquip(I, src)) + user.visible_message( + "[user] places [I] into [src].", + "You place [I] into [src]." + ) playsound(loc, 'sound/machines/vending_drop.ogg', 100, 1) else - user.visible_message("[user.name] fails to throw away \the [I] into \the [src].", \ - "You fail to throw away \the [I] into the [src].") + user.visible_message( + "[user] fails to throw away [I] into [src].", + "You fail to throw away [I] into [src]." + ) + update() return + . = ..() // attempt to move while inside -/obj/machinery/disposal/relaymove(mob/user as mob) - if(user.stat || src.flushing) +/obj/machinery/disposal/relaymove(mob/user) + if(user.stat || flushing) return if(user.loc == src) - src.go_out(user) - return + go_out(user) // leave the disposal /obj/machinery/disposal/proc/go_out(mob/user) - - if (user.client) - user.client.eye = user.client.mob - user.client.perspective = MOB_PERSPECTIVE - user.forceMove(src.loc) + user.forceMove(loc) + user.reset_view() update() - return /obj/machinery/disposal/ui_state(mob/user) return GLOB.notcontained_state /obj/machinery/disposal/ui_interact(mob/user, datum/tgui/ui) - if(stat & BROKEN) return @@ -276,7 +275,6 @@ "handle" = flush, "panel" = panel_open, "eject" = length(contents) ? TRUE : FALSE, - "pressure" = CLAMP01(100 * air_contents.return_pressure() / SEND_PRESSURE) ) return data @@ -304,18 +302,24 @@ // eject the contents of the disposal unit /obj/machinery/disposal/proc/eject() for(var/atom/movable/AM in src) - AM.forceMove(src.loc) + AM.forceMove(loc) AM.pipe_eject(0) update() -// update the icon & over-lays to reflect mode & status +// update state to match stat and update the icon /obj/machinery/disposal/proc/update() - cut_overlays() if(stat & BROKEN) - icon_state = "disposal-broken" mode = DISPOSALS_OFF flush = 0 - return + + update_icon() + +/obj/machinery/disposal/update_icon() + . = ..() + cut_overlays() + + if(stat & BROKEN) + icon_state = "disposal-broken" // only handle is shown if no power if(stat & NOPOWER || mode == DISPOSALS_OFF) @@ -336,52 +340,46 @@ add_overlay(image(icon, "dispover-handle")) // timed process -// charge the gas reservoir and perform flush if ready +// charge the "gas" reservoir and perform flush if ready /obj/machinery/disposal/Process() - if(!air_contents || (stat & BROKEN)) // nothing can happen if broken + if(stat & BROKEN) // nothing can happen if broken update_use_power(0) return flush_count++ - if( flush_count >= flush_every_ticks ) - if( contents.len ) + if(flush_count >= flush_every_ticks) + if(LAZYLEN(contents)) if(mode == DISPOSALS_CHARGED) spawn(0) flush() flush_count = 0 - src.updateDialog() - - if(flush && air_contents.return_pressure() >= SEND_PRESSURE ) // flush can happen even without power + // flush can happen even without power + if(flush && percent_charged >= 1) flush() if(mode != DISPOSALS_CHARGING) update_use_power(1) - else if(air_contents.return_pressure() >= SEND_PRESSURE) + else if(percent_charged >= 1) mode = DISPOSALS_CHARGED update() else - src.pressurize() //otherwise charge + pressurize() //otherwise charge /obj/machinery/disposal/proc/pressurize() - if(stat & NOPOWER) // won't charge if no power + // won't charge if no power + if(stat & NOPOWER) update_use_power(0) return - var/atom/L = loc // recharging from loc turf - var/datum/gas_mixture/env = L.return_air() - - var/power_draw = -1 - if(env && env.temperature > 0) - var/transfer_moles = (PUMP_MAX_FLOW_RATE/env.volume)*env.total_moles //group_multiplier is divided out here - power_draw = pump_gas(src, env, air_contents, transfer_moles, active_power_usage) + if(percent_charged >= 1) + return - if (power_draw > 0) - use_power(power_draw) + use_power(active_power_usage) + percent_charged = CLAMP01(percent_charged + PERCENT_PER_PROCESS) // perform a flush /obj/machinery/disposal/proc/flush() - flushing = 1 flick("[icon_state]-flush", src) @@ -398,55 +396,44 @@ if(wrapcheck == 1) H.tomail = 1 - sleep(10) if(last_sound < world.time + 1) playsound(src, 'sound/machines/disposalflush.ogg', 50, 0, 0) last_sound = world.time sleep(5) // wait for animation to finish - - H.init(src, air_contents) // copy the contents of disposer to holder - air_contents = new(PRESSURE_TANK_VOLUME) // new empty gas resv. - + H.init(src) // copy the contents of disposer to holder H.start(src) // start the holder processing movement flushing = 0 // now reset disposal state flush = 0 + percent_charged = 0 if(mode == DISPOSALS_CHARGED) mode = DISPOSALS_CHARGING update() - return - // called when area power changes /obj/machinery/disposal/power_change() ..() // do default setting/reset of stat NOPOWER bit update() // update icon - return - // called when holder is expelled from a disposal // should usually only occur if the pipe network is modified /obj/machinery/disposal/proc/get_eject_turf() - get_offset_target_turf(src.loc, rand(5)-rand(5), rand(5)-rand(5)) - -/obj/machinery/disposal/proc/expel(var/obj/structure/disposalholder/H) + get_offset_target_turf(loc, rand(5)-rand(5), rand(5)-rand(5)) - var/turf/target +/obj/machinery/disposal/proc/expel(obj/structure/disposalholder/H) + var/turf/target = get_eject_turf() playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) if(H) // Somehow, someone managed to flush a window which broke mid-transit and caused the disposal to go in an infinite loop trying to expel null, hopefully this fixes it for(var/atom/movable/AM in H) - target = get_eject_turf() - - AM.forceMove(src.loc) + AM.forceMove(loc) AM.pipe_eject(0) if(!isdrone(AM)) //Poor drones kept smashing windows and taking system damage being fired out of disposals. ~Z spawn(1) if(AM) AM.throw_at(target, 5, 1) - H.vent_gas(loc) qdel(H) /obj/machinery/disposal/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) @@ -454,51 +441,49 @@ var/mob/living/carbon/human/H = mover if(H.stats.getPerk(PERK_SPACE_ASSHOLE)) H.forceMove(src) - visible_message("[H] dives into \the [src]!") + visible_message("[H] dives into [src]!") flush = TRUE return - else if (istype(mover,/obj/item) && mover.throwing) + else if(isitem(mover) && mover.throwing) var/obj/item/I = mover if(istype(I, /obj/item/projectile)) return else if(prob(75)) I.forceMove(src) - visible_message("\The [I] lands in \the [src].") + visible_message("[I] lands in [src].") else - visible_message("\The [I] bounces off of \the [src]\'s rim!") - else if (istype(mover, /obj/item/projectile)) + visible_message("[I] bounces off of [src]'s rim!") + else if(istype(mover, /obj/item/projectile)) return TRUE - else return ..(mover, target, height, air_group) // virtual disposal object // travels through pipes in lieu of actual items // contents will be items flushed by the disposal -// this allows the gas flushed to be tracked - /obj/structure/disposalholder invisibility = 101 - var/datum/gas_mixture/gas = null // gas used to flush, will appear at exit point - var/active = 0 // true if the holder is moving, otherwise inactive dir = 0 + + var/active = 0 // true if the holder is moving, otherwise inactive var/count = 2048 //*** can travel 2048 steps before going inactive (in case of loops) var/destinationTag = "" // changes if contains a delivery container var/tomail = 0 //changes if contains wrapped package var/has_mob = FALSE //If it contains a mob var/from_cloner = FALSE // if the package originates from a genetics cloner - var/partialTag = "" //set by a partial tagger the first time round, then put in destinationTag if it goes through again. - // initialize a holder from the contents of a disposal unit -/obj/structure/disposalholder/proc/init(var/obj/machinery/disposal/D, var/datum/gas_mixture/flush_gas) - gas = flush_gas// transfer gas resv. into holder object -- let's be explicit about the data this proc consumes, please. +// initialize a holder from the contents of a disposal unit +/obj/structure/disposalholder/proc/init(obj/machinery/disposal/D) + // these three loops are here to prevent someone from mailing themselves into a sensitive area + // by simply including a delivery in the same package as them //Check for any living mobs trigger hasmob. //hasmob effects whether the package goes to cargo or its tagged destination. for(var/mob/living/M in D) + M.reset_view(src) if(M && M.stat != DEAD && !isdrone(M)) has_mob = TRUE @@ -507,6 +492,7 @@ for(var/obj/O in D) if(O.contents) for(var/mob/living/M in O.contents) + M.reset_view(src) if(M && M.stat != DEAD && !isdrone(M)) has_mob = TRUE @@ -516,19 +502,18 @@ AM.forceMove(src) if(istype(AM, /obj/structure/bigDelivery) && !has_mob) var/obj/structure/bigDelivery/T = AM - src.destinationTag = T.sortTag + destinationTag = T.sortTag if(istype(AM, /obj/item/smallDelivery) && !has_mob) var/obj/item/smallDelivery/T = AM - src.destinationTag = T.sortTag + destinationTag = T.sortTag //Drones can mail themselves through maint. if(isdrone(AM)) var/mob/living/silicon/robot/drone/drone = AM - src.destinationTag = drone.mail_destination - + destinationTag = drone.mail_destination - // start the movement process - // argument is the disposal unit the holder started in -/obj/structure/disposalholder/proc/start(var/obj/machinery/disposal/D) +// start the movement process +// argument is the disposal unit the holder started in +/obj/structure/disposalholder/proc/start(obj/machinery/disposal/D) if(!D.trunk) D.expel(src) // no trunk connected, so expel immediately return @@ -541,7 +526,7 @@ return - // movement process, persists while holder is moving through pipes +// movement process, persists while holder is moving through pipes /obj/structure/disposalholder/proc/move() var/obj/structure/disposalpipe/last while(active) @@ -575,20 +560,17 @@ if(!current) last.expel(src, loc, dir) - // if(!(count--)) active = FALSE return - - // find the turf which should contain the next pipe +// find the turf which should contain the next pipe /obj/structure/disposalholder/proc/nextloc() - return get_step(loc,dir) - - // find a matching pipe on a turf -/obj/structure/disposalholder/proc/findpipe(var/turf/T) + return get_step(loc, dir) +// find a matching pipe on a turf +/obj/structure/disposalholder/proc/findpipe(turf/T) if(!T) return null @@ -599,9 +581,9 @@ // if no matching pipe, return null return null - // merge two holder objects - // used when a a holder meets a stuck holder -/obj/structure/disposalholder/proc/merge(var/obj/structure/disposalholder/other) +// merge two holder objects +// used when a a holder meets a stuck holder +/obj/structure/disposalholder/proc/merge(obj/structure/disposalholder/other) for(var/atom/movable/AM in other) AM.forceMove(src) // move everything in other holder to this one if(ismob(AM)) @@ -611,44 +593,35 @@ qdel(other) - -/obj/structure/disposalholder/proc/settag(var/new_tag) +/obj/structure/disposalholder/proc/settag(new_tag) destinationTag = new_tag -/obj/structure/disposalholder/proc/setpartialtag(var/new_tag) +/obj/structure/disposalholder/proc/setpartialtag(new_tag) if(partialTag == new_tag) destinationTag = new_tag partialTag = "" else partialTag = new_tag - - // called when player tries to move while in a pipe -/obj/structure/disposalholder/relaymove(mob/user as mob) - +// called when player tries to move while in a pipe +/obj/structure/disposalholder/relaymove(mob/user) if(!isliving(user)) return var/mob/living/U = user - if (U.stat || U.last_special <= world.time) + if(U.stat || U.last_special <= world.time) return - U.last_special = world.time+100 + U.last_special = world.time + 100 - if (src.loc) - for (var/mob/M in hearers(src.loc.loc)) + if(loc) + for(var/mob/M in hearers(loc.loc)) to_chat(M, "CLONG, clong!") - playsound(src.loc, 'sound/effects/clang.ogg', 50, 0, 0) - - // called to vent all gas in holder to a location -/obj/structure/disposalholder/proc/vent_gas(var/atom/location) - location.assume_air(gas) // vent all gas to turf - return + playsound(loc, 'sound/effects/clang.ogg', 50, 0, 0) /obj/structure/disposalholder/Destroy() - qdel(gas) active = 0 return ..() @@ -656,7 +629,6 @@ return TRUE // Disposal pipes - /obj/structure/disposalpipe icon = 'icons/obj/pipes/disposal.dmi' name = "disposal pipe" @@ -674,21 +646,20 @@ var/base_icon_state // initial icon state on map var/sortType = list() var/subtype = SORT_TYPE_NORMAL - // new pipe, set the icon_state as on map - New() - ..() - base_icon_state = icon_state - return +// new pipe, set the icon_state as on map +/obj/structure/disposalpipe/New() + . = ..() + base_icon_state = icon_state - // pipe is deleted - // ensure if holder is present, it is expelled +// pipe is deleted +// ensure if holder is present, it is expelled /obj/structure/disposalpipe/Destroy() var/obj/structure/disposalholder/H = locate() in src if(H) // holder was present H.active = FALSE - var/turf/T = src.loc + var/turf/T = loc if(T.density) // deleting pipe is inside a dense turf (wall) // this is unlikely, but just dump out everything into the turf in case @@ -697,23 +668,22 @@ AM.forceMove(T) AM.pipe_eject(0) qdel(H) - ..() - return + return ..() // otherwise, do normal expel from turf if(H) expel(H, T, 0) . = ..() - // returns the direction of the next pipe object, given the entrance dir - // by default, returns the bitmask of remaining directions -/obj/structure/disposalpipe/proc/nextdir(var/fromdir) +// returns the direction of the next pipe object, given the entrance dir +// by default, returns the bitmask of remaining directions +/obj/structure/disposalpipe/proc/nextdir(fromdir) return pipe_dir & (~turn(fromdir, 180)) - // transfer the holder through this pipe segment - // overriden for special behaviour - // -/obj/structure/disposalpipe/proc/transfer(var/obj/structure/disposalholder/H) +// transfer the holder through this pipe segment +// overriden for special behaviour +// +/obj/structure/disposalpipe/proc/transfer(obj/structure/disposalholder/H) var/nextdir = nextdir(H.dir) H.set_dir(nextdir) var/turf/T = H.nextloc() @@ -733,30 +703,28 @@ return P - // update the icon_state to reflect hidden status +// update the icon_state to reflect hidden status /obj/structure/disposalpipe/proc/update() - var/turf/T = src.loc - hide(!T.is_plating() && !istype(T,/turf/space)) // space never hides pipes + var/turf/T = loc + // space never hides pipes + hide(!T.is_plating() && !istype(T,/turf/space)) // hide called by levelupdate if turf intact status changes // change visibility status and force update of icon -/obj/structure/disposalpipe/hide(var/intact) +/obj/structure/disposalpipe/hide(intact) invisibility = intact ? 101: 0 // hide if floor is intact - updateicon() - - // update actual icon_state depending on visibility - // if invisible, append "f" to icon_state to show faded version - // this will be revealed if a T-scanner is used - // if visible, use regular icon_state -/obj/structure/disposalpipe/proc/updateicon() + update_icon() +// update actual icon_state depending on visibility +// if invisible, append "f" to icon_state to show faded version +// this will be revealed if a T-scanner is used +// if visible, use regular icon_state +/obj/structure/disposalpipe/update_icon() icon_state = base_icon_state - return - - // expel the held objects into a turf - // called when there is a break in the pipe -/obj/structure/disposalpipe/proc/expel(var/obj/structure/disposalholder/H, var/turf/T, var/direction) +// expel the held objects into a turf +// called when there is a break in the pipe +/obj/structure/disposalpipe/proc/expel(obj/structure/disposalholder/H, turf/T, direction) if(!istype(H)) return @@ -769,7 +737,6 @@ qdel(H) return - if(!T.is_plating() && istype(T,/turf/simulated/floor)) //intact floor, pop the tile var/turf/simulated/floor/F = T F.break_tile() @@ -790,11 +757,9 @@ spawn(1) if(AM) AM.throw_at(target, 100, 1) - H.vent_gas(T) qdel(H) else // no specified direction, so throw in random direction - playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) if(H) for(var/atom/movable/AM in H) @@ -806,28 +771,25 @@ if(AM) AM.throw_at(target, 5, 1) - H.vent_gas(T) // all gas vent to turf qdel(H) - return - - // call to break the pipe - // will expel any holder inside at the time - // then delete the pipe - // remains : set to leave broken pipe pieces in place -/obj/structure/disposalpipe/proc/broken(var/remains = 0) +// call to break the pipe +// will expel any holder inside at the time +// then delete the pipe +// remains : set to leave broken pipe pieces in place +/obj/structure/disposalpipe/proc/broken(remains = 0) if(remains) for(var/D in cardinal) if(D & pipe_dir) - var/obj/structure/disposalpipe/broken/P = new(src.loc) + var/obj/structure/disposalpipe/broken/P = new(loc) P.set_dir(D) - src.invisibility = 101 // make invisible (since we won't delete the pipe immediately) + invisibility = 101 // make invisible (since we won't delete the pipe immediately) var/obj/structure/disposalholder/H = locate() in src if(H) // holder was present H.active = 0 - var/turf/T = src.loc + var/turf/T = loc if(T.density) // broken pipe is inside a dense turf (wall) // this is unlikely, but just dump out everything into the turf in case @@ -848,7 +810,6 @@ // pipe affected by explosion /obj/structure/disposalpipe/ex_act(severity) - switch(severity) if(1) broken(0) @@ -874,23 +835,21 @@ //attack by item //weldingtool: unfasten and convert to obj/disposalconstruct -/obj/structure/disposalpipe/attackby(var/obj/item/I, var/mob/user) - - var/turf/T = src.loc +/obj/structure/disposalpipe/attackby(obj/item/I, mob/user) + var/turf/T = loc if(!T.is_plating()) return // prevent interaction with T-scanner revealed pipes - src.add_fingerprint(user) + + add_fingerprint(user) if(QUALITY_WELDING in I.tool_qualities) if(I.use_tool(user, src, WORKTIME_NORMAL, QUALITY_WELDING, FAILCHANCE_EASY, required_stat = STAT_MEC)) welded() - - return + return // called when pipe is cut with welder /obj/structure/disposalpipe/proc/welded() - - var/obj/structure/disposalconstruct/C = new (src.loc) + var/obj/structure/disposalconstruct/C = new(loc) switch(base_icon_state) if("pipe-s") C.pipe_type = PIPE_TYPE_STRAIGHT @@ -920,8 +879,8 @@ C.pipe_type = PIPE_TYPE_TAGGER if("pipe-tagger-partial") C.pipe_type = PIPE_TYPE_TAGGER_PART - C.sort_mode = src.subtype - src.transfer_fingerprints_to(C) + C.sort_mode = subtype + transfer_fingerprints_to(C) C.set_dir(dir) C.density = FALSE C.anchored = TRUE @@ -929,30 +888,6 @@ qdel(src) -// pipe is deleted -// ensure if holder is present, it is expelled -/obj/structure/disposalpipe/Destroy() - var/obj/structure/disposalholder/H = locate() in src - if(H) - // holder was present - H.active = FALSE - var/turf/T = src.loc - if(T.density) - // deleting pipe is inside a dense turf (wall) - // this is unlikely, but just dump out everything into the turf in case - - for(var/atom/movable/AM in H) - AM.forceMove(T) - AM.pipe_eject(0) - qdel(H) - - return ..() - - // otherwise, do normal expel from turf - if(H) - expel(H, T, 0) - . = ..() - /obj/structure/disposalpipe/hides_under_flooring() return TRUE @@ -965,27 +900,25 @@ /obj/structure/disposalpipe/segment icon_state = "pipe-s" - New() - ..() - if(icon_state == "pipe-s") - pipe_dir = dir | turn(dir, 180) - else - pipe_dir = dir | turn(dir, -90) +/obj/structure/disposalpipe/segment/New() + . = ..() + if(icon_state == "pipe-s") + pipe_dir = dir | turn(dir, 180) + else + pipe_dir = dir | turn(dir, -90) - update() - return + update() ///// Z-Level stuff /obj/structure/disposalpipe/up icon_state = "pipe-u" /obj/structure/disposalpipe/up/New() - ..() + . = ..() pipe_dir = dir update() - return -/obj/structure/disposalpipe/up/nextdir(var/fromdir) +/obj/structure/disposalpipe/up/nextdir(fromdir) var/nextdir if(fromdir == DOWN) nextdir = dir @@ -993,7 +926,7 @@ nextdir = UP return nextdir -/obj/structure/disposalpipe/up/transfer(var/obj/structure/disposalholder/H) +/obj/structure/disposalpipe/up/transfer(obj/structure/disposalholder/H) var/nextdir = nextdir(H.dir) H.set_dir(nextdir) @@ -1007,9 +940,8 @@ else for(var/obj/structure/disposalpipe/down/F in T) P = F - else - T = get_step(src.loc, H.dir) + T = get_step(loc, H.dir) P = H.findpipe(T) if(P) @@ -1029,12 +961,11 @@ icon_state = "pipe-d" /obj/structure/disposalpipe/down/New() - ..() + . = ..() pipe_dir = dir update() - return -/obj/structure/disposalpipe/down/nextdir(var/fromdir) +/obj/structure/disposalpipe/down/nextdir(fromdir) var/nextdir if(fromdir == UP) nextdir = dir @@ -1042,7 +973,7 @@ nextdir = DOWN return nextdir -/obj/structure/disposalpipe/down/transfer(var/obj/structure/disposalholder/H) +/obj/structure/disposalpipe/down/transfer(obj/structure/disposalholder/H) var/nextdir = nextdir(H.dir) H.dir = nextdir @@ -1052,14 +983,14 @@ if(nextdir == DOWN) T = GetBelow(src) if(!T) - H.forceMove(src.loc) + H.forceMove(loc) return else for(var/obj/structure/disposalpipe/up/F in T) P = F else - T = get_step(src.loc, H.dir) + T = get_step(loc, H.dir) P = H.findpipe(T) if(P) @@ -1084,7 +1015,7 @@ icon_state = "pipe-j1" /obj/structure/disposalpipe/junction/New() - ..() + . = ..() if(icon_state == "pipe-j1") pipe_dir = dir | turn(dir, -90) | turn(dir,180) else if(icon_state == "pipe-j2") @@ -1092,13 +1023,10 @@ else // pipe-y pipe_dir = dir | turn(dir,90) | turn(dir, -90) update() - return - - - // next direction to move - // if coming in from secondary dirs, then next is primary dir - // if coming in from primary dir, then next is equal chance of other dirs +// next direction to move +// if coming in from secondary dirs, then next is primary dir +// if coming in from primary dir, then next is equal chance of other dirs /obj/structure/disposalpipe/junction/nextdir(var/fromdir) var/flipdir = turn(fromdir, 180) if(flipdir != dir) // came from secondary dir @@ -1150,7 +1078,7 @@ updatedesc() update() -/obj/structure/disposalpipe/tagger/attackby(var/obj/item/I, var/mob/user) +/obj/structure/disposalpipe/tagger/attackby(obj/item/I, mob/user) if(..()) return @@ -1159,12 +1087,12 @@ if(O.currTag)// Tag set sort_tag = O.currTag - playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) + playsound(loc, 'sound/machines/twobeep.ogg', 100, 1) to_chat(user, SPAN_NOTICE("Changed tag to '[sort_tag]'.")) updatename() updatedesc() -/obj/structure/disposalpipe/tagger/transfer(var/obj/structure/disposalholder/H) +/obj/structure/disposalpipe/tagger/transfer(obj/structure/disposalholder/H) if(sort_tag) if(partial) H.setpartialtag(sort_tag) @@ -1218,7 +1146,7 @@ updatedesc() update() -/obj/structure/disposalpipe/sortjunction/attackby(var/obj/item/I, var/mob/user) +/obj/structure/disposalpipe/sortjunction/attackby(obj/item/I, mob/user) if(..()) return @@ -1227,12 +1155,12 @@ if(O.currTag)// Tag set sortType = O.currTag - playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) + playsound(loc, 'sound/machines/twobeep.ogg', 100, 1) to_chat(user, "\blue Changed filter to '[sortType]'.") updatename() updatedesc() -/obj/structure/disposalpipe/sortjunction/proc/divert_check(var/checkTag) +/obj/structure/disposalpipe/sortjunction/proc/divert_check(checkTag) if(islist(sortType)) return checkTag in sortType else @@ -1243,7 +1171,7 @@ // if coming in from posdir, then flip around and go back to posdir // if coming in from sortdir, go to posdir -/obj/structure/disposalpipe/sortjunction/nextdir(var/fromdir, var/sortTag) +/obj/structure/disposalpipe/sortjunction/nextdir(fromdir, sortTag) if(fromdir != sortdir) // probably came from the negdir if(divert_check(sortTag)) return sortdir @@ -1253,7 +1181,7 @@ // so go with the flow to positive direction return posdir -/obj/structure/disposalpipe/sortjunction/transfer(var/obj/structure/disposalholder/H) +/obj/structure/disposalpipe/sortjunction/transfer(obj/structure/disposalholder/H) var/nextdir = nextdir(H.dir, H.destinationTag) H.set_dir(nextdir) var/turf/T = H.nextloc() @@ -1303,13 +1231,12 @@ var/obj/linked // the linked obj/machinery/disposal or obj/disposaloutlet /obj/structure/disposalpipe/trunk/New() - ..() + . = ..() pipe_dir = dir spawn(1) getlinked() update() - return /obj/structure/disposalpipe/trunk/Destroy() // Unlink trunk and disposal so that objets are not sent to nullspace @@ -1317,58 +1244,56 @@ if (istype(D)) D.trunk = null linked = null - return ..() + . = ..() /obj/structure/disposalpipe/trunk/proc/getlinked() linked = null - var/obj/machinery/disposal/D = locate() in src.loc + var/obj/machinery/disposal/D = locate() in loc if(D) linked = D if (!D.trunk) D.trunk = src - var/obj/structure/disposaloutlet/O = locate() in src.loc + var/obj/structure/disposaloutlet/O = locate() in loc if(O) linked = O update() - return - - // Override attackby so we disallow trunkremoval when somethings ontop -/obj/structure/disposalpipe/trunk/attackby(var/obj/item/I, var/mob/user) +// Override attackby so we disallow trunkremoval when somethings ontop +/obj/structure/disposalpipe/trunk/attackby(obj/item/I, mob/user) //Disposal bins or chutes /* These shouldn't be required - var/obj/machinery/disposal/D = locate() in src.loc + var/obj/machinery/disposal/D = locate() in loc if(D && D.anchored) return //Disposal outlet - var/obj/structure/disposaloutlet/O = locate() in src.loc + var/obj/structure/disposaloutlet/O = locate() in loc if(O && O.anchored) return */ //Disposal constructors - var/obj/structure/disposalconstruct/C = locate() in src.loc + var/obj/structure/disposalconstruct/C = locate() in loc if(C && C.anchored) return - var/turf/T = src.loc + var/turf/T = loc if(!T.is_plating()) return // prevent interaction with T-scanner revealed pipes - src.add_fingerprint(user) + add_fingerprint(user) if(QUALITY_WELDING in I.tool_qualities) if(I.use_tool(user, src, WORKTIME_NORMAL, QUALITY_WELDING, FAILCHANCE_EASY, required_stat = STAT_MEC)) welded() + return // would transfer to next pipe segment, but we are in a trunk // if not entering from disposal bin, // transfer to linked object (outlet or bin) -/obj/structure/disposalpipe/trunk/transfer(var/obj/structure/disposalholder/H) - +/obj/structure/disposalpipe/trunk/transfer(obj/structure/disposalholder/H) if(H.dir == DOWN) // we just entered from a disposer return ..() // so do base transfer proc // otherwise, go to the linked object @@ -1382,12 +1307,10 @@ D.expel(H) // expel at disposal else if(H) - src.expel(H, src.loc, 0) // expel at turf + expel(H, loc, 0) // expel at turf return null - // nextdir - -/obj/structure/disposalpipe/trunk/nextdir(var/fromdir) +/obj/structure/disposalpipe/trunk/nextdir(fromdir) if(fromdir == DOWN) return dir else @@ -1400,18 +1323,16 @@ // i.e. will be treated as an empty turf desc = "A broken piece of disposal pipe." - New() - ..() - update() - return - - // called when welded - // for broken pipe, remove and turn into scrap +/obj/structure/disposalpipe/broken/New() + . = ..() + update() - welded() -// var/obj/item/scrap/S = new(src.loc) -// S.set_components(200,0,0) - qdel(src) +// called when welded +// for broken pipe, remove and turn into scrap +/obj/structure/disposalpipe/broken/welded() +// var/obj/item/scrap/S = new(loc) +// S.set_components(200,0,0) + qdel(src) // the disposal outlet machine @@ -1427,21 +1348,20 @@ var/turf/target // this will be where the output objects are 'thrown' to. var/mode = DISPOSALS_OFF - New() - ..() - - spawn(1) - target = get_ranged_target_turf(src, dir, 10) - +/obj/structure/disposaloutlet/Initialize() + ..() + return INITIALIZE_HINT_LATELOAD - var/obj/structure/disposalpipe/trunk/trunk = locate() in src.loc - if(trunk) - trunk.linked = src // link the pipe trunk to self +/obj/structure/disposaloutlet/LateInitialize(mapload) + target = get_ranged_target_turf(src, dir, 10) - // expel the contents of the holder object, then delete it - // called when the holder exits the outlet -/obj/structure/disposaloutlet/proc/expel(var/obj/structure/disposalholder/H) + var/obj/structure/disposalpipe/trunk/trunk = locate() in loc + if(trunk) + trunk.linked = src // link the pipe trunk to self +// expel the contents of the holder object, then delete it +// called when the holder exits the outlet +/obj/structure/disposaloutlet/proc/expel(obj/structure/disposalholder/H) flick("outlet-open", src) playsound(src, 'sound/machines/warning-buzzer.ogg', 50, 0, 0) sleep(20) //wait until correct animation frame @@ -1449,51 +1369,45 @@ if(H) for(var/atom/movable/AM in H) - AM.forceMove(src.loc) + AM.forceMove(loc) AM.pipe_eject(dir) if(!isdrone(AM)) //Drones keep smashing windows from being fired out of chutes. Bad for the station. ~Z spawn(5) AM.throw_at(target, 3, 1) - H.vent_gas(src.loc) qdel(H) - return -/obj/structure/disposaloutlet/attackby(var/obj/item/I, var/mob/user) +/obj/structure/disposaloutlet/attackby(obj/item/I, mob/user) if(!I || !user) return - src.add_fingerprint(user) + add_fingerprint(user) var/list/usable_qualities = list() - if(mode<=0) + if(mode <= 0) usable_qualities.Add(QUALITY_SCREW_DRIVING) - if(mode==-1) + if(mode == -1) usable_qualities.Add(QUALITY_WELDING) - var/tool_type = I.get_tool_type(user, usable_qualities, src) switch(tool_type) - if(QUALITY_SCREW_DRIVING) - if(mode<=0) + if(mode <= 0) var/used_sound = mode ? 'sound/machines/Custom_screwdriverclose.ogg' : 'sound/machines/Custom_screwdriveropen.ogg' if(I.use_tool(user, src, WORKTIME_NEAR_INSTANT, tool_type, FAILCHANCE_EASY, required_stat = STAT_MEC, instant_finish_tier = 30, forced_sound = used_sound)) - if(mode==0) // It's off but still not unscrewed - mode=-1 // Set it to doubleoff l0l + if(mode == 0) // It's off but still not unscrewed + mode = -1 // Set it to doubleoff l0l to_chat(user, "You remove the screws around the power connection.") - return - else if(mode==-1) - mode=0 + else if(mode == -1) + mode = 0 to_chat(user, "You attach the screws around the power connection.") - return return if(QUALITY_WELDING) - if(mode==-1) + if(mode == -1) if(I.use_tool(user, src, WORKTIME_NORMAL, tool_type, FAILCHANCE_EASY, required_stat = STAT_MEC)) to_chat(user, "You sliced the floorweld off the disposal outlet.") - var/obj/structure/disposalconstruct/C = new (src.loc) - src.transfer_fingerprints_to(C) + var/obj/structure/disposalconstruct/C = new(loc) + transfer_fingerprints_to(C) C.pipe_type = PIPE_TYPE_OUTLET C.anchored = TRUE C.density = TRUE @@ -1506,32 +1420,27 @@ // called when movable is expelled from a disposal pipe or outlet // by default does nothing, override for special behaviour - -/atom/movable/proc/pipe_eject(var/direction) +/atom/movable/proc/pipe_eject(direction) return // check if mob has client, if so restore client view on eject -/mob/pipe_eject(var/direction) - if (src.client) - src.client.perspective = MOB_PERSPECTIVE - src.client.eye = src - - return +/mob/pipe_eject(direction) + reset_view() -/obj/effect/decal/cleanable/blood/gibs/pipe_eject(var/direction) +/obj/effect/decal/cleanable/blood/gibs/pipe_eject(direction) var/list/dirs if(direction) - dirs = list( direction, turn(direction, -45), turn(direction, 45)) + dirs = list(direction, turn(direction, -45), turn(direction, 45)) else dirs = alldirs.Copy() - src.streak(dirs) + streak(dirs) -/obj/effect/decal/cleanable/blood/gibs/robot/pipe_eject(var/direction) +/obj/effect/decal/cleanable/blood/gibs/robot/pipe_eject(direction) var/list/dirs if(direction) - dirs = list( direction, turn(direction, -45), turn(direction, 45)) + dirs = list(direction, turn(direction, -45), turn(direction, 45)) else dirs = alldirs.Copy() - src.streak(dirs) + streak(dirs) diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index df4c4e8832e..8022411170d 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -377,12 +377,15 @@ layer = BELOW_OBJ_LAYER //So that things being ejected are visible var/c_mode = 0 -/obj/machinery/disposal/deliveryChute/New() +/obj/machinery/disposal/deliveryChute/Initialize(mapload, d) ..() - spawn(5) - trunk = locate() in src.loc - if(trunk) - trunk.linked = src // link the pipe trunk to self + return INIT_ORDER_LATELOAD + +/obj/machinery/disposal/deliveryChute/LateInitialize(mapload) + . = ..() + trunk = locate() in loc + if(trunk) + trunk.linked = src // link the pipe trunk to self /obj/machinery/disposal/deliveryChute/interact() return @@ -390,29 +393,29 @@ /obj/machinery/disposal/deliveryChute/update() return -/obj/machinery/disposal/deliveryChute/Bumped(var/atom/movable/AM) //Go straight into the chute - if(istype(AM, /obj/item/projectile) || istype(AM, /obj/effect)) return - if(AM.loc && src.loc) +/obj/machinery/disposal/deliveryChute/Bumped(atom/movable/AM) //Go straight into the chute + if(istype(AM, /obj/item/projectile) || istype(AM, /obj/effect)) + return + if(AM.loc && loc) switch(dir) if(NORTH) - if(AM.loc.y != src.loc.y+1) return + if(AM.loc.y != loc.y + 1) return if(EAST) - if(AM.loc.x != src.loc.x+1) return + if(AM.loc.x != loc.x + 1) return if(SOUTH) - if(AM.loc.y != src.loc.y-1) return + if(AM.loc.y != loc.y - 1) return if(WEST) - if(AM.loc.x != src.loc.x-1) return + if(AM.loc.x != loc.x - 1) return if(isobj(AM) || ismob(AM)) AM.forceMove(src) - src.flush() + flush() /obj/machinery/disposal/deliveryChute/flush() flushing = 1 flick("intake-closing", src) var/obj/structure/disposalholder/H = new() // virtual holder object which actually // travels through the pipes. - //air_contents = new() // new empty gas resv. sleep(10) if(sound_on) @@ -420,7 +423,6 @@ sleep(5) // wait for animation to finish H.init(src) // copy the contents of disposer to holder - H.start(src) // start the holder processing movement flushing = 0 // now reset disposal state diff --git a/tgui/packages/tgui/interfaces/DisposalUnit.tsx b/tgui/packages/tgui/interfaces/DisposalUnit.tsx index d76617e0679..ae621fefaae 100644 --- a/tgui/packages/tgui/interfaces/DisposalUnit.tsx +++ b/tgui/packages/tgui/interfaces/DisposalUnit.tsx @@ -10,31 +10,30 @@ const MODE2COLOR = { }; type DisposalUnitData = { - isai: boolean - mode: string - panel: boolean - eject: boolean - handle: boolean - pressure: number -} + isai: boolean; + mode: string; + panel: boolean; + eject: boolean; + handle: boolean; +}; -export const DisposalUnit = props => { +export const DisposalUnit = (props) => { const { act, data } = useBackend(); - const { isai, mode, handle, panel, eject, pressure } = data; + const { isai, mode, handle, panel, eject } = data; let modeColor = MODE2COLOR[panel ? 'Panel' : mode]; let modeText = panel ? 'Power Disabled' : mode; return ( - +
- + {modeText} - +