-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add SubGamemodes comp/sys * remove RuleChance from thief rule * use SubGamemodes for adding thief rule instead of adding ThiefRule component to random gamemodes * clean up thief rule prototype * add better logging + end rule if it fails to start * march 1st incident * preset ops * the dreaded --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
- Loading branch information
1 parent
709881f
commit 7f060eb
Showing
7 changed files
with
58 additions
and
21 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
Content.Server/GameTicking/Rules/Components/SubGamemodesComponent.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,20 @@ | ||
using Content.Server.GameTicking.Rules; | ||
using Content.Shared.Storage; | ||
|
||
namespace Content.Server.GameTicking.Rules.Components; | ||
|
||
/// <summary> | ||
/// When this gamerule is added it has a chance of adding other gamerules. | ||
/// Since it's done when added and not when started you can still use normal start logic. | ||
/// Used for starting subgamemodes in game presets. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(SubGamemodesSystem))] | ||
public sealed partial class SubGamemodesComponent : Component | ||
{ | ||
/// <summary> | ||
/// Spawn entries for each gamerule prototype. | ||
/// Use orGroups if you want to limit rules. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public List<EntitySpawnEntry> Rules = new(); | ||
} |
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,17 @@ | ||
using Content.Server.GameTicking.Rules.Components; | ||
using Content.Shared.Storage; | ||
|
||
namespace Content.Server.GameTicking.Rules; | ||
|
||
public sealed class SubGamemodesSystem : GameRuleSystem<SubGamemodesComponent> | ||
{ | ||
protected override void Added(EntityUid uid, SubGamemodesComponent comp, GameRuleComponent rule, GameRuleAddedEvent args) | ||
{ | ||
var picked = EntitySpawnCollection.GetSpawns(comp.Rules, RobustRandom); | ||
foreach (var id in picked) | ||
{ | ||
Log.Info($"Starting gamerule {id} as a subgamemode of {ToPrettyString(uid):rule}"); | ||
GameTicker.AddGameRule(id); | ||
} | ||
} | ||
} |
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