-
Notifications
You must be signed in to change notification settings - Fork 149
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 #545 from Rxup/upstream-sync
Upstream sync
- Loading branch information
Showing
153 changed files
with
132,941 additions
and
136,554 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
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
29 changes: 29 additions & 0 deletions
29
Content.Server/GameTicking/Rules/VariationPass/Components/CutWireVariationPassComponent.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,29 @@ | ||
using Content.Shared.Whitelist; | ||
|
||
namespace Content.Server.GameTicking.Rules.VariationPass.Components; | ||
|
||
/// <summary> | ||
/// Handles cutting a random wire on random devices around the station. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class CutWireVariationPassComponent : Component | ||
{ | ||
/// <summary> | ||
/// Blacklist of hackable entities that should not be chosen to | ||
/// have wires cut. | ||
/// </summary> | ||
[DataField] | ||
public EntityWhitelist Blacklist = new(); | ||
|
||
/// <summary> | ||
/// Chance for an individual wire to be cut. | ||
/// </summary> | ||
[DataField] | ||
public float WireCutChance = 0.05f; | ||
|
||
/// <summary> | ||
/// Maximum number of wires that can be cut stationwide. | ||
/// </summary> | ||
[DataField] | ||
public int MaxWiresCut = 10; | ||
} |
39 changes: 39 additions & 0 deletions
39
Content.Server/GameTicking/Rules/VariationPass/CutWireVariationPassSystem.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,39 @@ | ||
using Content.Server.GameTicking.Rules.VariationPass.Components; | ||
using Content.Server.Wires; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.GameTicking.Rules.VariationPass; | ||
|
||
/// <summary> | ||
/// Handles cutting a random wire on random devices around the station. | ||
/// This system identifies target devices and adds <see cref="CutWireOnMapInitComponent"/> to them. | ||
/// The actual wire cutting is handled by <see cref="CutWireOnMapInitSystem"/>. | ||
/// </summary> | ||
public sealed class CutWireVariationPassSystem : VariationPassSystem<CutWireVariationPassComponent> | ||
{ | ||
protected override void ApplyVariation(Entity<CutWireVariationPassComponent> ent, ref StationVariationPassEvent args) | ||
{ | ||
var wiresCut = 0; | ||
var query = AllEntityQuery<WiresComponent, TransformComponent>(); | ||
while (query.MoveNext(out var uid, out _, out var transform)) | ||
{ | ||
// Ignore if not part of the station | ||
if (!IsMemberOfStation((uid, transform), ref args)) | ||
continue; | ||
|
||
// Check against blacklist | ||
if (ent.Comp.Blacklist.IsValid(uid)) | ||
continue; | ||
|
||
if (Random.Prob(ent.Comp.WireCutChance)) | ||
{ | ||
EnsureComp<CutWireOnMapInitComponent>(uid); | ||
wiresCut++; | ||
|
||
// Limit max wires cut | ||
if (wiresCut >= ent.Comp.MaxWiresCut) | ||
break; | ||
} | ||
} | ||
} | ||
} |
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.