forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from Gorox221/dream
Мелкие правки
- Loading branch information
Showing
36 changed files
with
896 additions
and
11 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
Content.Server/Corvax/HiddenDescription/HiddenDescriptionComponent.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,56 @@ | ||
using Content.Shared.Roles; | ||
using Content.Shared.Whitelist; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Corvax.HiddenDescription; | ||
|
||
/// <summary> | ||
/// A component that shows players with specific roles or jobs additional information about entities | ||
/// </summary> | ||
|
||
[RegisterComponent, Access(typeof(HiddenDescriptionSystem))] | ||
public sealed partial class HiddenDescriptionComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public List<HiddenDescriptionEntry> Entries = new(); | ||
|
||
/// <summary> | ||
/// Prioritizing the location of classified information in an inspection | ||
/// </summary> | ||
[DataField] | ||
public int PushPriority = 1; | ||
} | ||
|
||
[DataDefinition, Serializable] | ||
public readonly partial record struct HiddenDescriptionEntry() | ||
{ | ||
/// <summary> | ||
/// Locale string with hidden description | ||
/// </summary> | ||
[DataField(required: true)] | ||
public LocId Label { get; init; } = default!; | ||
|
||
/// <summary> | ||
/// A player's mind must pass a whitelist check to receive hidden information | ||
/// </summary> | ||
[DataField] | ||
public EntityWhitelist WhitelistMind { get; init; } = new(); | ||
|
||
/// <summary> | ||
/// A player's body must pass a whitelist check to receive hidden information | ||
/// </summary> | ||
[DataField] | ||
public EntityWhitelist WhitelistBody { get; init; } = new(); | ||
|
||
/// <summary> | ||
/// The player's mind has to have some job role to access the hidden information | ||
/// </summary> | ||
[DataField] | ||
public List<ProtoId<JobPrototype>> JobRequired { get; init; } = new(); | ||
|
||
/// <summary> | ||
/// If true, the player needs to go through and whitelist, and have some job. By default, at least one successful checks is sufficient. | ||
/// </summary> | ||
[DataField] | ||
public bool NeedAllCheck { get; init; } = false; | ||
} |
37 changes: 37 additions & 0 deletions
37
Content.Server/Corvax/HiddenDescription/HiddenDescriptionSystem.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,37 @@ | ||
using Content.Server.Mind; | ||
using Content.Shared.Examine; | ||
using Content.Shared.Roles.Jobs; | ||
|
||
namespace Content.Server.Corvax.HiddenDescription; | ||
|
||
public sealed partial class HiddenDescriptionSystem : EntitySystem | ||
{ | ||
|
||
[Dependency] private readonly MindSystem _mind = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<HiddenDescriptionComponent, ExaminedEvent>(OnExamine); | ||
} | ||
|
||
private void OnExamine(Entity<HiddenDescriptionComponent> hiddenDesc, ref ExaminedEvent args) | ||
{ | ||
_mind.TryGetMind(args.Examiner, out var mindId, out var mindComponent); | ||
TryComp<JobComponent>(mindId, out var job); | ||
|
||
foreach (var item in hiddenDesc.Comp.Entries) | ||
{ | ||
var isJobAllow = job?.Prototype != null && item.JobRequired.Contains(job.Prototype.Value); | ||
var isMindWhitelistPassed = item.WhitelistMind.IsValid(mindId); | ||
var isBodyWhitelistPassed = item.WhitelistMind.IsValid(args.Examiner); | ||
var passed = item.NeedAllCheck | ||
? isMindWhitelistPassed && isBodyWhitelistPassed && isJobAllow | ||
: isMindWhitelistPassed || isBodyWhitelistPassed || isJobAllow; | ||
|
||
if (passed) | ||
args.PushMarkup(Loc.GetString(item.Label), hiddenDesc.Comp.PushPriority); | ||
} | ||
} | ||
} |
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
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
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.