Add active and ended game rule components, generic TryRoundStartAttempt and minPlayers field (#20564)

* Improve active game rule querying, add generic try round start attempt method, move minPlayers to GameRuleComponent

* Nukeops todo and cleanup

* Remove Active field

* Add EndedGameRuleComponent
This commit is contained in:
DrSmugleaf
2023-09-28 07:48:59 -07:00
committed by GitHub
parent 78091fb11d
commit 2f4b2cc887
7 changed files with 132 additions and 86 deletions

View File

@@ -595,7 +595,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
// Basically copied verbatim from traitor code
var playersPerOperative = nukeops.PlayersPerOperative;
var maxOperatives = nukeops.MaxOperatives;
var maxOperatives = nukeops.MaxOps;
// Dear lord what is happening HERE.
var everyone = new List<IPlayerSession>(ev.PlayerPool);
@@ -614,15 +614,15 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
}
var profile = ev.Profiles[player.UserId];
if (profile.AntagPreferences.Contains(nukeops.OperativeRoleProto))
if (profile.AntagPreferences.Contains(nukeops.OperativeRoleProto.Id))
{
prefList.Add(player);
}
if (profile.AntagPreferences.Contains(nukeops.MedicRoleProto))
if (profile.AntagPreferences.Contains(nukeops.MedicRoleProto.Id))
{
medPrefList.Add(player);
}
if (profile.AntagPreferences.Contains(nukeops.CommanderRolePrototype))
if (profile.AntagPreferences.Contains(nukeops.CommanderRoleProto.Id))
{
cmdrPrefList.Add(player);
}
@@ -808,8 +808,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
if (!component.SpawnOutpost)
return true;
var path = component.NukieOutpostMap;
var shuttlePath = component.NukieShuttleMap;
var path = component.OutpostMap;
var shuttlePath = component.ShuttleMap;
var mapId = _mapManager.CreateMap();
var options = new MapLoadOptions
@@ -866,18 +866,18 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
{
case 0:
name = Loc.GetString("nukeops-role-commander") + " " + _random.PickAndTake(component.OperativeNames[component.EliteNames]);
role = component.CommanderRolePrototype;
gear = component.CommanderStartGearPrototype;
role = component.CommanderRoleProto;
gear = component.CommanderStartGearProto;
break;
case 1:
name = Loc.GetString("nukeops-role-agent") + " " + _random.PickAndTake(component.OperativeNames[component.NormalNames]);
role = component.MedicRoleProto;
gear = component.MedicStartGearPrototype;
gear = component.MedicStartGearProto;
break;
default:
name = Loc.GetString("nukeops-role-operator") + " " + _random.PickAndTake(component.OperativeNames[component.NormalNames]);
role = component.OperativeRoleProto;
gear = component.OperativeStartGearPrototype;
gear = component.OperativeStartGearProto;
break;
}
@@ -915,7 +915,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
// Forgive me for hardcoding prototypes
foreach (var (_, meta, xform) in EntityQuery<SpawnPointComponent, MetaDataComponent, TransformComponent>(true))
{
if (meta.EntityPrototype?.ID != component.SpawnPointPrototype)
if (meta.EntityPrototype?.ID != component.SpawnPointProto.Id)
continue;
if (xform.ParentUid != component.NukieOutpost)
@@ -981,7 +981,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
}
// Basically copied verbatim from traitor code
var playersPerOperative = component.PlayersPerOperative;
var maxOperatives = component.MaxOperatives;
var maxOperatives = component.MaxOps;
var playerPool = _playerManager.ServerSessions.ToList();
var numNukies = MathHelper.Clamp(playerPool.Count / playersPerOperative, 1, maxOperatives);
@@ -1115,9 +1115,9 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
// TODO: Loot table or something
foreach (var proto in new[]
{
component.CommanderStartGearPrototype,
component.MedicStartGearPrototype,
component.OperativeStartGearPrototype
component.CommanderStartGearProto,
component.MedicStartGearProto,
component.OperativeStartGearProto
})
{
component.StartingGearPrototypes.Add(proto, _prototypeManager.Index<StartingGearPrototype>(proto));