From 16f01791e7abde7cf18ae65c55a8f9090f127c7e Mon Sep 17 00:00:00 2001 From: Guti <32563288+TheCaramelion@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:05:34 +0100 Subject: [PATCH] Point Refactor (#17120) * Point refactor * Big think * Fixes so Kash won't yell at me --------- Co-authored-by: Selis <12716288+ItsSelis@users.noreply.github.com> --- .../signals/signals_mobs/signals_mob_main.dm | 2 + code/game/atoms.dm | 3 + code/game/atoms_movable.dm | 6 ++ code/modules/mob/dead/observer/observer.dm | 8 +- code/modules/mob/living/living.dm | 16 ++-- code/modules/mob/mob.dm | 31 ------- code/modules/point/point.dm | 90 +++++++++++++++++++ vorestation.dme | 2 + 8 files changed, 116 insertions(+), 42 deletions(-) create mode 100644 code/__defines/dcs/signals/signals_mobs/signals_mob_main.dm create mode 100644 code/modules/point/point.dm diff --git a/code/__defines/dcs/signals/signals_mobs/signals_mob_main.dm b/code/__defines/dcs/signals/signals_mobs/signals_mob_main.dm new file mode 100644 index 00000000000..ae06f69a025 --- /dev/null +++ b/code/__defines/dcs/signals/signals_mobs/signals_mob_main.dm @@ -0,0 +1,2 @@ +///from base of /mob/verb/pointed: (atom/A) +#define COMSIG_MOB_POINTED "mob_pointed" diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 6d383c2040c..6f38250b888 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -56,6 +56,9 @@ * its inherent color, the colored paint applied on it, special color effect etc... */ var/list/atom_colours + /// Lazylist of all images to update when we change z levels + /// You will need to manage adding/removing from this yourself, but I'll do the updating for you + var/list/image/update_on_z /atom/New(loc, ...) // Don't call ..() unless /datum/New() ever exists diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index daa473b74e7..34e349df0d0 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -654,3 +654,9 @@ cut_overlay(source) if(em_block == source) em_block = null + +/atom/movable/proc/abstract_move(atom/new_loc) + var/atom/old_loc = loc + var/direction = get_dir(old_loc, new_loc) + loc = new_loc + Moved(old_loc, direction, TRUE) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index b6b38246bd7..6b5e3575fee 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -830,11 +830,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp W.add_hiddenprint(src) W.visible_message(span_filter_notice(span_red("Invisible fingers crudely paint something in blood on [T]..."))) -/mob/observer/dead/pointed(atom/A as mob|obj|turf in view()) +/mob/observer/dead/_pointed(atom/pointed_at) if(!..()) - return 0 - src.visible_message(span_deadsay(span_bold("[src]") + " points to [A].")) - return 1 + return FALSE + + visible_message(span_deadsay(span_bold("[src]") + " points to [pointed_at].")) /mob/observer/dead/proc/manifest(mob/user) is_manifest = TRUE diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index b99aea01f72..39ccd6250f3 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -118,16 +118,18 @@ return //mob verbs are faster than object verbs. See above. -/mob/living/pointed(atom/A as mob|obj|turf in view()) +/mob/living/pointed(atom/A as mob|obj|turf in view(client.view, src)) if(src.stat || src.restrained()) - return 0 + return FALSE if(src.status_flags & FAKEDEATH) - return 0 - if(!..()) - return 0 + return FALSE + return ..() - src.visible_message(span_filter_notice(span_bold("[src]") + " points to [A].")) - return 1 +/mob/living/_pointed(atom/pointing_at) + if(!..()) + return FALSE + + visible_message(span_info(span_bold("[src]") + " points at [pointing_at]."), span_info("You point at [pointing_at].")) /mob/living/verb/succumb() set name = "Succumb to death" diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index ede01edc639..fec32f347c3 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -251,37 +251,6 @@ client.eye = loc return TRUE -/mob/verb/pointed(atom/A as mob|obj|turf in view()) - set name = "Point To" - set category = "Object" - - if(!src || !isturf(loc) || !(A in view(loc))) - return 0 - if(istype(A, /obj/effect/decal/point)) - return 0 - - var/turf/tile = get_turf(A) - if (!tile) - return 0 - - var/turf/our_tile = get_turf(src) - var/obj/visual = new /obj/effect/decal/point(our_tile) - visual.invisibility = invisibility - visual.plane = ABOVE_PLANE - visual.layer = FLY_LAYER - - animate(visual, - pixel_x = (tile.x - our_tile.x) * world.icon_size + A.pixel_x, - pixel_y = (tile.y - our_tile.y) * world.icon_size + A.pixel_y, - time = 1.7, - easing = EASE_OUT) - - QDEL_IN(visual, 2 SECONDS) //Better qdel - - face_atom(A) - return 1 - - /mob/proc/ret_grab(list/L, flag) return diff --git a/code/modules/point/point.dm b/code/modules/point/point.dm new file mode 100644 index 00000000000..02c9295a9fc --- /dev/null +++ b/code/modules/point/point.dm @@ -0,0 +1,90 @@ +#define POINT_TIME (2.5 SECONDS) + +/atom/movable/proc/point_at(atom/pointed_atom) + if(!isturf(loc)) + return + + if (pointed_atom in src) + create_point_bubble(pointed_atom) + return + + var/turf/tile = get_turf(pointed_atom) + if (!tile) + return + + var/turf/our_tile = get_turf(src) + var/obj/visual = new /obj/effect/temp_visual/point(our_tile, invisibility) + + animate(visual, pixel_x = (tile.x - our_tile.x) * world.icon_size + pointed_atom.pixel_x, pixel_y = (tile.y - our_tile.y) * world.icon_size + pointed_atom.pixel_y, time = 1.7, easing = EASE_OUT) + +/atom/movable/proc/create_point_bubble(atom/pointed_atom) + var/mutable_appearance/thought_bubble = mutable_appearance( + 'icons/effects/effects.dmi', + "thought_bubble", + plane = PLANE_RUNECHAT, + appearance_flags = KEEP_APART, + ) + + var/mutable_appearance/pointed_atom_appearance = new(pointed_atom.appearance) + pointed_atom_appearance.blend_mode = BLEND_INSET_OVERLAY + pointed_atom_appearance.plane = FLOAT_PLANE + pointed_atom_appearance.layer = FLOAT_LAYER + pointed_atom_appearance.pixel_x = 0 + pointed_atom_appearance.pixel_y = 0 + thought_bubble.overlays += pointed_atom_appearance + + thought_bubble.pixel_x = 16 + thought_bubble.pixel_y = 32 + thought_bubble.alpha = 200 + thought_bubble.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + + var/mutable_appearance/point_visual = mutable_appearance( + 'icons/mob/screen1.dmi', + "arrow" + ) + + thought_bubble.overlays += point_visual + + add_overlay(thought_bubble) + LAZYADD(update_on_z, thought_bubble) + addtimer(CALLBACK(src, PROC_REF(clear_point_bubble), thought_bubble), POINT_TIME) + +/atom/movable/proc/clear_point_bubble(mutable_appearance/thought_bubble) + LAZYREMOVE(update_on_z, thought_bubble) + cut_overlay(thought_bubble) + +/obj/effect/temp_visual/point + name = "pointer" + icon = 'icons/mob/screen1.dmi' + icon_state = "arrow" + plane = ABOVE_PLANE + duration = POINT_TIME + +/obj/effect/temp_visual/point/Initialize(mapload, set_invis = 0) + . = ..() + var/atom/old_loc = loc + abstract_move(get_turf(src)) + pixel_x = old_loc.pixel_x + pixel_y = old_loc.pixel_y + invisibility = set_invis + +#undef POINT_TIME + +/mob/verb/pointed(atom/A as mob|obj|turf in view()) + set name = "Point To" + set category = "Object" + + if(istype(A, /obj/effect/temp_visual/point)) + return FALSE + + DEFAULT_QUEUE_OR_CALL_VERB(VERB_CALLBACK(src, PROC_REF(_pointed), A)) + +/mob/proc/_pointed(atom/pointing_at) + if(client && !(pointing_at in view(client.view, src))) + return FALSE + + point_at(pointing_at) + + SEND_SIGNAL(src, COMSIG_MOB_POINTED, pointing_at) + face_atom(pointing_at) + return TRUE diff --git a/vorestation.dme b/vorestation.dme index f8a53aae189..cafadaf7161 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -168,6 +168,7 @@ #include "code\__defines\dcs\helpers.dm" #include "code\__defines\dcs\signals.dm" #include "code\__defines\dcs\signals\signals_subsystem.dm" +#include "code\__defines\dcs\signals\signals_mobs\signals_mob_main.dm" #include "code\__defines\dcs\signals\signals_turf.dm" #include "code\__defines\traits\_traits.dm" #include "code\__defines\traits\declarations.dm" @@ -3752,6 +3753,7 @@ #include "code\modules\planet\weather.dm" #include "code\modules\player_tips_vr\player_tips_controller_vr.dm" #include "code\modules\player_tips_vr\player_tips_list_vr.dm" +#include "code\modules\point\point.dm" #include "code\modules\power\apc.dm" #include "code\modules\power\batteryrack.dm" #include "code\modules\power\batteryrack_vr.dm"