diff --git a/code/game/objects/structures/crates_lockers/closet_see_inside.dm b/code/game/objects/structures/crates_lockers/closet_see_inside.dm new file mode 100644 index 00000000000..7895d31d519 --- /dev/null +++ b/code/game/objects/structures/crates_lockers/closet_see_inside.dm @@ -0,0 +1,106 @@ +/// Responsible for showing the insides of a closet to those inside it. +/datum/closet_see_inside + var/obj/structure/closet/closet + + var/image/background_image + var/image/contents_image + + var/list/client/clients_looking_at_image = list() + + var/door_alpha = 85 + +/datum/closet_see_inside/New(obj/structure/closet/closet) + src.closet = closet + + RegisterSignal(closet, COMSIG_ATOM_ENTERED, PROC_REF(on_atom_entered)) + RegisterSignal(closet, COMSIG_ATOM_EXITED, PROC_REF(on_atom_exited)) + +/datum/closet_see_inside/Destroy(force) + if (contents_image) + for (var/client/looking_at_image as anything in clients_looking_at_image) + looking_at_image.images -= background_image + looking_at_image.images -= contents_image + + contents_image.vis_contents.Cut() + + clients_looking_at_image.Cut() + + + return ..() + +/datum/closet_see_inside/proc/create_image() + contents_image = new + contents_image.loc = closet + contents_image.appearance_flags |= KEEP_TOGETHER + + background_image = image( + icon = closet.icon, + icon_state = closet.base_icon_state == null ? initial(closet.icon_state) : closet.base_icon_state, + loc = closet, + layer = BELOW_OBJ_LAYER, + ) + background_image.color = COLOR_GRAY + background_image.opacity = MOUSE_OPACITY_TRANSPARENT + background_image.override = TRUE + + contents_image.add_filter( + "mask", + 1, + list( + type = "alpha", + icon = icon('icons/effects/closet_see_inside_mask.dmi', "mask"), + y = -3, + ) + ) + + contents_image.add_filter( + "color", + 2, + list( + type = "color", + color = COLOR_GRAY, + ) + ) + + if (closet.enable_door_overlay) + var/obj/effect/overlay/door = new + door.icon = closet.icon + door.icon_state = "[closet.icon_door || background_image.icon_state]_door" + door.alpha = door_alpha + door.layer = ABOVE_ALL_MOB_LAYER + door.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + contents_image.vis_contents += door + + for (var/atom/movable/movable in closet) + contents_image.vis_contents += movable + +/datum/closet_see_inside/proc/on_atom_entered(obj/structure/closet/source, atom/movable/arrived) + SIGNAL_HANDLER + + if (contents_image) + contents_image.vis_contents += arrived + + if (ismob(arrived)) + var/mob/arrived_mob = arrived + var/client/client = GET_CLIENT(arrived_mob) + if (client) + create_image() + clients_looking_at_image += client + client.images += background_image + client.images += contents_image + +/datum/closet_see_inside/proc/on_atom_exited(obj/structure/closet/source, atom/movable/exited) + SIGNAL_HANDLER + + if (!contents_image) + return + + contents_image.vis_contents -= exited + + if (ismob(exited)) + var/mob/exited_mob = exited + var/client/client = GET_CLIENT(exited_mob) + if (client) + clients_looking_at_image -= client + client.images -= background_image + client.images -= contents_image diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index d80fd500987..0ac1518a69d 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -101,6 +101,9 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets) /// how many pixels the closet can shift on the y axes when shaking var/y_shake_pixel_shift = 1 + VAR_PRIVATE + datum/closet_see_inside/closet_see_inside + /datum/armor/structure_closet melee = 20 bullet = 10 @@ -153,6 +156,8 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets) if(is_station_level(z) && mapload) add_to_roundstart_list() + closet_see_inside = new(src) + // if closed, any item at the crate's loc is put in the contents if (mapload) is_maploaded = TRUE @@ -203,6 +208,7 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets) id_card = null QDEL_NULL(internal_air) QDEL_NULL(door_obj) + QDEL_NULL(closet_see_inside) GLOB.roundstart_station_closets -= src return ..() @@ -978,7 +984,6 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets) return container_resist_act(user) - /obj/structure/closet/attack_hand(mob/living/user, list/modifiers) . = ..() if(.) diff --git a/icons/effects/closet_see_inside_mask.dmi b/icons/effects/closet_see_inside_mask.dmi new file mode 100644 index 00000000000..70d22d84d22 Binary files /dev/null and b/icons/effects/closet_see_inside_mask.dmi differ diff --git a/tgstation.dme b/tgstation.dme index 87a2c5018be..f0ca8d90c7f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3035,6 +3035,7 @@ #include "code\game\objects\structures\construction_console\construction_console.dm" #include "code\game\objects\structures\construction_console\construction_console_aux.dm" #include "code\game\objects\structures\construction_console\construction_console_centcom.dm" +#include "code\game\objects\structures\crates_lockers\closet_see_inside.dm" #include "code\game\objects\structures\crates_lockers\closets.dm" #include "code\game\objects\structures\crates_lockers\crates.dm" #include "code\game\objects\structures\crates_lockers\closets\bodybag.dm"