make thief a subgamemode (#25740)

* 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>
This commit is contained in:
deltanedas
2024-03-02 16:33:24 +00:00
committed by GitHub
parent 709881f912
commit 7f060eb129
7 changed files with 58 additions and 21 deletions

View File

@@ -37,19 +37,19 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
private void OnPlayersSpawned(RulePlayerJobsAssignedEvent ev)
{
var query = QueryActiveRules();
while (query.MoveNext(out _, out var comp, out _))
while (query.MoveNext(out var uid, out _, out var comp, out var gameRule))
{
//Chance to not launch the game rule
if (!_random.Prob(comp.RuleChance))
continue;
//Get all players eligible for this role, allow selecting existing antags
//TO DO: When voxes specifies are added, increase their chance of becoming a thief by 4 times >:)
var eligiblePlayers = _antagSelection.GetEligiblePlayers(ev.Players, comp.ThiefPrototypeId, acceptableAntags: AntagAcceptability.All, allowNonHumanoids: true);
//Abort if there are none
if (eligiblePlayers.Count == 0)
{
Log.Warning($"No eligible thieves found, ending game rule {ToPrettyString(uid):rule}");
GameTicker.EndGameRule(uid, gameRule);
continue;
}
//Calculate number of thieves to choose
var thiefCount = _random.Next(1, comp.MaxAllowThief + 1);