From 08b92591ee02f3091308ae547f3e061f3e2e5be4 Mon Sep 17 00:00:00 2001 From: Chap Date: Mon, 4 Nov 2024 19:22:22 +0100 Subject: [PATCH] [FIX] Ventcrawling overlay fixes (#27013) * Vent images update while ventcrawling * Add some comments * Autodoc for a variable * Get rid of this useless timer * Update code/modules/atmospherics/machinery/atmospherics.dm Co-authored-by: Nathan Winters <100448493+CinnamonSnowball@users.noreply.github.com> Signed-off-by: Chap * Move update pipe image to unary base * We're doing signals now * Added a comment to the signal * Trailing newline --------- Signed-off-by: Chap Co-authored-by: Adrer Co-authored-by: Nathan Winters <100448493+CinnamonSnowball@users.noreply.github.com> --- code/__DEFINES/dcs/mob_signals.dm | 3 +++ .../airlock_control/airlock_controllers.dm | 3 ++- .../atmospherics/machinery/atmospherics.dm | 7 +++++-- .../components/unary_devices/unary_base.dm | 7 +++++++ .../components/unary_devices/vent_pump.dm | 3 +-- .../components/unary_devices/vent_scrubber.dm | 2 +- .../atmospherics/machinery/datum_pipeline.dm | 11 ++++++++++ .../modules/mob/living/carbon/carbon_procs.dm | 21 ++++++++++++++----- 8 files changed, 46 insertions(+), 11 deletions(-) diff --git a/code/__DEFINES/dcs/mob_signals.dm b/code/__DEFINES/dcs/mob_signals.dm index 487a1eb2d85..2922c06f9f9 100644 --- a/code/__DEFINES/dcs/mob_signals.dm +++ b/code/__DEFINES/dcs/mob_signals.dm @@ -212,3 +212,6 @@ /// Sent from datum/spell/ethereal_jaunt/cast, before the mob enters jaunting as a pre-check: (mob/jaunter) #define COMSIG_MOB_PRE_JAUNT "spell_mob_pre_jaunt" #define COMPONENT_BLOCK_JAUNT (1<<0) + +/// from remove_ventcrawler(): (mob/living/crawler) +#define COMSIG_LIVING_EXIT_VENTCRAWL "living_exit_ventcrawl" diff --git a/code/game/machinery/airlock_control/airlock_controllers.dm b/code/game/machinery/airlock_control/airlock_controllers.dm index fd30655fe80..4328b3063ee 100644 --- a/code/game/machinery/airlock_control/airlock_controllers.dm +++ b/code/game/machinery/airlock_control/airlock_controllers.dm @@ -263,7 +263,8 @@ if(QDELETED(V)) vents -= vent_uid continue - + if(V.on == FALSE && power == FALSE) // Don't bother if it's already off + continue V.on = power V.releasing = direction V.external_pressure_bound = pressure diff --git a/code/modules/atmospherics/machinery/atmospherics.dm b/code/modules/atmospherics/machinery/atmospherics.dm index 21f7103bab2..44bff7a7d01 100644 --- a/code/modules/atmospherics/machinery/atmospherics.dm +++ b/code/modules/atmospherics/machinery/atmospherics.dm @@ -101,8 +101,8 @@ Pipelines + Other Objects -> Pipe network plane = GAME_PLANE layer = GAS_PIPE_VISIBLE_LAYER + layer_offset -/obj/machinery/atmospherics/proc/update_pipe_image() - pipe_image = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir) //the 20 puts it above Byond's darkness (not its opacity view) +/obj/machinery/atmospherics/proc/update_pipe_image(overlay = src) + pipe_image = image(overlay, loc, layer = ABOVE_HUD_LAYER, dir = dir) //the 20 puts it above Byond's darkness (not its opacity view) pipe_image.plane = HUD_PLANE /obj/machinery/atmospherics/proc/check_icon_cache() @@ -322,6 +322,7 @@ Pipelines + Other Objects -> Pipe network // Ventcrawling #define VENT_SOUND_DELAY 30 /obj/machinery/atmospherics/relaymove(mob/living/user, direction) + var/datum/pipeline/current_pipenet = returnPipenet(src) direction &= initialize_directions if(!direction || !(direction in GLOB.cardinal)) //cant go this way. return @@ -332,6 +333,7 @@ Pipelines + Other Objects -> Pipe network var/obj/machinery/atmospherics/target_move = findConnecting(direction) if(target_move) if(is_type_in_list(target_move, GLOB.ventcrawl_machinery) && target_move.can_crawl_through()) + current_pipenet.crawlers -= user user.remove_ventcrawl() user.forceMove(target_move.loc) //handles entering and so on user.visible_message("You hear something squeezing through the ducts.", "You climb out of the ventilation system.") @@ -344,6 +346,7 @@ Pipelines + Other Objects -> Pipe network playsound(src, 'sound/machines/ventcrawl.ogg', 50, TRUE, -3) else if((direction & initialize_directions) || is_type_in_list(src, GLOB.ventcrawl_machinery)) //if we move in a way the pipe can connect, but doesn't - or we're in a vent + current_pipenet.crawlers -= user user.remove_ventcrawl() user.forceMove(loc) user.visible_message("You hear something squeezing through the pipes.", "You climb out of the ventilation system.") diff --git a/code/modules/atmospherics/machinery/components/unary_devices/unary_base.dm b/code/modules/atmospherics/machinery/components/unary_devices/unary_base.dm index 293538e76e1..a831588f401 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/unary_base.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/unary_base.dm @@ -50,6 +50,13 @@ build_network() . = 1 +/obj/machinery/atmospherics/unary/update_pipe_image() + . = ..() + if(parent) + for(var/mob/crawler in parent.crawlers) + var/mob/living/current_crawler = crawler + current_crawler.update_pipe_vision(src) + /obj/machinery/atmospherics/unary/build_network(remove_deferral = FALSE) if(!parent) parent = new /datum/pipeline() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm index e252d7598b6..12e3d2bf01a 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm @@ -88,8 +88,7 @@ vent_icon += "[on ? "[releasing ? "out" : "in"]" : "off"]" . += GLOB.pipe_icon_manager.get_atmos_icon("device", state = vent_icon) - - update_pipe_image() + update_pipe_image(.) /obj/machinery/atmospherics/unary/vent_pump/update_underlays() if(..()) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm index 5ba4847cf80..3066b5308b0 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm @@ -83,7 +83,7 @@ scrubber_icon = "scrubberweld" . += GLOB.pipe_icon_manager.get_atmos_icon("device", state = scrubber_icon) - update_pipe_image() + update_pipe_image(.) /obj/machinery/atmospherics/unary/vent_scrubber/update_underlays() if(..()) diff --git a/code/modules/atmospherics/machinery/datum_pipeline.dm b/code/modules/atmospherics/machinery/datum_pipeline.dm index d55f9da5e81..fb77f74cc46 100644 --- a/code/modules/atmospherics/machinery/datum_pipeline.dm +++ b/code/modules/atmospherics/machinery/datum_pipeline.dm @@ -7,6 +7,8 @@ var/update = TRUE + var/list/crawlers = list() + /datum/pipeline/New() SSair.pipenets += src @@ -220,3 +222,12 @@ GL += C.portableConnectorReturnAir() share_many_airs(GL) + +/datum/pipeline/proc/add_ventcrawler(mob/living/crawler) + if(!(crawler in crawlers)) + RegisterSignal(crawler, COMSIG_LIVING_EXIT_VENTCRAWL, PROC_REF(remove_ventcrawler), crawler) + crawlers += crawler + +/datum/pipeline/proc/remove_ventcrawler(mob/living/crawler) + UnregisterSignal(crawler, COMSIG_LIVING_EXIT_VENTCRAWL) + crawlers -= crawler diff --git a/code/modules/mob/living/carbon/carbon_procs.dm b/code/modules/mob/living/carbon/carbon_procs.dm index 95ec7756c9c..d5cfe17fdb3 100644 --- a/code/modules/mob/living/carbon/carbon_procs.dm +++ b/code/modules/mob/living/carbon/carbon_procs.dm @@ -534,10 +534,15 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven /mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine, obj/machinery/atmospherics/target_move) if(!istype(starting_machine) || !starting_machine.returnPipenet(target_move) || !starting_machine.can_see_pipes()) return - var/datum/pipeline/pipeline = starting_machine.returnPipenet(target_move) + var/datum/pipeline/pipenet = starting_machine.returnPipenet(target_move) + pipenet.add_ventcrawler(src) + add_ventcrawl_images(pipenet) + + +/mob/living/proc/add_ventcrawl_images(datum/pipeline/pipenet) var/list/totalMembers = list() - totalMembers |= pipeline.members - totalMembers |= pipeline.other_atmosmch + totalMembers |= pipenet.members + totalMembers |= pipenet.other_atmosmch for(var/obj/machinery/atmospherics/A in totalMembers) if(!A.pipe_image) A.update_pipe_image() @@ -546,6 +551,10 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven client.images += A.pipe_image /mob/living/proc/remove_ventcrawl() + SEND_SIGNAL(src, COMSIG_LIVING_EXIT_VENTCRAWL) + remove_ventcrawl_images() + +/mob/living/proc/remove_ventcrawl_images() if(client) for(var/image/current_image in pipes_shown) client.images -= current_image @@ -567,8 +576,10 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven else if(is_ventcrawling(src)) if(target_move) - remove_ventcrawl() - add_ventcrawl(loc, target_move) + remove_ventcrawl_images() + var/obj/machinery/atmospherics/current_pipe = loc + var/datum/pipeline/pipenet = current_pipe.returnPipenet(target_move) + add_ventcrawl_images(pipenet) //Throwing stuff