Merge pull request #8205 from Cerebulon/lockeranims

Locker Opening Animations Port
This commit is contained in:
MistakeNot4892
2021-08-19 15:10:23 +10:00
committed by GitHub
22 changed files with 110 additions and 18 deletions

View File

@@ -7,10 +7,10 @@
density = 1
w_class = ITEMSIZE_HUGE
layer = UNDER_JUNK_LAYER
var/opened = 0
var/sealed = 0
var/seal_tool = /obj/item/weapon/weldingtool //Tool used to seal the closet, defaults to welder
var/wall_mounted = 0 //never solid (You can always pass over it)
var/health = 100
@@ -35,6 +35,19 @@
var/closet_appearance = /decl/closet_appearance // The /decl that defines what decals we end up with, that makes our look unique
/// Currently animating the door transform
var/is_animating_door = FALSE
/// Length of time (ds) to animate the door transform
var/door_anim_time = 2.0
/// Amount to 'squish' the full width of the door by
var/door_anim_squish = 0.30
/// Virtual angle at which the door is opened to (136 by default, so not a full 180)
var/door_anim_angle = 136
/// Offset for the door hinge location from centerline
var/door_hinge = -6.5
/// Our visual object for the closet door
var/obj/effect/overlay/closet_door/door_obj
/obj/structure/closet/Initialize()
..()
return INITIALIZE_HINT_LATELOAD
@@ -65,6 +78,10 @@
color = null
update_icon()
/obj/structure/closet/Destroy()
. = ..()
qdel_null(door_obj)
/obj/structure/closet/examine(mob/user)
. = ..()
if(Adjacent(user) || isobserver(user))
@@ -133,7 +150,7 @@
playsound(src, open_sound, 15, 1, -3)
if(initial(density))
density = !density
update_icon()
animate_door()
return 1
/obj/structure/closet/proc/close()
@@ -158,7 +175,7 @@
playsound(src, close_sound, 15, 1, -3)
if(initial(density))
density = !density
update_icon()
animate_door(TRUE)
return 1
//Cham Projector Exception
@@ -213,10 +230,11 @@
/obj/structure/closet/proc/toggle(mob/user as mob)
if(is_animating_door)
return
if(!(opened ? close() : open()))
to_chat(user, "<span class='notice'>It won't budge!</span>")
return
update_icon()
// this should probably use dump_contents()
/obj/structure/closet/ex_act(severity)
@@ -480,8 +498,45 @@
spawn(1) qdel(src)
return 1
// Just a generic cabinet for mappers to use
/obj/structure/closet/cabinet
name = "cabinet"
icon = 'icons/obj/closets/bases/cabinet.dmi'
closet_appearance = /decl/closet_appearance/cabinet
/obj/structure/closet/proc/animate_door(closing = FALSE)
if(!door_anim_time)
update_icon()
return
if(!door_obj)
door_obj = new
vis_contents |= door_obj
door_obj.icon = icon
door_obj.icon_state = "door_front"
is_animating_door = TRUE
if(!closing)
update_icon()
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 ? "door_back" : "door_front"
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
animate(transform = M, icon_state = door_state, layer = door_layer, time = world.tick_lag)
addtimer(CALLBACK(src,.proc/end_door_animation,closing),door_anim_time,TIMER_UNIQUE|TIMER_OVERRIDE)
/obj/structure/closet/proc/end_door_animation(closing = FALSE)
is_animating_door = FALSE
if(closing)
// There's not really harm in leaving it on, but, one less atom to send to clients to render when lockers are closed
vis_contents -= door_obj
update_icon()
/obj/structure/closet/proc/get_door_transform(angle)
var/matrix/M = matrix()
M.Translate(-door_hinge, 0)
M.Multiply(matrix(cos(angle), 0, 0, -sin(angle) * door_anim_squish, 1, 0))
M.Translate(door_hinge, 0)
return M

View File

