-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
263 additions
and
107 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
46 changes: 46 additions & 0 deletions
46
Content.Server/DeltaV/GameTicking/Rules/Components/DelayedRuleComponent.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,46 @@ | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
|
||
namespace Content.Server.DeltaV.GameTicking.Rules.Components; | ||
|
||
/// <summary> | ||
/// Delays adding components to the antags of a gamerule until some time has passed. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is used for the zombies gamemode so that new players don't hit the funny button immediately and ruin anyone else's plans. | ||
/// </remarks> | ||
[RegisterComponent, Access(typeof(DelayedRuleSystem))] | ||
[AutoGenerateComponentPause] | ||
public sealed partial class DelayedRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// The players must wait this length of time before <see cref="DelayedComponents"/> gets added. | ||
/// If they are somehow found out and get gibbed/cremated/etc before this delay is up they will not turn. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public TimeSpan Delay; | ||
|
||
/// <summary> | ||
/// Whether to skip the delay if there is only 1 antag selected. | ||
/// </summary> | ||
[DataField] | ||
public bool IgnoreSolo; | ||
|
||
/// <summary> | ||
/// When the <see cref="Delay"/> will end. | ||
/// </summary> | ||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] | ||
public TimeSpan DelayEnds; | ||
|
||
/// <summary> | ||
/// The components to add to each player's mob once the delay ends. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public ComponentRegistry DelayedComponents = new(); | ||
|
||
/// <summary> | ||
/// Popup to show when the delay ends. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public LocId EndedPopup; | ||
} |
58 changes: 58 additions & 0 deletions
58
Content.Server/DeltaV/GameTicking/Rules/DelayedRuleSystem.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,58 @@ | ||
using Content.Server.Antag.Components; | ||
using Content.Server.GameTicking.Rules; | ||
using Content.Server.DeltaV.GameTicking.Rules.Components; | ||
using Content.Shared.GameTicking.Components; | ||
using Content.Shared.Mind; | ||
using Content.Shared.Popups; | ||
|
||
namespace Content.Server.DeltaV.GameTicking.Rules; | ||
|
||
public sealed class DelayedRuleSystem : GameRuleSystem<DelayedRuleComponent> | ||
{ | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
|
||
protected override void Started(EntityUid uid, DelayedRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
{ | ||
base.Started(uid, component, gameRule, args); | ||
|
||
component.DelayEnds = Timing.CurTime + component.Delay; | ||
} | ||
|
||
protected override void ActiveTick(EntityUid uid, DelayedRuleComponent component, GameRuleComponent gameRule, float frameTime) | ||
{ | ||
base.ActiveTick(uid, component, gameRule, frameTime); | ||
|
||
CheckDelay((uid, component)); | ||
} | ||
|
||
/// <summary> | ||
/// Checks if the delay has ended. | ||
/// </summary> | ||
private void CheckDelay(Entity<DelayedRuleComponent> ent) | ||
{ | ||
if (!TryComp<AntagSelectionComponent>(ent, out var selection)) | ||
return; | ||
|
||
// skip the delay if it's just 1 player, theres no plan to ruin if you are the only one | ||
var ends = ent.Comp.DelayEnds; | ||
if (ent.Comp.IgnoreSolo && selection.SelectedMinds.Count < 2) | ||
ends = Timing.CurTime; | ||
|
||
if (Timing.CurTime < ends) | ||
return; | ||
|
||
var comps = ent.Comp.DelayedComponents; | ||
foreach (var (mindId, _) in selection.SelectedMinds) | ||
{ | ||
// using OriginalOwnedEntity as the player might have ghosted to try become an evil ghost antag | ||
if (!TryComp<MindComponent>(mindId, out var mind) || !TryGetEntity(mind.OriginalOwnedEntity, out var mob)) | ||
continue; | ||
|
||
var uid = mob.Value; | ||
_popup.PopupEntity(Loc.GetString(ent.Comp.EndedPopup), uid, uid, PopupType.LargeCaution); | ||
EntityManager.AddComponents(uid, comps); | ||
} | ||
|
||
RemCompDeferred<DelayedRuleComponent>(ent); | ||
} | ||
} |
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
2 changes: 2 additions & 0 deletions
2
Resources/Locale/en-US/deltav/game-ticking/game-presets/preset-zombies.ftl
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,2 @@ | ||
zombie-bioterrorist-role-greeting = You are a syndicate sponsored bioterrorist sent to overtake the station by use of the Romerol virus. Coordinate with your team, get supplies and prepare for your eventual transformation. Death to nanotrasen! | ||
zombie-bioterrorist-romerol-active = The romerol in your blood is now active, you are ready to transform! |
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.