Adds another check in the Nukeops system (#11295)
This commit is contained in:
@@ -101,6 +101,20 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WinType _winType = WinType.Neutral;
|
private WinType _winType = WinType.Neutral;
|
||||||
|
|
||||||
|
private WinType RuleWinType
|
||||||
|
{
|
||||||
|
get => _winType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_winType = value;
|
||||||
|
|
||||||
|
if (value == WinType.CrewMajor || value == WinType.OpsMajor)
|
||||||
|
{
|
||||||
|
_roundEndSystem.EndRound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private List<WinCondition> _winConditions = new ();
|
private List<WinCondition> _winConditions = new ();
|
||||||
|
|
||||||
private MapId? _nukiePlanet;
|
private MapId? _nukiePlanet;
|
||||||
@@ -175,11 +189,11 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
{
|
{
|
||||||
if (ev.OwningStation == _nukieOutpost)
|
if (ev.OwningStation == _nukieOutpost)
|
||||||
{
|
{
|
||||||
_winType = WinType.CrewMajor;
|
|
||||||
_winConditions.Add(WinCondition.NukeExplodedOnNukieOutpost);
|
_winConditions.Add(WinCondition.NukeExplodedOnNukieOutpost);
|
||||||
|
RuleWinType = WinType.CrewMajor;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (TryComp(_targetStation, out StationDataComponent? data))
|
if (TryComp(_targetStation, out StationDataComponent? data))
|
||||||
{
|
{
|
||||||
foreach (var grid in data.Grids)
|
foreach (var grid in data.Grids)
|
||||||
@@ -189,15 +203,14 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_winType = WinType.OpsMajor;
|
|
||||||
_winConditions.Add(WinCondition.NukeExplodedOnCorrectStation);
|
_winConditions.Add(WinCondition.NukeExplodedOnCorrectStation);
|
||||||
|
RuleWinType = WinType.OpsMajor;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_winConditions.Add(WinCondition.NukeExplodedOnIncorrectLocation);
|
_winConditions.Add(WinCondition.NukeExplodedOnIncorrectLocation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_winConditions.Add(WinCondition.NukeExplodedOnIncorrectLocation);
|
_winConditions.Add(WinCondition.NukeExplodedOnIncorrectLocation);
|
||||||
@@ -246,7 +259,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
private void OnRoundEnd()
|
private void OnRoundEnd()
|
||||||
{
|
{
|
||||||
// If the win condition was set to operative/crew major win, ignore.
|
// If the win condition was set to operative/crew major win, ignore.
|
||||||
if (_winType == WinType.OpsMajor || _winType == WinType.CrewMajor)
|
if (RuleWinType == WinType.OpsMajor || RuleWinType == WinType.CrewMajor)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -261,8 +274,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
// UH OH
|
// UH OH
|
||||||
if (nukeTransform.MapID == _shuttleSystem.CentComMap)
|
if (nukeTransform.MapID == _shuttleSystem.CentComMap)
|
||||||
{
|
{
|
||||||
_winType = WinType.OpsMajor;
|
|
||||||
_winConditions.Add(WinCondition.NukeActiveAtCentCom);
|
_winConditions.Add(WinCondition.NukeActiveAtCentCom);
|
||||||
|
RuleWinType = WinType.OpsMajor;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +296,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_winType = WinType.OpsMajor;
|
|
||||||
_winConditions.Add(WinCondition.NukeActiveInStation);
|
_winConditions.Add(WinCondition.NukeActiveInStation);
|
||||||
|
RuleWinType = WinType.OpsMajor;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,7 +318,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
// running away the moment nuke ops appear.
|
// running away the moment nuke ops appear.
|
||||||
if (allAlive)
|
if (allAlive)
|
||||||
{
|
{
|
||||||
_winType = WinType.OpsMinor;
|
RuleWinType = WinType.OpsMinor;
|
||||||
_winConditions.Add(WinCondition.AllNukiesAlive);
|
_winConditions.Add(WinCondition.AllNukiesAlive);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -327,13 +340,13 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
// This also implies that some nuclear operatives have died.
|
// This also implies that some nuclear operatives have died.
|
||||||
if (diskAtCentCom)
|
if (diskAtCentCom)
|
||||||
{
|
{
|
||||||
_winType = WinType.CrewMinor;
|
RuleWinType = WinType.CrewMinor;
|
||||||
_winConditions.Add(WinCondition.NukeDiskOnCentCom);
|
_winConditions.Add(WinCondition.NukeDiskOnCentCom);
|
||||||
}
|
}
|
||||||
// Otherwise, the nuke ops win.
|
// Otherwise, the nuke ops win.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_winType = WinType.OpsMinor;
|
RuleWinType = WinType.OpsMinor;
|
||||||
_winConditions.Add(WinCondition.NukeDiskNotOnCentCom);
|
_winConditions.Add(WinCondition.NukeDiskNotOnCentCom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,7 +376,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
|
|
||||||
private void CheckRoundShouldEnd()
|
private void CheckRoundShouldEnd()
|
||||||
{
|
{
|
||||||
if (!RuleAdded)
|
if (!RuleAdded || RuleWinType == WinType.CrewMajor || RuleWinType == WinType.OpsMajor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If there are any nuclear bombs that are active, immediately return. We're not over yet.
|
// If there are any nuclear bombs that are active, immediately return. We're not over yet.
|
||||||
@@ -401,8 +414,6 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
if (operativesAlive)
|
if (operativesAlive)
|
||||||
return; // There are living operatives than can access the shuttle, or are still on the station's map.
|
return; // There are living operatives than can access the shuttle, or are still on the station's map.
|
||||||
|
|
||||||
_winType = WinType.CrewMajor;
|
|
||||||
|
|
||||||
// Check that there are spawns available and that they can access the shuttle.
|
// Check that there are spawns available and that they can access the shuttle.
|
||||||
var spawnsAvailable = EntityQuery<NukeOperativeSpawnerComponent>(true).Any();
|
var spawnsAvailable = EntityQuery<NukeOperativeSpawnerComponent>(true).Any();
|
||||||
if (spawnsAvailable && shuttleMapId == _nukiePlanet)
|
if (spawnsAvailable && shuttleMapId == _nukiePlanet)
|
||||||
@@ -419,7 +430,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
_winConditions.Add(WinCondition.AllNukiesDead);
|
_winConditions.Add(WinCondition.AllNukiesDead);
|
||||||
}
|
}
|
||||||
|
|
||||||
_roundEndSystem.EndRound();
|
RuleWinType = WinType.CrewMajor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNukeDisarm(NukeDisarmSuccessEvent ev)
|
private void OnNukeDisarm(NukeDisarmSuccessEvent ev)
|
||||||
@@ -790,7 +801,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
|
|
||||||
public override void Started()
|
public override void Started()
|
||||||
{
|
{
|
||||||
_winType = WinType.Neutral;
|
RuleWinType = WinType.Neutral;
|
||||||
_winConditions.Clear();
|
_winConditions.Clear();
|
||||||
_nukieOutpost = null;
|
_nukieOutpost = null;
|
||||||
_nukiePlanet = null;
|
_nukiePlanet = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user