From 487ba1a0d36ff01986ea88c7bb8413d13ba51e11 Mon Sep 17 00:00:00 2001 From: Lucy Date: Fri, 3 May 2024 23:15:45 -0400 Subject: [PATCH] Ghost orbit menu now auto-updates --- .../dcs/signals/signals_carbon.dm | 3 +++ code/datums/elements/point_of_interest.dm | 25 +++++++++++++++++++ code/game/data_huds.dm | 1 + .../antagonists/_common/antag_datum.dm | 10 ++++++++ 4 files changed, 39 insertions(+) diff --git a/code/__DEFINES/~monkestation/dcs/signals/signals_carbon.dm b/code/__DEFINES/~monkestation/dcs/signals/signals_carbon.dm index e90390892b72..b7e3f36deceb 100644 --- a/code/__DEFINES/~monkestation/dcs/signals/signals_carbon.dm +++ b/code/__DEFINES/~monkestation/dcs/signals/signals_carbon.dm @@ -3,3 +3,6 @@ #define COMSIG_HUMAN_BEGIN_DUEL "human_begin_duel" #define COMSIG_HUMAN_END_DUEL "human_end_duel" + +/// Sent after `sec_hud_set_ID` runs - this is as close as I have right now to a "when ID changed" hook. +#define COMSIG_HUMAN_SECHUD_SET_ID "human_sechud_set_id" diff --git a/code/datums/elements/point_of_interest.dm b/code/datums/elements/point_of_interest.dm index abde86aa37ad..b0b167cfd113 100644 --- a/code/datums/elements/point_of_interest.dm +++ b/code/datums/elements/point_of_interest.dm @@ -1,6 +1,18 @@ +/* monkestation edit: added signals to autoupdate the orbit menu whenever something that might affect it happens */ /// Designates the atom as a "point of interest", meaning it can be directly orbited /datum/element/point_of_interest element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + var/static/list/update_signals = list( + COMSIG_ATOM_ORBIT_BEGIN, + COMSIG_ATOM_ORBIT_STOP, + COMSIG_MOB_STATCHANGE, + COMSIG_HUMAN_SECHUD_SET_ID, + SIGNAL_ADDTRAIT(TRAIT_UNKNOWN) + ) + COMSIG_LIVING_ADJUST_STANDARD_DAMAGE_TYPES + var/should_update = FALSE + +/datum/element/point_of_interest/New() + START_PROCESSING(SSdcs, src) /datum/element/point_of_interest/Attach(datum/target) if (!isatom(target)) @@ -13,8 +25,21 @@ return ELEMENT_INCOMPATIBLE SSpoints_of_interest.on_poi_element_added(target) + RegisterSignals(target, update_signals, PROC_REF(flag_updated)) + flag_updated() return ..() /datum/element/point_of_interest/Detach(datum/target) SSpoints_of_interest.on_poi_element_removed(target) + UnregisterSignal(target, update_signals) + flag_updated() return ..() + +/datum/element/point_of_interest/process(seconds_per_tick) + if(should_update) + INVOKE_ASYNC(GLOB.orbit_menu, TYPE_PROC_REF(/datum/orbit_menu, update_static_data_for_all_viewers)) + should_update = FALSE + +/datum/element/point_of_interest/proc/flag_updated() + SIGNAL_HANDLER + should_update = TRUE diff --git a/code/game/data_huds.dm b/code/game/data_huds.dm index 55ef35401204..0c4babcf37ba 100644 --- a/code/game/data_huds.dm +++ b/code/game/data_huds.dm @@ -284,6 +284,7 @@ Security HUDs! Basic mode shows only the job. if(!permit_icon_state) permit_icon_state = "hudfan_no" permit_holder.icon_state = permit_icon_state + SEND_SIGNAL(src, COMSIG_HUMAN_SECHUD_SET_ID) //monkestation edit end /mob/living/proc/sec_hud_set_implants() diff --git a/monkestation/code/modules/antagonists/_common/antag_datum.dm b/monkestation/code/modules/antagonists/_common/antag_datum.dm index 179004449e8d..39e16eed2634 100644 --- a/monkestation/code/modules/antagonists/_common/antag_datum.dm +++ b/monkestation/code/modules/antagonists/_common/antag_datum.dm @@ -2,6 +2,16 @@ ///The list of keys that are valid to see our antag hud/of huds we can see var/list/hud_keys +/datum/antagonist/on_gain() + . = ..() + if(show_to_ghosts) + GLOB.orbit_menu.update_static_data_for_all_viewers() + +/datum/antagonist/on_removal() + . = ..() + if(show_to_ghosts) + GLOB.orbit_menu.update_static_data_for_all_viewers() + ///Set our hud_keys, please only use this proc when changing them, if override_old_keys is FALSE then we will simply add keys, otherwise we we set our keys to only be passed ones /datum/antagonist/proc/set_hud_keys(list/keys, override_old_keys = FALSE) if(!islist(keys))