From a22c5fde787f1c139ee0594cf1c5d7138cec1b60 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:32:25 +0100 Subject: [PATCH] [MIRROR] Moves `thinking_IC` variable to a trait [MDB IGNORE] (#25441) * Moves `thinking_IC` variable to a trait (#80122) ## About The Pull Request This was another boolean that was used to just manage stuff codeside that really was not accessed _too_ much and is ultimately not useful as a variable on `/mob`. This just moves it to a trait because it's only really used in a few spots for a similar intent+purpose. ## Why It's Good For The Game Less stuff to deal with in the average view variables window whenever looking at a mob, which is really nice and welcome. ## Changelog Doesn't concern players. * Moves `thinking_IC` variable to a trait --------- Co-authored-by: san7890 --- code/__DEFINES/traits/declarations.dm | 3 +++ code/__DEFINES/traits/sources.dm | 3 +++ code/_globalvars/traits/_traits.dm | 1 + code/datums/brain_damage/imaginary_friend.dm | 6 ++--- code/modules/mob/mob_defines.dm | 2 -- code/modules/tgui_input/say_modal/typing.dm | 26 +++++++++++--------- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/code/__DEFINES/traits/declarations.dm b/code/__DEFINES/traits/declarations.dm index 29a167a5c72a43..3f535278a75691 100644 --- a/code/__DEFINES/traits/declarations.dm +++ b/code/__DEFINES/traits/declarations.dm @@ -963,6 +963,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai /// the object has a label applied #define TRAIT_HAS_LABEL "labeled" +/// Trait given to a mob that is currently thinking (giving off the "thinking" icon), used in an IC context +#define TRAIT_THINKING_IN_CHARACTER "currently_thinking_IC" + ///without a human having this trait, they speak as if they have no tongue. #define TRAIT_SPEAKS_CLEARLY "speaks_clearly" diff --git a/code/__DEFINES/traits/sources.dm b/code/__DEFINES/traits/sources.dm index d472b9bed2675a..f0b67a95b92a70 100644 --- a/code/__DEFINES/traits/sources.dm +++ b/code/__DEFINES/traits/sources.dm @@ -250,6 +250,9 @@ /// Hearing trait that is from the hearing component #define CIRCUIT_HEAR_TRAIT "circuit_hear" +/// This trait comes from when a mob is currently typing. +#define CURRENTLY_TYPING_TRAIT "currently_typing" + /** * Trait granted by [/mob/living/carbon/Initialize] and * granted/removed by [/obj/item/organ/internal/tongue] diff --git a/code/_globalvars/traits/_traits.dm b/code/_globalvars/traits/_traits.dm index f9cc2e9e4c44bb..6bb2fddcd59d7c 100644 --- a/code/_globalvars/traits/_traits.dm +++ b/code/_globalvars/traits/_traits.dm @@ -418,6 +418,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_TENTACLE_IMMUNE" = TRAIT_TENTACLE_IMMUNE, "TRAIT_TESLA_SHOCKIMMUNE" = TRAIT_TESLA_SHOCKIMMUNE, "TRAIT_THERMAL_VISION" = TRAIT_THERMAL_VISION, + "TRAIT_THINKING_IN_CHARACTER" = TRAIT_THINKING_IN_CHARACTER, "TRAIT_THROWINGARM" = TRAIT_THROWINGARM, "TRAIT_TIME_STOP_IMMUNE" = TRAIT_TIME_STOP_IMMUNE, "TRAIT_TOWER_OF_BABEL" = TRAIT_TOWER_OF_BABEL, diff --git a/code/datums/brain_damage/imaginary_friend.dm b/code/datums/brain_damage/imaginary_friend.dm index 61175593ce4d7f..922e43c8f00458 100644 --- a/code/datums/brain_damage/imaginary_friend.dm +++ b/code/datums/brain_damage/imaginary_friend.dm @@ -390,7 +390,7 @@ 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) /mob/camera/imaginary_friend/create_thinking_indicator() - if(active_thinking_indicator || active_typing_indicator || !thinking_IC) + if(active_thinking_indicator || active_typing_indicator || !HAS_TRAIT(src, TRAIT_THINKING_IN_CHARACTER)) return FALSE active_thinking_indicator = image('icons/mob/effects/talk.dmi', src, "[bubble_icon]3", TYPING_LAYER) add_image_to_clients(active_thinking_indicator, group_clients()) @@ -402,19 +402,19 @@ active_thinking_indicator = null /mob/camera/imaginary_friend/create_typing_indicator() - if(active_typing_indicator || active_thinking_indicator || !thinking_IC) + if(active_typing_indicator || active_thinking_indicator || !HAS_TRAIT(src, TRAIT_THINKING_IN_CHARACTER)) return FALSE active_typing_indicator = image('icons/mob/effects/talk.dmi', src, "[bubble_icon]0", TYPING_LAYER) add_image_to_clients(active_typing_indicator, group_clients()) /mob/camera/imaginary_friend/remove_typing_indicator() + REMOVE_TRAIT(src, TRAIT_THINKING_IN_CHARACTER, CURRENTLY_TYPING_TRAIT) if(!active_typing_indicator) return FALSE remove_image_from_clients(active_typing_indicator, group_clients()) active_typing_indicator = null /mob/camera/imaginary_friend/remove_all_indicators() - thinking_IC = FALSE remove_thinking_indicator() remove_typing_indicator() diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 32766db5ab73e3..ffc343f491db99 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -212,6 +212,4 @@ var/active_typing_indicator ///the icon currently used for the thinking indicator's bubble var/active_thinking_indicator - /// User is thinking in character. Used to revert to thinking state after stop_typing - var/thinking_IC = FALSE diff --git a/code/modules/tgui_input/say_modal/typing.dm b/code/modules/tgui_input/say_modal/typing.dm index 49357fb9b5f858..d1c51d1356b6c5 100644 --- a/code/modules/tgui_input/say_modal/typing.dm +++ b/code/modules/tgui_input/say_modal/typing.dm @@ -36,14 +36,14 @@ /datum/preference/toggle/typing_indicator/apply_to_client(client/client, value) client?.typing_indicators = value -/** Sets the mob as "thinking" - with indicator and variable thinking_IC */ +/** Sets the mob as "thinking" - with indicator and the TRAIT_THINKING_IN_CHARACTER trait */ /datum/tgui_say/proc/start_thinking() if(!window_open || !client.typing_indicators) return FALSE /// Special exemptions if(isabductor(client.mob)) return FALSE - client.mob.thinking_IC = TRUE + ADD_TRAIT(client.mob, TRAIT_THINKING_IN_CHARACTER, CURRENTLY_TYPING_TRAIT) client.mob.create_thinking_indicator() /** Removes typing/thinking indicators and flags the mob as not thinking */ @@ -55,10 +55,11 @@ * signals the client mob to revert to the "thinking" icon. */ /datum/tgui_say/proc/start_typing() - client.mob.remove_thinking_indicator() - if(!window_open || !client.typing_indicators || !client.mob.thinking_IC) + var/mob/client_mob = client.mob + client_mob.remove_thinking_indicator() + if(!window_open || !client.typing_indicators || !HAS_TRAIT(client_mob, TRAIT_THINKING_IN_CHARACTER)) return FALSE - client.mob.create_typing_indicator() + client_mob.create_typing_indicator() addtimer(CALLBACK(src, PROC_REF(stop_typing)), 5 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_STOPPABLE) /** @@ -66,29 +67,31 @@ * If the user was typing IC, the thinking indicator is shown. */ /datum/tgui_say/proc/stop_typing() - if(!client?.mob) + if(isnull(client?.mob)) return FALSE - client.mob.remove_typing_indicator() - if(!window_open || !client.typing_indicators || !client.mob.thinking_IC) + var/mob/client_mob = client.mob + client_mob.remove_typing_indicator() + if(!window_open || !client.typing_indicators || !HAS_TRAIT(client_mob, TRAIT_THINKING_IN_CHARACTER)) return FALSE - client.mob.create_thinking_indicator() + client_mob.create_thinking_indicator() /// Overrides for overlay creation /mob/living/create_thinking_indicator() - if(active_thinking_indicator || active_typing_indicator || !thinking_IC || stat != CONSCIOUS ) + if(active_thinking_indicator || active_typing_indicator || stat != CONSCIOUS || !HAS_TRAIT(src, TRAIT_THINKING_IN_CHARACTER)) return FALSE active_thinking_indicator = mutable_appearance('icons/mob/effects/talk.dmi', "[bubble_icon]3", TYPING_LAYER) add_overlay(active_thinking_indicator) play_fov_effect(src, 6, "talk", ignore_self = TRUE) /mob/living/remove_thinking_indicator() + REMOVE_TRAIT(src, TRAIT_THINKING_IN_CHARACTER, CURRENTLY_TYPING_TRAIT) if(!active_thinking_indicator) return FALSE cut_overlay(active_thinking_indicator) active_thinking_indicator = null /mob/living/create_typing_indicator() - if(active_typing_indicator || active_thinking_indicator || !thinking_IC || stat != CONSCIOUS) + if(active_typing_indicator || active_thinking_indicator || stat != CONSCIOUS || !HAS_TRAIT(src, TRAIT_THINKING_IN_CHARACTER)) return FALSE active_typing_indicator = mutable_appearance('icons/mob/effects/talk.dmi', "[bubble_icon]0", TYPING_LAYER) add_overlay(active_typing_indicator) @@ -101,7 +104,6 @@ active_typing_indicator = null /mob/living/remove_all_indicators() - thinking_IC = FALSE remove_thinking_indicator() remove_typing_indicator()