From d7db7c0605a21a571dd2c78a0d8e3c8e9782aae1 Mon Sep 17 00:00:00 2001 From: Time-Green Date: Mon, 27 Jan 2020 11:25:32 +0100 Subject: [PATCH] Fixes plumbing ducts appearing disconnected (#48924) * fixes ducts appearing disconnected * adds comment to remove connects * adds newlines for comments and fixes an autodoc typo --- code/datums/components/plumbing/_plumbing.dm | 5 +++-- code/modules/plumbing/ducts.dm | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/code/datums/components/plumbing/_plumbing.dm b/code/datums/components/plumbing/_plumbing.dm index bca558ea80e..17105b0c5de 100644 --- a/code/datums/components/plumbing/_plumbing.dm +++ b/code/datums/components/plumbing/_plumbing.dm @@ -134,7 +134,8 @@ for(var/D in GLOB.cardinals) if(D & (demand_connects | supply_connects)) for(var/obj/machinery/duct/duct in get_step(parent, D)) - duct.attempt_connect() + duct.remove_connects(turn(D, 180)) + duct.update_icon() ///settle wherever we are, and start behaving like a piece of plumbing /datum/component/plumbing/proc/enable() @@ -156,7 +157,7 @@ if(istype(A, /obj/machinery/duct)) var/obj/machinery/duct/duct = A duct.attempt_connect() - else + else var/datum/component/plumbing/P = A.GetComponent(/datum/component/plumbing) if(P) direct_connect(P, D) diff --git a/code/modules/plumbing/ducts.dm b/code/modules/plumbing/ducts.dm index 667145ec3ea..0b141d764a3 100644 --- a/code/modules/plumbing/ducts.dm +++ b/code/modules/plumbing/ducts.dm @@ -60,9 +60,9 @@ All the important duct code: disconnect_duct() if(active) attempt_connect() + ///start looking around us for stuff to connect to /obj/machinery/duct/proc/attempt_connect() - reset_connects() //All connects are gathered here again eitherway, we might aswell reset it so they properly update when reconnecting for(var/atom/movable/AM in loc) var/datum/component/plumbing/P = AM.GetComponent(/datum/component/plumbing) @@ -76,6 +76,7 @@ All the important duct code: if(connect_network(AM, D)) add_connects(D) update_icon() + ///see if whatever we found can be connected to /obj/machinery/duct/proc/connect_network(atom/movable/AM, direction, ignore_color) if(istype(AM, /obj/machinery/duct)) @@ -85,6 +86,7 @@ All the important duct code: if(!plumber) return return connect_plumber(plumber, direction) + ///connect to a duct /obj/machinery/duct/proc/connect_duct(obj/machinery/duct/D, direction, ignore_color) var/opposite_dir = turn(direction, 180) @@ -124,6 +126,7 @@ All the important duct code: D.attempt_connect() return TRUE + ///connect to a plumbing object /obj/machinery/duct/proc/connect_plumber(datum/component/plumbing/P, direction) var/opposite_dir = turn(direction, 180) @@ -140,6 +143,7 @@ All the important duct code: if(duct.add_plumber(P, opposite_dir)) neighbours[P.parent] = direction return TRUE + ///we disconnect ourself from our neighbours. we also destroy our ductnet and tell our neighbours to make a new one /obj/machinery/duct/proc/disconnect_duct() anchored = FALSE @@ -190,25 +194,35 @@ All the important duct code: /obj/machinery/duct/proc/create_duct() duct = new() duct.add_duct(src) + ///add a duct as neighbour. this means we're connected and will connect again if we ever regenerate /obj/machinery/duct/proc/add_neighbour(obj/machinery/duct/D, direction) if(!(D in neighbours)) neighbours[D] = direction if(!(src in D.neighbours)) D.neighbours[src] = turn(direction, 180) + ///remove all our neighbours, and remove us from our neighbours aswell /obj/machinery/duct/proc/lose_neighbours() for(var/obj/machinery/duct/D in neighbours) D.neighbours.Remove(src) neighbours = list() + ///add a connect direction /obj/machinery/duct/proc/add_connects(new_connects) //make this a define to cut proc calls? if(!lock_connects) connects |= new_connects + +///remove a connect direction +/obj/machinery/duct/proc/remove_connects(dead_connects) + if(!lock_connects) + connects &= ~dead_connects + ///remove our connects /obj/machinery/duct/proc/reset_connects() if(!lock_connects) connects = 0 + ///get a list of the ducts we can connect to if we are dumb /obj/machinery/duct/proc/get_adjacent_ducts() var/list/adjacents = list()