@@ -33,6 +33,8 @@
var/icon/closed_locked_welded_icon
var/icon/closed_unlocked_icon
var/icon/closed_unlocked_welded_icon
var/icon/door_front_icon
var/icon/door_back_icon
// Create open icon.
var/icon/new_icon = new
@@ -40,6 +42,8 @@
open_icon.Blend(icon(base_icon, "open"), ICON_OVERLAY)
open_icon.Blend(color, BLEND_ADD)
open_icon.Blend(icon(base_icon, "interior"), ICON_OVERLAY)
door_back_icon = icon(base_icon, "door_back")
door_back_icon.Blend(color, BLEND_ADD)
if(decal_icon)
for(var/thing in decals)
var/icon/this_decal_icon = icon(decal_icon, "[thing]_open")
@@ -47,6 +51,8 @@
open_icon.Blend(this_decal_icon, ICON_OVERLAY)
// Generate basic closed icons.
door_front_icon = icon(base_icon, "door_front")
door_front_icon.Blend(color, BLEND_ADD)
closed_emagged_icon = icon(base_icon, "base")
if(can_lock)
closed_emagged_icon.Blend(icon(base_icon, "lock"), ICON_OVERLAY)
@@ -56,6 +62,10 @@
var/icon/this_decal_icon = icon(decal_icon, thing)
this_decal_icon.Blend(decals[thing], BLEND_ADD)
closed_emagged_icon.Blend(this_decal_icon, ICON_OVERLAY)
door_front_icon.Blend(this_decal_icon, ICON_OVERLAY)
door_front_icon.AddAlphaMask(icon(base_icon, "door_front")) // Remove pesky 'more than just door' decals
closed_locked_icon = icon(closed_emagged_icon)
closed_unlocked_icon = icon(closed_emagged_icon)
@@ -90,6 +100,8 @@
new_icon.Insert(closed_locked_welded_icon, "closed_locked_welded")
new_icon.Insert(closed_unlocked_icon, "closed_unlocked")
new_icon.Insert(closed_unlocked_welded_icon, "closed_unlocked_welded")
new_icon.Insert(door_front_icon, "door_front")
new_icon.Insert(door_back_icon, "door_back")
// Set icon!
icon = new_icon

View File

@@ -2,11 +2,12 @@
name = "coffin"
desc = "It's a burial receptacle for the dearly departed."
icon = 'icons/obj/closets/coffin.dmi'
icon_state = "closed_unlocked"
seal_tool = /obj/item/weapon/tool/screwdriver
breakout_sound = 'sound/weapons/tablehit1.ogg'
closet_appearance = null // Special icon for us
door_anim_time = 0 //Unsupported
/* Graves */
/obj/structure/closet/grave
@@ -20,6 +21,7 @@
max_closets = 1
opened = 1
closet_appearance = null // Special icon for us
door_anim_time = 0 //Unsupported
/obj/structure/closet/grave/attack_hand(mob/user as mob)
if(opened)

View File

@@ -1,4 +1,5 @@
/obj/structure/closet/crate/critter
name = "critter crate"
desc = "A crate which can sustain life for a while."
closet_appearance = /decl/closet_appearance/large_crate/critter
closet_appearance = /decl/closet_appearance/large_crate/critter
door_anim_time = 0 //Unsupported

View File

@@ -1,7 +1,9 @@
/obj/structure/closet/cabinet
name = "cabinet"
desc = "Old will forever be in fashion."
icon = 'icons/obj/closets/bases/cabinet.dmi'
closet_appearance = /decl/closet_appearance/cabinet
door_anim_time = 0 //Unsupported
/obj/structure/closet/acloset
name = "strange closet"

View File

