Skip to content

Commit

Permalink
[MIRROR] Fix multitile doors opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhEugene committed Sep 22, 2023
1 parent 6aab8d8 commit 4a5bc99
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 32 deletions.
90 changes: 75 additions & 15 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -393,13 +394,17 @@
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()
sleep(7)
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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
69 changes: 52 additions & 17 deletions code/game/machinery/doors/multi_tile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a5bc99

Please sign in to comment.