forked from Simple-Station/Parkstation-Friendly-Chainsaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rev Components are no longer leaked + Rev and Zombie icon visibility …
…to ghosts is now controlled by a cvar (#22194) * Initial work on having the Rev icons not be visible to ghosts depending on a Cvar and a component. This commit just makes it so that the revcomponent and headrev component are not shared with clients that shouldn't know about them. This is due to the concern that clients having access to those components, even if no image was displayed could allow modified clients to have meta knowledge of revs. Currently this has the issue that if a player later for example becomes a rev, none of the existing rev components get networked to them. I am not sure there is currently an effecient solution to this. This is probably in an issue for a lot more stuff. I might just make it so all the logic just moves to the client on whether to put the icon again. Also this commit adds the ShowRevIconsComponent to allow anyone with it to just view rev icons. * Rev components now get communicated to clients that didn't have them previously and the AntagIconSystem is now properly checking whether to give the icons. We now dirty all the rev/headrev components when someone gets converted or gets the ViewRevIcons component. The AntagIconSystem now checks whether it should draw the icons mostly based on an event, this is still done client side. This is not a full proof solution to make it so clients can't know someone is an antag when they shouldn't because: 1. There are other components that need similar treatment, to my knowledge not to for revs but for other antags. Maybe even the mind component. This could be addressed in future PRs. 2. We cannot ensure that clients forget about these components if the client gets deconverted for example. We can of course have code that does this, but it will necessarily need to be done on the client and if the client is modified then there is no way to ensure this. Of course at that point they should already know who their fellow revs are so this might not be an issue. I now need to do the same thing for zombies in a future commit. A similar system for nukies also needs to be looked at but I will not be doing that in the PR this commit ends up in. * Misc name changes and cleaning up the ZombieSystem Changed some names around and decoupled the ZombieSystem from the AntagStatusIconsystem. Now there is a cvar for ghost visibility for them as well. The Zombie Component was not made SessionSpecific because: 1. Zombies are pretty visible anyways 2. The Component is needed to change the appearance of zombie players. * Misc name changes and cleaning up the ZombieSystem Changed some names around and decoupled the ZombieSystem from the AntagStatusIconsystem. Now there is a cvar for ghost visibility for them as well. The Zombie Component was not made SessionSpecific because: 1. Zombies are pretty visible anyways 2. The Component is needed to change the appearance of zombie players. * Merged 2 if statements into 1 on the Zombiesystem. * Cut down on code duplication in AntagStatusIconSystem Now instead of having a seperate function for each component, there is 1 generic function. Functions for special cases like the Rev/Headrev comp can have a separate function that does the special check and then calls the generic one. This is done through the IAntagStatusIconComponent interface which provides a common interface to get the Icon. * Removed some duplication from the SharedRevolutionarySystem with generics. I have no idea why I didn't think of this sooner. * Addressed Reviews I think I think events get unsubbed automatically but I am probably missing something that I have not understood. Either way this is a requested change. * Replace war crimes with actual fixes for reviews It was not clear to me what the reviews meant * Addressed reviews by removing need for cvars. Whether icons are visible to ghosts is now determined by a bool in IAntagStatusIcon which all antag components with status icons should implement. * Update Content.Shared/Revolutionary/SharedRevolutionarySystem.cs --------- Co-authored-by: metalgearsloth <[email protected]> (cherry picked from commit 8b19b7fab9dd8fb115f65794d97a26ebb9aa1142)
- Loading branch information
1 parent
2befc02
commit 639d3af
Showing
12 changed files
with
208 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,44 @@ | ||
using Content.Shared.Antag; | ||
using Content.Shared.Revolutionary.Components; | ||
using Content.Client.Antag; | ||
using Content.Shared.Ghost; | ||
using Content.Shared.StatusIcon.Components; | ||
|
||
namespace Content.Client.Revolutionary; | ||
|
||
/// <summary> | ||
/// Used for the client to get status icons from other revs. | ||
/// </summary> | ||
public sealed class RevolutionarySystem : AntagStatusIconSystem<RevolutionaryComponent> | ||
public sealed class RevolutionarySystem : EntitySystem | ||
{ | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RevolutionaryComponent, GetStatusIconsEvent>(GetRevIcon); | ||
SubscribeLocalEvent<HeadRevolutionaryComponent, GetStatusIconsEvent>(GetHeadRevIcon); | ||
SubscribeLocalEvent<RevolutionaryComponent, CanDisplayStatusIconsEvent>(OnCanShowRevIcon); | ||
SubscribeLocalEvent<HeadRevolutionaryComponent, CanDisplayStatusIconsEvent>(OnCanShowRevIcon); | ||
} | ||
|
||
/// <summary> | ||
/// Checks if the person who triggers the GetStatusIcon event is also a Rev or a HeadRev. | ||
/// Determine whether a client should display the rev icon. | ||
/// </summary> | ||
private void GetRevIcon(EntityUid uid, RevolutionaryComponent comp, ref GetStatusIconsEvent args) | ||
private void OnCanShowRevIcon<T>(EntityUid uid, T comp, ref CanDisplayStatusIconsEvent args) where T : IAntagStatusIconComponent | ||
{ | ||
if (!HasComp<HeadRevolutionaryComponent>(uid)) | ||
{ | ||
GetStatusIcon(comp.RevStatusIcon, ref args); | ||
} | ||
args.Cancelled = !CanDisplayIcon(args.User, comp.IconVisibleToGhost); | ||
} | ||
|
||
private void GetHeadRevIcon(EntityUid uid, HeadRevolutionaryComponent comp, ref GetStatusIconsEvent args) | ||
/// <summary> | ||
/// The criteria that determine whether a client should see Rev/Head rev icons. | ||
/// </summary> | ||
private bool CanDisplayIcon(EntityUid? uid, bool visibleToGhost) | ||
{ | ||
GetStatusIcon(comp.HeadRevStatusIcon, ref args); | ||
if (HasComp<HeadRevolutionaryComponent>(uid) || HasComp<RevolutionaryComponent>(uid)) | ||
return true; | ||
|
||
if (visibleToGhost && HasComp<GhostComponent>(uid)) | ||
return true; | ||
|
||
return HasComp<ShowRevIconsComponent>(uid); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Content.Shared.StatusIcon; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Shared.Antag; | ||
|
||
public interface IAntagStatusIconComponent | ||
{ | ||
public ProtoId<StatusIconPrototype> StatusIcon { get; set; } | ||
|
||
public bool IconVisibleToGhost { get; set; } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Content.Shared/Revolutionary/Components/ShowRevIconsComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Revolutionary.Components; | ||
|
||
/// <summary> | ||
/// Determines whether Someone can see rev/headrev icons on revs. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class ShowRevIconsComponent: Component | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Zombies; | ||
|
||
/// <summary> | ||
/// Makes it so an entity can view ZombieAntagIcons. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class ShowZombieIconsComponent: Component | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.