Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated Locker Doors #9706

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/game/objects/effects/overlays.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@
// in case some caveman is still using 512
/obj/effect/overlay/airlock_part/Click()
parent.Click(arglist(args))

/obj/effect/overlay/closet_door
anchored = TRUE
plane = FLOAT_PLANE
layer = FLOAT_LAYER
vis_flags = VIS_INHERIT_ID
appearance_flags = KEEP_TOGETHER | LONG_GLIDE | PIXEL_SCALE
75 changes: 61 additions & 14 deletions code/game/objects/structures/crates_lockers/closets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
var/datum/gas_mixture/air_contents
var/airtight_when_welded = TRUE
var/airtight_when_closed = FALSE

var/obj/effect/overlay/closet_door/door_obj
var/is_animating_door = FALSE
var/door_anim_squish = 0.12
var/door_anim_angle = 136
var/door_hinge_x = -6.5
var/door_anim_time = 2.5 // set to 0 to make the door not animate at all

/obj/structure/closet/Initialize(mapload)
if(mapload && !opened) // if closed, any item at the crate's loc is put in the contents
Expand All @@ -58,24 +63,64 @@
cut_overlays()
if(!opened)
layer = OBJ_LAYER
if(icon_door)
add_overlay("[icon_door]_door")
else
add_overlay("[icon_state]_door")
if(welded)
add_overlay(icon_welded)
if(secure && !broken)
if(locked)
add_overlay("locked")
if(!is_animating_door)
if(icon_door)
add_overlay("[icon_door]_door")
else
add_overlay("unlocked")
add_overlay("[icon_state]_door")
if(welded)
add_overlay(icon_welded)
if(secure && !broken)
if(locked)
add_overlay("locked")
else
add_overlay("unlocked")

else
layer = BELOW_OBJ_LAYER
if(icon_door_override)
add_overlay("[icon_door]_open")
if(!is_animating_door)
if(icon_door_override)
add_overlay("[icon_door]_open")
else
add_overlay("[icon_state]_open")

/obj/structure/closet/proc/animate_door(var/closing = FALSE)
if(!door_anim_time)
return
if(!door_obj) door_obj = new
vis_contents |= door_obj
door_obj.icon = icon
door_obj.icon_state = "[icon_door || icon_state]_door"
is_animating_door = TRUE
var/num_steps = door_anim_time / world.tick_lag
for(var/I in 0 to num_steps)
var/angle = door_anim_angle * (closing ? 1 - (I/num_steps) : (I/num_steps))
var/matrix/M = get_door_transform(angle)
var/door_state = angle >= 90 ? "[icon_door_override ? icon_door : icon_state]_back" : "[icon_door || icon_state]_door"
var/door_layer = angle >= 90 ? FLOAT_LAYER : ABOVE_MOB_LAYER

if(I == 0)
door_obj.transform = M
door_obj.icon_state = door_state
door_obj.layer = door_layer
else if(I == 1)
animate(door_obj, transform = M, icon_state = door_state, layer = door_layer, time = world.tick_lag, flags = ANIMATION_END_NOW)
else
add_overlay("[icon_state]_open")
animate(transform = M, icon_state = door_state, layer = door_layer, time = world.tick_lag)
addtimer(CALLBACK(src,.proc/end_door_animation),door_anim_time,TIMER_UNIQUE|TIMER_OVERRIDE)

/obj/structure/closet/proc/end_door_animation()
is_animating_door = FALSE
vis_contents -= door_obj
update_icon()
COMPILE_OVERLAYS(src)

/obj/structure/closet/proc/get_door_transform(angle)
var/matrix/M = matrix()
M.Translate(-door_hinge_x, 0)
M.Multiply(matrix(cos(angle), 0, 0, -sin(angle) * door_anim_squish, 1, 0))
M.Translate(door_hinge_x, 0)
return M

/obj/structure/closet/examine(mob/user)
.=..()
Expand Down Expand Up @@ -146,6 +191,7 @@
density = FALSE
climb_time *= 0.5 //it's faster to climb onto an open thing
dump_contents()
animate_door(FALSE)
update_icon()
update_airtightness()
return 1
Expand Down Expand Up @@ -199,6 +245,7 @@
climb_time = initial(climb_time)
opened = FALSE
density = TRUE
animate_door(TRUE)
update_icon()
update_airtightness()
close_storage(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
delivery_icon = null //unwrappable
anchorable = FALSE
notreallyacloset = TRUE
door_anim_time = 0 // no animation
var/foldedbag_path = /obj/item/bodybag
var/obj/item/bodybag/foldedbag_instance = null
var/tagged = 0 // so closet code knows to put the tag overlay back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
material_drop = /obj/item/stack/sheet/cardboard
delivery_icon = "deliverybox"
anchorable = FALSE
door_anim_time = 0 // no animation
var/move_speed_multiplier = 1
var/move_delay = FALSE
var/egged = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
icon_state = "cabinet"
resistance_flags = FLAMMABLE
max_integrity = 70
door_anim_time = 0 // no animation

/obj/structure/closet/acloset
name = "strange closet"
desc = "It looks alien!"
icon_state = "alien"
door_anim_time = 0 // no animation


/obj/structure/closet/gimmick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
icon_state = "cabinet"
resistance_flags = FLAMMABLE
max_integrity = 70
door_anim_time = 0 // no animation

/obj/structure/closet/secure_closet/bar/PopulateContents()
..()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/obj/structure/closet/secure_closet/freezer
icon_state = "freezer"
var/jones = FALSE
door_anim_squish = 0.22
door_anim_angle = 123
door_anim_time = 4

/obj/structure/closet/secure_closet/freezer/Destroy()
recursive_organ_check(src)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
icon_state = "cabinet"
resistance_flags = FLAMMABLE
max_integrity = 70
door_anim_time = 0 // no animation

/obj/structure/closet/secure_closet/detective/PopulateContents()
..()
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/structures/crates_lockers/crates.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
climb_time = 10 //real fast, because let's be honest stepping into or onto a crate is easy
climb_stun = 0 //climbing onto crates isn't hard, guys
delivery_icon = "deliverycrate"
door_anim_time = 0 // no animation
var/obj/item/paper/fluff/jobs/cargo/manifest/manifest

/obj/structure/closet/crate/Initialize()
Expand Down
Binary file modified icons/obj/closet.dmi
Binary file not shown.