Skip to content

Commit

Permalink
[MIRROR] Moves thinking_IC variable to a trait [MDB IGNORE] (Skyrat…
Browse files Browse the repository at this point in the history
…-SS13#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 <[email protected]>
  • Loading branch information
SkyratBot and san7890 authored Dec 5, 2023
1 parent ac72f49 commit a22c5fd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions code/datums/brain_damage/imaginary_friend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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()

Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

26 changes: 14 additions & 12 deletions code/modules/tgui_input/say_modal/typing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -55,40 +55,43 @@
* 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)

/**
* Callback to remove the typing indicator after a brief period of inactivity.
* 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)
Expand All @@ -101,7 +104,6 @@
active_typing_indicator = null

/mob/living/remove_all_indicators()
thinking_IC = FALSE
remove_thinking_indicator()
remove_typing_indicator()

0 comments on commit a22c5fd

Please sign in to comment.