@@ -1,6 +1,7 @@
/obj/structure/closet/secure_closet/freezer/kitchen
name = "kitchen cabinet"
req_access = list(access_kitchen)
door_anim_time = 0 //Unsupported
starts_with = list(
/obj/item/weapon/reagent_containers/food/condiment/flour = 7,
@@ -16,6 +17,7 @@
name = "meat fridge"
icon = 'icons/obj/closets/fridge.dmi'
closet_appearance = null
door_anim_time = 0 //Unsupported
starts_with = list(
/obj/item/weapon/reagent_containers/food/snacks/meat/monkey = 10)
@@ -25,6 +27,7 @@
name = "refrigerator"
icon = 'icons/obj/closets/fridge.dmi'
closet_appearance = null
door_anim_time = 0 //Unsupported
starts_with = list(
/obj/item/weapon/reagent_containers/food/drinks/milk = 6,
@@ -38,6 +41,7 @@
icon = 'icons/obj/closets/fridge.dmi'
closet_appearance = null
req_access = list(access_heads_vault)
door_anim_time = 0 //Unsupported
starts_with = list(

View File

@@ -227,6 +227,7 @@
wall_mounted = 1
req_access = list(access_medical_equip)
closet_appearance = /decl/closet_appearance/wall/medical
door_anim_time = 0 // Unsupported
/obj/structure/closet/secure_closet/medical_wall/pills
name = "pill cabinet"

View File

@@ -26,6 +26,7 @@
/obj/structure/closet/secure_closet/personal/cabinet
closet_appearance = /decl/closet_appearance/cabinet/secure
door_anim_time = 0 //Unsupported
starts_with = list(
/obj/item/weapon/storage/backpack/satchel/withwallet,

View File

@@ -223,6 +223,7 @@
name = "detective's cabinet"
req_access = list(access_forensics_lockers)
closet_appearance = /decl/closet_appearance/cabinet/secure
door_anim_time = 0 //Unsupported
starts_with = list(
/obj/item/clothing/accessory/badge/holo/detective,
@@ -295,6 +296,5 @@ GLOBAL_LIST_BOILERPLATE(all_brig_closets, /obj/structure/closet/secure_closet/br
req_access = list(access_security)
closet_appearance = /decl/closet_appearance/wall
density = 1
//too small to put a man in
large = 0
door_anim_time = 0 // Unsupported
large = 0 //too small to put a man in

View File

@@ -6,6 +6,7 @@
density = 1
anchored = 1
health = 0 //destroying the statue kills the mob within
door_anim_time = 0 // Why is this a closet??
var/intialTox = 0 //these are here to keep the mob from taking damage from things that logically wouldn't affect a rock
var/intialFire = 0 //it's a little sloppy I know but it was this or the GODMODE flag. Lesser of two evils.
var/intialBrute = 0
@@ -43,7 +44,7 @@
qdel(src)
return
START_PROCESSING(SSobj, src)
START_PROCESSING(SSobj, src)
..()
/obj/structure/closet/statue/process()

View File

@@ -186,6 +186,7 @@
anchored = 1
density = 0
wall_mounted = 1
door_anim_time = 0 // Unsupported
starts_with = list(
/obj/item/clothing/suit/fire/firefighter,

View File

@@ -10,6 +10,7 @@
anchored = 1
store_mobs = 0
wall_mounted = 1
door_anim_time = 0 // Unsupported
//spawns 2 sets of breathmask, emergency oxy tank and crowbar
@@ -68,6 +69,7 @@
wall_mounted = 1
plane = TURF_PLANE
layer = ABOVE_TURF_LAYER
door_anim_time = 0 // Unsupported
/obj/structure/closet/walllocker_double/north
pixel_y = 32
@@ -108,7 +110,7 @@
/obj/structure/closet/walllocker_double/kitchen/east
pixel_x = 32
dir = EAST
/obj/structure/closet/walllocker_double/medical
name = "Medical Cabinet"
desc = "A wall mounted medical supply cabinet. Probably full of drugs!" //not actually full of drugs, sorry!
@@ -129,7 +131,7 @@
/obj/structure/closet/walllocker_double/medical/east
pixel_x = 32
dir = EAST
/obj/structure/closet/walllocker_double/hydrant
name = "fire-safety closet"
desc = "It's a storage cabinet packed with fire-fighting supplies."

View File

@@ -7,6 +7,7 @@
closet_appearance = /decl/closet_appearance/crate
climbable = 1
dir = 4 //Spawn facing 'forward' by default.
door_anim_time = 0 //Unsupported until appropriate sprites are available
var/points_per_crate = 5
var/rigged = 0