Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for antag huds to only display to players with specific hud keys #1265

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion code/modules/antagonists/_common/antag_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,15 @@ GLOBAL_LIST_EMPTY(antagonists)

/// Adds a HUD that will show you other members with the same antagonist.
/// If an antag typepath is passed to `antag_to_check`, will check that, otherwise will use the source type.
/datum/antagonist/proc/add_team_hud(mob/target, antag_to_check)
/datum/antagonist/proc/add_team_hud(mob/target, antag_to_check, passed_hud_keys) //monkestation edit: adds passed_hud_keys
QDEL_NULL(team_hud_ref)

team_hud_ref = WEAKREF(target.add_alt_appearance(
/datum/atom_hud/alternate_appearance/basic/has_antagonist,
"antag_team_hud_[REF(src)]",
hud_image_on(target),
antag_to_check || type,
passed_hud_keys || hud_keys, //monkestation edit
))

// Add HUDs that they couldn't see before
Expand Down
7 changes: 4 additions & 3 deletions code/modules/antagonists/_common/antag_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ GLOBAL_LIST_EMPTY_TYPED(has_antagonist_huds, /datum/atom_hud/alternate_appearanc
/datum/atom_hud/alternate_appearance/basic/has_antagonist
var/antag_datum_type

/datum/atom_hud/alternate_appearance/basic/has_antagonist/New(key, image/I, antag_datum_type)
/datum/atom_hud/alternate_appearance/basic/has_antagonist/New(key, image/I, antag_datum_type, valid_keys) //monkestation edit: adds valid_keys
src.antag_datum_type = antag_datum_type
src.valid_keys = valid_keys
GLOB.has_antagonist_huds += src
return ..(key, I, NONE)

/datum/atom_hud/alternate_appearance/basic/has_antagonist/Destroy()
GLOB.has_antagonist_huds -= src
return ..()

/datum/atom_hud/alternate_appearance/basic/has_antagonist/mobShouldSee(mob/M)
return !!M.mind?.has_antag_datum(antag_datum_type)
///datum/atom_hud/alternate_appearance/basic/has_antagonist/mobShouldSee(mob/M) //monkestation removal, moved to the modular version of this file
// return !!M.mind?.has_antag_datum(antag_datum_type) //monkestation removal

/// An alternate appearance that will show all the antagonists this mob has
/datum/atom_hud/alternate_appearance/basic/antagonist_hud
Expand Down
4 changes: 4 additions & 0 deletions monkestation/code/modules/antagonists/_common/antag_datum.dm
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/datum/antagonist
///The key or list of keys that are valid to see our antag hud/of huds we can see
var/list/hud_keys

/datum/antagonist/proc/antag_token(datum/mind/hosts_mind, mob/spender)
return
20 changes: 20 additions & 0 deletions monkestation/code/modules/antagonists/_common/antag_hud.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/datum/atom_hud/alternate_appearance/basic/has_antagonist
///The key or list of keys that are valid to see this hud, if unset then it will display to everyone with the antag datum like normal
var/list/valid_keys

/datum/atom_hud/alternate_appearance/basic/has_antagonist/mobShouldSee(mob/M)
var/datum/antagonist/antag_datum = M.mind?.has_antag_datum(antag_datum_type)
if(!antag_datum)
return FALSE

if(!valid_keys)
return TRUE

var/islist_datum_keys = islist(antag_datum.hud_keys)
if(islist(valid_keys))
if(islist_datum_keys)
return length(valid_keys - antag_datum.hud_keys) != length(valid_keys)
return antag_datum.hud_keys in valid_keys
else if(islist_datum_keys)
return valid_keys in antag_datum.hud_keys
return valid_keys == antag_datum.hud_keys
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5743,6 +5743,7 @@
#include "monkestation\code\modules\aesthetics\subsystem\coloring.dm"
#include "monkestation\code\modules\aesthetics\walls\iron.dm"
#include "monkestation\code\modules\antagonists\_common\antag_datum.dm"
#include "monkestation\code\modules\antagonists\_common\antag_hud.dm"
#include "monkestation\code\modules\antagonists\brainwashing\brainwashing.dm"
#include "monkestation\code\modules\antagonists\brainwashing\brainwashing_alert.dm"
#include "monkestation\code\modules\antagonists\brainwashing\brainwashing_helpers.dm"
Expand Down
Loading