From 4a5bc992312a412e234d9a89e4733cfa5bb1aa77 Mon Sep 17 00:00:00 2001 From: SuhEugene <32931701+SuhEugene@users.noreply.github.com> Date: Fri, 22 Sep 2023 17:35:58 +0300 Subject: [PATCH] [MIRROR] Fix multitile doors opacity --- code/game/machinery/doors/door.dm | 90 ++++++++++++++++++++----- code/game/machinery/doors/multi_tile.dm | 69 ++++++++++++++----- 2 files changed, 127 insertions(+), 32 deletions(-) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 80d1a019f7430..36e411a4c70bd 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -50,6 +50,8 @@ /// Integer. Width of the door in tiles. var/width = 1 + /// List. Player view blocking fillers for multi-tile doors. + var/list/fillers // Integer. Used for intercepting clicks on our turf. Set 0 to disable click interception. Passed directly to `/datum/extension/turf_hand`. var/turf_hand_priority = 3 @@ -67,14 +69,7 @@ else layer = open_layer - - if(width > 1) - if(dir in list(EAST, WEST)) - bound_width = width * world.icon_size - bound_height = world.icon_size - else - bound_width = world.icon_size - bound_height = width * world.icon_size + update_bounds() if (turf_hand_priority) set_extension(src, /datum/extension/turf_hand, turf_hand_priority) @@ -367,13 +362,19 @@ do_animate("opening") icon_state = "door0" set_opacity(0) + if(width > 1) + set_fillers_opacity(0) sleep(3) src.set_density(0) + if(width > 1) + set_fillers_density(0) update_nearby_tiles() sleep(7) src.layer = open_layer update_icon() set_opacity(0) + if(width > 1) + set_fillers_opacity(0) operating = DOOR_OPERATING_NO if(autoclose) @@ -393,6 +394,8 @@ close_door_at = 0 do_animate("closing") src.set_density(1) + if(width > 1) + set_fillers_density(1) sleep(3) src.layer = closed_layer update_nearby_tiles() @@ -400,6 +403,8 @@ update_icon() if (visible && !glass) set_opacity(1) //caaaaarn! + if(width > 1) + set_fillers_opacity(1) operating = DOOR_OPERATING_NO //I shall not add a check every x ticks if a door has closed over some fire. @@ -438,15 +443,9 @@ /obj/machinery/door/Move(new_loc, new_dir) update_nearby_tiles() + update_bounds() . = ..() - if(width > 1) - if(dir in list(EAST, WEST)) - bound_width = width * world.icon_size - bound_height = world.icon_size - else - bound_width = world.icon_size - bound_height = width * world.icon_size if(.) deconstruct(null, TRUE) @@ -534,6 +533,67 @@ if (heat_proof) . += 4000 +/** + * Checks which way the airlock is facing and adjusts the direction accordingly. + * For use with multi-tile airlocks. + */ +/obj/machinery/door/proc/get_adjusted_dir(dir) + if(dir in list(NORTH, SOUTH)) + return EAST + else + return NORTH + +/** + * Sets the bounds of the airlock. For use with multi-tile airlocks. + * If the airlock is multi-tile, it will set the bounds to be the size of the airlock. + * If the airlock doesn't already have fillers, it will create them. + * If the airlock already has fillers, it will move them to the correct location. + */ +/obj/machinery/door/proc/update_bounds() + if(width <= 1) + return + + if(dir in list(NORTH, SOUTH)) + bound_width = width * world.icon_size + bound_height = world.icon_size + else + bound_width = world.icon_size + bound_height = width * world.icon_size + + LAZYINITLIST(fillers) + + var/adjusted_dir = get_adjusted_dir(dir) + var/obj/last_filler = src + for (var/i = 1, i < width, i++) + var/obj/airlock_filler_object/filler + + if (length(fillers) < i) + filler = new + filler.pair_airlock(src) + fillers.Add(filler) + else + filler = fillers[i] + + filler.loc = get_step(last_filler, adjusted_dir) + filler.density = density + filler.set_opacity(opacity) + + last_filler = filler + +/obj/machinery/door/proc/set_fillers_density(density) + if (!length(fillers)) + return + + for (var/obj/airlock_filler_object/filler as anything in fillers) + filler.density = density + +/obj/machinery/door/proc/set_fillers_opacity(opacity) + if (!length(fillers)) + return + + for (var/obj/airlock_filler_object/filler as anything in fillers) + filler.set_opacity(opacity) + // Public access /singleton/public_access/public_method/open_door diff --git a/code/game/machinery/doors/multi_tile.dm b/code/game/machinery/doors/multi_tile.dm index 53bb593fedb0c..ed28f2b655b4f 100644 --- a/code/game/machinery/doors/multi_tile.dm +++ b/code/game/machinery/doors/multi_tile.dm @@ -20,23 +20,6 @@ opacity = 1 assembly_type = /obj/structure/door_assembly/multi_tile -/obj/machinery/door/airlock/multi_tile/New() - ..() - SetBounds() - -/obj/machinery/door/airlock/multi_tile/Move() - . = ..() - SetBounds() - -/obj/machinery/door/airlock/multi_tile/proc/SetBounds() - if(dir in list(NORTH, SOUTH)) - bound_width = width * world.icon_size - bound_height = world.icon_size - else - bound_width = world.icon_size - bound_height = width * world.icon_size - - /obj/machinery/door/airlock/multi_tile/on_update_icon(state=0) ..() if(connections in list(NORTH, SOUTH, NORTH|SOUTH)) @@ -81,6 +64,57 @@ dirs |= direction connections = dirs + +/obj/airlock_filler_object + name = "airlock fluff" + desc = "You shouldn't be able to see this fluff!" + icon = null + icon_state = null + density = TRUE + opacity = TRUE + anchored = TRUE + invisibility = INVISIBILITY_MAXIMUM + atmos_canpass = CANPASS_DENSITY + /// The door/airlock this fluff panel is attached to + var/obj/machinery/door/filled_airlock + +/obj/airlock_filler_object/Bumped(atom/A) + if(isnull(filled_airlock)) + crash_with("Someone bumped into an airlock filler with no parent airlock specified!") + return filled_airlock.Bumped(A) + +/obj/airlock_filler_object/Destroy() + filled_airlock = null + return ..() + +/// Multi-tile airlocks pair with a filler panel, if one goes so does the other. +/obj/airlock_filler_object/proc/pair_airlock(obj/machinery/door/parent_airlock) + if(isnull(parent_airlock)) + crash_with("Attempted to pair an airlock filler with no parent airlock specified!") + + filled_airlock = parent_airlock + GLOB.destroyed_event.register(filled_airlock, src, .proc/no_airlock) + +/obj/airlock_filler_object/proc/no_airlock() + GLOB.destroyed_event.unregister(filled_airlock, src) + qdel_self() + +/// Multi-tile airlocks (using a filler panel) have special handling for movables with PASS_FLAG_GLASS +/obj/airlock_filler_object/CanPass(atom/movable/mover, turf/target) + . = ..() + if(.) + return + + if(istype(mover) && mover.checkpass(PASS_FLAG_GLASS)) + return !opacity + +/obj/airlock_filler_object/singularity_act() + return + +/obj/airlock_filler_object/singularity_pull(S, current_size) + return + + /obj/machinery/door/airlock/multi_tile/command door_color = COLOR_COMMAND_BLUE @@ -134,6 +168,7 @@ name = "Glass Airlock" damage_hitsound = 'sound/effects/Glasshit.ogg' glass = TRUE + opacity = 0 /obj/machinery/door/airlock/multi_tile/glass/command door_color = COLOR_COMMAND_BLUE