-
Notifications
You must be signed in to change notification settings - Fork 15
Port spare ID cabinet, port automaticspareidsystem, add spareid:unlock command #94
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
Open
JustTNE
wants to merge
2
commits into
DeltaV-Station:master
Choose a base branch
from
JustTNE:spare-id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,7 @@ | ||
| namespace Content.Server._DVA.Cabinet; | ||
|
|
||
| /// <summary> | ||
| /// Component that marks an entity as a spare ID safe. Is interacted with by DVAutomaticSpareIdSystem to unlock the safe when there is no captain present. | ||
| /// </summary> | ||
| [RegisterComponent] | ||
| public sealed partial class DVSpareIDSafeComponent : Component; |
95 changes: 95 additions & 0 deletions
95
Content.Server/_DVA/Station/Components/DVAutomaticSpareIdComponent.cs
This file contains hidden or 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,95 @@ | ||
| using Content.Server._DVA.Station.Systems; | ||
| using Content.Shared.Access; | ||
| using Content.Shared.Roles; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
|
|
||
| namespace Content.Server._DVA.Station.Components; | ||
|
|
||
| public enum AutomaticSpareIdState | ||
| { | ||
| RoundStart, | ||
| Alerted, | ||
| AwaitingUnlock, | ||
| Unlocked, | ||
| CaptainPresent, | ||
| WarOps | ||
| } | ||
|
|
||
| [RegisterComponent, Access(typeof(DVAutomaticSpareIdSystem)), AutoGenerateComponentPause] | ||
| public sealed partial class DVAutomaticSpareIdComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// The current state of the automatic spare ID system | ||
| /// </summary> | ||
| [DataField] | ||
| public AutomaticSpareIdState State = AutomaticSpareIdState.RoundStart; | ||
|
|
||
| /// <summary> | ||
| /// Timeout before an action is taken if the state doesn't change | ||
| /// </summary> | ||
| [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] | ||
| public TimeSpan? Timeout; | ||
|
|
||
| /// <summary> | ||
| /// The job considered as Captain for the automatic spare ID system | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<JobPrototype> CaptainJob = "Captain"; | ||
|
|
||
| /// <summary> | ||
| /// The access that the spare ID safe will be extended to have if it is automatically unlocked | ||
| /// if there is no captain | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<AccessLevelPrototype> GrantAccessToCommand = "Command"; | ||
|
|
||
| /// <summary> | ||
| /// The access that the spare ID safe will be extended to have if it is automatically unlocked | ||
| /// if there is a captain | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<AccessLevelPrototype> GrantAccessToCaptain = "Captain"; | ||
|
|
||
| /// <summary> | ||
| /// Message for when a Captain joins after the system has alerted about their absence | ||
| /// </summary> | ||
| [DataField] | ||
| public LocId CaptainPresentAfterAlertsMessage = "captain-arrived-revoke-aco-announcement"; | ||
|
|
||
| /// <summary> | ||
| /// Message for when the system alerts but isn't going to automatically unlock | ||
| /// </summary> | ||
| [DataField] | ||
| public LocId AlertedMessage = "no-captain-request-aco-vote-announcement"; | ||
|
|
||
| /// <summary> | ||
| /// Message for when the system alerts and will automatically unlock | ||
| /// </summary> | ||
| [DataField] | ||
| public LocId AwaitingUnlockMessage = "no-captain-request-aco-vote-with-aa-announcement"; | ||
|
|
||
| /// <summary> | ||
| /// Message for when the system alerts automatically unlock | ||
| /// </summary> | ||
| [DataField] | ||
| public LocId UnlockedMessage = "no-captain-aa-unlocked-announcement"; | ||
|
|
||
| /// <summary> | ||
| /// The amount of time in which that the spare ID will unlock after nuclear operatives declare war. | ||
| /// </summary> | ||
| [DataField] | ||
| public TimeSpan WarOpsUnlockDelay = TimeSpan.FromSeconds(15); | ||
|
|
||
| /// <summary> | ||
| /// Message that will be displayed to the station when there is no captain and war ops is declared. | ||
| /// </summary> | ||
| [DataField] | ||
| public LocId WarOpsUnlockedMessageACO = "spare-id-warops-no-captain"; | ||
|
|
||
| /// <summary> | ||
| /// Message that will be displayed to the station when there is a captain and war ops is declared. | ||
| /// </summary> | ||
| [DataField] | ||
| public LocId WarOpsUnlockedMessageCaptain = "spare-id-warops-captain"; | ||
| } | ||
This file contains hidden or 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,9 @@ | ||
| using Robust.Shared.Network; | ||
|
|
||
| namespace Content.Server._DVA.Station.Events; | ||
|
|
||
| /// <summary> | ||
| /// Event is raised when a player takes a job. | ||
| /// </summary> | ||
| [ByRefEvent] | ||
| public record struct PlayerJobAddedEvent(NetUserId Player, string JobPrototypeId); |
11 changes: 11 additions & 0 deletions
11
Content.Server/_DVA/Station/Events/PlayerJobsRemovedEvent.cs
This file contains hidden or 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.Network; | ||
| using Robust.Shared.Prototypes; | ||
| using Content.Shared.Roles; | ||
|
|
||
| namespace Content.Server._DVA.Station.Events; | ||
|
|
||
| /// <summary> | ||
| /// Event is raised when a player loses jobs. | ||
| /// </summary> | ||
| [ByRefEvent] | ||
| public record struct PlayerJobsRemovedEvent(NetUserId Player, List<ProtoId<JobPrototype>> PlayerJobs); |
41 changes: 41 additions & 0 deletions
41
Content.Server/_DVA/Station/Systems/DVAutomaticSpareIdSystem.Commands.cs
This file contains hidden or 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,41 @@ | ||
| using System.Diagnostics; | ||
| using Content.Server._DVA.Station.Components; | ||
| using Content.Server._DVA.Station.Systems; | ||
| using Content.Server.Administration; | ||
| using Content.Shared.Administration; | ||
| using Robust.Shared.Toolshed; | ||
| using Robust.Shared.Toolshed.Errors; | ||
| using Robust.Shared.Utility; | ||
|
|
||
| namespace Robust.Shared._DVA.Station.Systems; | ||
|
|
||
| [ToolshedCommand(Name = "spareid"), AdminCommand(AdminFlags.Spawn)] | ||
| public sealed partial class DVAutomaticSpareIdSystemCommand : ToolshedCommand | ||
| { | ||
| [Dependency] private IEntityManager _entityManager = default!; | ||
| private DVAutomaticSpareIdSystem? _automaticSpareIdSystem; | ||
|
|
||
| [CommandImplementation("unlock")] | ||
| public void Unlock(IInvocationContext ctx, [PipedArgument] EntityUid stationUid, bool doAnnouncement) | ||
| { | ||
| _automaticSpareIdSystem ??= GetSys<DVAutomaticSpareIdSystem>(); | ||
| if (!_entityManager.TryGetComponent<DVAutomaticSpareIdComponent>(stationUid, out var spareId)) | ||
| { | ||
| ctx.ReportError(new AutomaticSpareIdSystemMissing()); | ||
| return; | ||
| } | ||
| _automaticSpareIdSystem.ForceUnlock((stationUid, spareId), null, doAnnouncement ? "command-spareid-unlock-announcement" : null); | ||
| } | ||
| } | ||
|
|
||
| public record struct AutomaticSpareIdSystemMissing : IConError | ||
| { | ||
| public FormattedMessage DescribeInner() | ||
| { | ||
| return FormattedMessage.FromMarkupOrThrow("This command doesn't function if there is no automatic spare ID system. Common usage: stations:get | spareid:unlock true"); | ||
| } | ||
|
|
||
| public string? Expression { get; set; } | ||
| public Vector2i? IssueSpan { get; set; } | ||
| public StackTrace? Trace { get; set; } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.