Skip to content

Commit

Permalink
Fix multitile doors opacity and bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustKisik committed Jun 9, 2024
1 parent 30c0f77 commit f761e7b
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 3 deletions.
89 changes: 87 additions & 2 deletions code/game/machinery/doors/_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
//Multi-tile doors
dir = SOUTH
var/width = 1
/// List. Player view blocking fillers for multi-tile doors.
var/list/fillers // SS220 ADD

//Used for intercepting clicks on our turf. Set 0 to disable click interception
var/turf_hand_priority = 3
Expand Down Expand Up @@ -95,7 +97,7 @@
else
layer = open_layer

set_bounds()
update_bounds()

if (turf_hand_priority)
set_extension(src, /datum/extension/turf_hand, turf_hand_priority)
Expand Down Expand Up @@ -436,15 +438,26 @@
do_animate("opening")
icon_state = icon_state_open
set_opacity(FALSE)

// SS220 ADD BEGIN
if(width > 1)
set_fillers_opacity(0)
// SS220 ADD END
sleep(0.5 SECONDS)
src.set_density(FALSE)
// SS220 ADD BEGIN
if(width > 1)
set_fillers_density(0)
// SS220 ADD END
update_nearby_tiles()

sleep(0.5 SECONDS)
src.layer = open_layer
update_icon()
set_opacity(FALSE)
// SS220 ADD BEGIN
if(width > 1)
set_fillers_opacity(0)
// SS220 ADD END
operating = 0

if(autoclose)
Expand All @@ -466,13 +479,21 @@

sleep(0.5 SECONDS)
src.set_density(TRUE)
// SS220 ADD BEGIN
if(width > 1)
set_fillers_density(1)
// SS220 ADD END
update_nearby_tiles()
src.layer = closed_layer

sleep(0.5 SECONDS)
update_icon()
if(visible && !glass)
set_opacity(TRUE)
// SS220 ADD BEGIN
if(width > 1)
set_fillers_opacity(1)
// SS220 ADD END
operating = 0

//I shall not add a check every x ticks if a door has closed over some fire.
Expand Down Expand Up @@ -511,6 +532,7 @@
/obj/machinery/door/Move(new_loc, new_dir)
. = ..()
update_nearby_tiles()
update_bounds() // SS220 ADD
if(.)
dismantle(TRUE)

Expand Down Expand Up @@ -619,3 +641,66 @@
name = "close door"
desc = "Closes the door if possible."
call_proc = /obj/machinery/door/proc/close

// SS220 ADD BEGIN
/**
* 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)
// SS220 ADD END
53 changes: 52 additions & 1 deletion code/game/machinery/doors/double.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,55 @@
stripe_color = COLOR_AMBER

/obj/machinery/door/airlock/double/glass/civilian
stripe_color = COLOR_CIVIE_GREEN
stripe_color = COLOR_CIVIE_GREEN

// SS220 ADD BEGIN
/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("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("Attempted to pair an airlock filler with no parent airlock specified!")

filled_airlock = parent_airlock
events_repository.unregister(/decl/observ/destroyed, filled_airlock, src, PROC_REF(no_airlock))

/obj/airlock_filler_object/proc/no_airlock()
events_repository.unregister(/decl/observ/destroyed, 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
// SS220 ADD END

0 comments on commit f761e7b

Please sign in to comment.