Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
using Content.Server.Antag ;
2023-08-30 10:56:20 +03:00
using Content.Server.Communications ;
2022-11-27 19:25:55 +01:00
using Content.Server.GameTicking.Rules.Components ;
2022-05-18 04:48:35 +02:00
using Content.Server.Nuke ;
2023-08-30 10:56:20 +03:00
using Content.Server.NukeOps ;
using Content.Server.Popups ;
2023-06-07 10:15:22 +03:00
using Content.Server.Roles ;
2022-05-18 04:48:35 +02:00
using Content.Server.RoundEnd ;
2023-08-30 10:56:20 +03:00
using Content.Server.Shuttles.Events ;
2022-07-15 14:11:41 +10:00
using Content.Server.Shuttles.Systems ;
2022-11-27 19:25:55 +01:00
using Content.Server.Station.Components ;
2023-08-30 10:56:20 +03:00
using Content.Server.Store.Systems ;
2024-06-04 11:53:24 +00:00
using Content.Shared.GameTicking.Components ;
2023-01-13 16:57:10 -08:00
using Content.Shared.Mobs ;
using Content.Shared.Mobs.Components ;
2024-03-18 07:23:25 +00:00
using Content.Shared.NPC.Components ;
using Content.Shared.NPC.Systems ;
2022-11-27 19:25:55 +01:00
using Content.Shared.Nuke ;
2023-08-30 10:56:20 +03:00
using Content.Shared.NukeOps ;
2025-08-13 12:51:46 +02:00
using Content.Shared.Roles.Components ;
2023-08-30 10:56:20 +03:00
using Content.Shared.Store ;
using Content.Shared.Tag ;
2023-07-25 17:31:35 -04:00
using Content.Shared.Zombies ;
2022-05-18 04:48:35 +02:00
using Robust.Shared.Map ;
using Robust.Shared.Random ;
using Robust.Shared.Utility ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
using System.Linq ;
2025-08-08 11:22:34 -04:00
using Content.Shared.Station.Components ;
2024-06-01 11:29:17 -04:00
using Content.Shared.Store.Components ;
2025-07-07 15:57:05 -04:00
using Robust.Shared.Prototypes ;
2022-05-18 04:48:35 +02:00
namespace Content.Server.GameTicking.Rules ;
2023-04-25 20:23:14 -04:00
public sealed class NukeopsRuleSystem : GameRuleSystem < NukeopsRuleComponent >
2022-05-18 04:48:35 +02:00
{
2024-10-10 10:48:56 +02:00
[Dependency] private readonly AntagSelectionSystem _antag = default ! ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
[Dependency] private readonly EmergencyShuttleSystem _emergency = default ! ;
2023-07-17 15:51:52 +12:00
[Dependency] private readonly NpcFactionSystem _npcFaction = default ! ;
2023-09-16 12:48:42 +01:00
[Dependency] private readonly PopupSystem _popupSystem = default ! ;
2022-05-18 04:48:35 +02:00
[Dependency] private readonly RoundEndSystem _roundEndSystem = default ! ;
2023-09-16 12:48:42 +01:00
[Dependency] private readonly StoreSystem _store = default ! ;
2023-08-30 10:56:20 +03:00
[Dependency] private readonly TagSystem _tag = default ! ;
2023-11-16 16:04:50 -05:00
2025-07-07 15:57:05 -04:00
private static readonly ProtoId < CurrencyPrototype > TelecrystalCurrencyPrototype = "Telecrystal" ;
private static readonly ProtoId < TagPrototype > NukeOpsUplinkTagPrototype = "NukeOpsUplink" ;
2023-03-27 10:24:00 +13:00
2025-05-18 12:34:33 +01:00
2022-05-18 04:48:35 +02:00
public override void Initialize ( )
{
base . Initialize ( ) ;
SubscribeLocalEvent < NukeExplodedEvent > ( OnNukeExploded ) ;
2022-09-13 19:42:19 -07:00
SubscribeLocalEvent < GameRunLevelChangedEvent > ( OnRunLevelChanged ) ;
SubscribeLocalEvent < NukeDisarmSuccessEvent > ( OnNukeDisarm ) ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
SubscribeLocalEvent < NukeOperativeComponent , ComponentRemove > ( OnComponentRemove ) ;
SubscribeLocalEvent < NukeOperativeComponent , MobStateChangedEvent > ( OnMobStateChanged ) ;
2023-07-25 17:31:35 -04:00
SubscribeLocalEvent < NukeOperativeComponent , EntityZombifiedEvent > ( OnOperativeZombified ) ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
2024-10-10 10:48:56 +02:00
SubscribeLocalEvent < NukeopsRoleComponent , GetBriefingEvent > ( OnGetBriefing ) ;
2023-08-30 10:56:20 +03:00
SubscribeLocalEvent < ConsoleFTLAttemptEvent > ( OnShuttleFTLAttempt ) ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
SubscribeLocalEvent < WarDeclaredEvent > ( OnWarDeclared ) ;
SubscribeLocalEvent < CommunicationConsoleCallShuttleAttemptEvent > ( OnShuttleCallAttempt ) ;
2024-04-24 21:31:45 -04:00
SubscribeLocalEvent < NukeopsRuleComponent , AfterAntagEntitySelectedEvent > ( OnAfterAntagEntSelected ) ;
2024-07-01 18:23:36 -04:00
SubscribeLocalEvent < NukeopsRuleComponent , RuleLoadedGridsEvent > ( OnRuleLoadedGrids ) ;
2023-08-30 10:56:20 +03:00
}
2024-10-10 10:48:56 +02:00
protected override void Started ( EntityUid uid ,
NukeopsRuleComponent component ,
GameRuleComponent gameRule ,
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
GameRuleStartedEvent args )
2023-08-30 10:56:20 +03:00
{
2024-04-24 21:31:45 -04:00
var eligible = new List < Entity < StationEventEligibleComponent , NpcFactionMemberComponent > > ( ) ;
var eligibleQuery = EntityQueryEnumerator < StationEventEligibleComponent , NpcFactionMemberComponent > ( ) ;
while ( eligibleQuery . MoveNext ( out var eligibleUid , out var eligibleComp , out var member ) )
2023-08-30 10:56:20 +03:00
{
2024-04-24 21:31:45 -04:00
if ( ! _npcFaction . IsFactionHostile ( component . Faction , ( eligibleUid , member ) ) )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
continue ;
2023-08-30 10:56:20 +03:00
2024-04-24 21:31:45 -04:00
eligible . Add ( ( eligibleUid , eligibleComp , member ) ) ;
}
2023-08-30 10:56:20 +03:00
2024-04-24 21:31:45 -04:00
if ( eligible . Count = = 0 )
return ;
2023-08-30 10:56:20 +03:00
2024-04-24 21:31:45 -04:00
component . TargetStation = RobustRandom . Pick ( eligible ) ;
2023-08-30 10:56:20 +03:00
}
2024-04-24 21:31:45 -04:00
#region Event Handlers
2024-10-10 10:48:56 +02:00
protected override void AppendRoundEndText ( EntityUid uid ,
NukeopsRuleComponent component ,
GameRuleComponent gameRule ,
2024-04-24 21:31:45 -04:00
ref RoundEndTextAppendEvent args )
2023-08-30 10:56:20 +03:00
{
2024-04-24 21:31:45 -04:00
var winText = Loc . GetString ( $"nukeops-{component.WinType.ToString().ToLower()}" ) ;
args . AddLine ( winText ) ;
2023-08-30 10:56:20 +03:00
2024-04-24 21:31:45 -04:00
foreach ( var cond in component . WinConditions )
{
var text = Loc . GetString ( $"nukeops-cond-{cond.ToString().ToLower()}" ) ;
args . AddLine ( text ) ;
2023-08-30 10:56:20 +03:00
}
2022-09-01 03:36:27 +01:00
2024-04-24 21:31:45 -04:00
args . AddLine ( Loc . GetString ( "nukeops-list-start" ) ) ;
2023-04-25 20:23:14 -04:00
2025-05-18 12:34:33 +01:00
var antags = _antag . GetAntagIdentifiers ( uid ) ;
2022-09-01 03:36:27 +01:00
2024-04-24 21:31:45 -04:00
foreach ( var ( _ , sessionData , name ) in antags )
{
args . AddLine ( Loc . GetString ( "nukeops-list-name-user" , ( "name" , name ) , ( "user" , sessionData . UserName ) ) ) ;
2023-04-25 20:23:14 -04:00
}
2022-09-01 03:36:27 +01:00
}
2022-05-18 04:48:35 +02:00
private void OnNukeExploded ( NukeExplodedEvent ev )
{
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
var query = QueryActiveRules ( ) ;
while ( query . MoveNext ( out var uid , out _ , out var nukeops , out _ ) )
2023-04-24 16:21:05 +10:00
{
2023-04-25 20:23:14 -04:00
if ( ev . OwningStation ! = null )
2023-04-24 16:21:05 +10:00
{
2024-04-24 21:31:45 -04:00
if ( ev . OwningStation = = GetOutpost ( uid ) )
2023-04-24 01:20:51 -04:00
{
2023-04-25 20:23:14 -04:00
nukeops . WinConditions . Add ( WinCondition . NukeExplodedOnNukieOutpost ) ;
2025-05-18 12:34:33 +01:00
SetWinType ( ( uid , nukeops ) , WinType . CrewMajor , GameTicker . IsGameRuleActive ( "Nukeops" ) ) ; // End the round ONLY if the actual gamemode is NukeOps.
if ( ! GameTicker . IsGameRuleActive ( "Nukeops" ) ) // End the rule if the LoneOp shuttle got nuked, because that particular LoneOp clearly failed, and should not be considered a Syndie victory even if a future LoneOp wins.
GameTicker . EndGameRule ( uid ) ;
2023-04-25 20:23:14 -04:00
continue ;
}
if ( TryComp ( nukeops . TargetStation , out StationDataComponent ? data ) )
{
var correctStation = false ;
foreach ( var grid in data . Grids )
2022-09-13 19:42:19 -07:00
{
2023-04-25 20:23:14 -04:00
if ( grid ! = ev . OwningStation )
{
continue ;
}
nukeops . WinConditions . Add ( WinCondition . NukeExplodedOnCorrectStation ) ;
2024-04-24 21:31:45 -04:00
SetWinType ( ( uid , nukeops ) , WinType . OpsMajor ) ;
2023-04-25 20:23:14 -04:00
correctStation = true ;
2022-09-13 19:42:19 -07:00
}
2023-04-25 20:23:14 -04:00
if ( correctStation )
continue ;
2022-09-15 06:50:47 -07:00
}
2023-04-25 20:23:14 -04:00
nukeops . WinConditions . Add ( WinCondition . NukeExplodedOnIncorrectLocation ) ;
}
else
{
nukeops . WinConditions . Add ( WinCondition . NukeExplodedOnIncorrectLocation ) ;
2022-09-13 19:42:19 -07:00
}
2022-09-15 06:50:47 -07:00
2025-05-18 12:34:33 +01:00
if ( GameTicker . IsGameRuleActive ( "Nukeops" ) ) // If it's Nukeops then end the round on any detonation
{
_roundEndSystem . EndRound ( ) ;
}
else
{ // It's a LoneOp. Only end the round if the station was destroyed
var handled = false ;
foreach ( var cond in nukeops . WinConditions )
{
if ( cond . ToString ( ) . ToLower ( ) = = "NukeExplodedOnCorrectStation" ) // If this is true, then the nuke destroyed the station! It's likely everyone is very dead so keeping the round going is pointless.
{
_roundEndSystem . EndRound ( ) ; // end the round!
handled = true ;
break ;
}
}
if ( ! handled ) // The round didn't end, so end the rule so it doesn't get overridden by future LoneOps.
{
GameTicker . EndGameRule ( uid ) ;
}
}
2022-09-13 19:42:19 -07:00
}
2022-05-18 04:48:35 +02:00
}
2022-09-13 19:42:19 -07:00
private void OnRunLevelChanged ( GameRunLevelChangedEvent ev )
{
2024-04-24 21:31:45 -04:00
if ( ev . New is not GameRunLevel . PostRound )
return ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
var query = QueryActiveRules ( ) ;
while ( query . MoveNext ( out var uid , out _ , out var nukeops , out _ ) )
2022-09-13 19:42:19 -07:00
{
2024-04-24 21:31:45 -04:00
OnRoundEnd ( ( uid , nukeops ) ) ;
}
}
private void OnRoundEnd ( Entity < NukeopsRuleComponent > ent )
{
// If the win condition was set to operative/crew major win, ignore.
if ( ent . Comp . WinType = = WinType . OpsMajor | | ent . Comp . WinType = = WinType . CrewMajor )
return ;
var nukeQuery = AllEntityQuery < NukeComponent , TransformComponent > ( ) ;
var centcomms = _emergency . GetCentcommMaps ( ) ;
while ( nukeQuery . MoveNext ( out var nuke , out var nukeTransform ) )
{
if ( nuke . Status ! = NukeStatus . ARMED )
continue ;
// UH OH
if ( nukeTransform . MapUid ! = null & & centcomms . Contains ( nukeTransform . MapUid . Value ) )
2023-04-25 20:23:14 -04:00
{
2024-04-24 21:31:45 -04:00
ent . Comp . WinConditions . Add ( WinCondition . NukeActiveAtCentCom ) ;
SetWinType ( ( ent , ent ) , WinType . OpsMajor ) ;
return ;
}
if ( nukeTransform . GridUid = = null | | ent . Comp . TargetStation = = null )
continue ;
if ( ! TryComp ( ent . Comp . TargetStation . Value , out StationDataComponent ? data ) )
continue ;
foreach ( var grid in data . Grids )
{
if ( grid ! = nukeTransform . GridUid )
continue ;
ent . Comp . WinConditions . Add ( WinCondition . NukeActiveInStation ) ;
SetWinType ( ent , WinType . OpsMajor ) ;
return ;
2023-04-25 20:23:14 -04:00
}
2022-09-13 19:42:19 -07:00
}
2024-04-24 21:31:45 -04:00
if ( _antag . AllAntagsAlive ( ent . Owner ) )
{
SetWinType ( ent , WinType . OpsMinor ) ;
ent . Comp . WinConditions . Add ( WinCondition . AllNukiesAlive ) ;
return ;
}
ent . Comp . WinConditions . Add ( _antag . AnyAliveAntags ( ent . Owner )
? WinCondition . SomeNukiesAlive
: WinCondition . AllNukiesDead ) ;
var diskAtCentCom = false ;
var diskQuery = AllEntityQuery < NukeDiskComponent , TransformComponent > ( ) ;
2024-08-28 16:05:04 -04:00
while ( diskQuery . MoveNext ( out var diskUid , out _ , out var transform ) )
2024-04-24 21:31:45 -04:00
{
diskAtCentCom = transform . MapUid ! = null & & centcomms . Contains ( transform . MapUid . Value ) ;
2024-08-28 16:05:04 -04:00
diskAtCentCom | = _emergency . IsTargetEscaping ( diskUid ) ;
2024-04-24 21:31:45 -04:00
// TODO: The target station should be stored, and the nuke disk should store its original station.
// This is fine for now, because we can assume a single station in base SS14.
break ;
}
// If the disk is currently at Central Command, the crew wins - just slightly.
// This also implies that some nuclear operatives have died.
2024-10-10 10:48:56 +02:00
SetWinType ( ent ,
diskAtCentCom
2024-04-24 21:31:45 -04:00
? WinType . CrewMinor
: WinType . OpsMinor ) ;
ent . Comp . WinConditions . Add ( diskAtCentCom
? WinCondition . NukeDiskOnCentCom
: WinCondition . NukeDiskNotOnCentCom ) ;
2022-09-13 19:42:19 -07:00
}
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
private void OnNukeDisarm ( NukeDisarmSuccessEvent ev )
{
CheckRoundShouldEnd ( ) ;
}
private void OnComponentRemove ( EntityUid uid , NukeOperativeComponent component , ComponentRemove args )
{
CheckRoundShouldEnd ( ) ;
}
private void OnMobStateChanged ( EntityUid uid , NukeOperativeComponent component , MobStateChangedEvent ev )
{
if ( ev . NewMobState = = MobState . Dead )
CheckRoundShouldEnd ( ) ;
}
2024-04-24 21:31:45 -04:00
private void OnOperativeZombified ( EntityUid uid , NukeOperativeComponent component , ref EntityZombifiedEvent args )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
2024-04-24 21:31:45 -04:00
RemCompDeferred ( uid , component ) ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
}
2024-07-01 18:23:36 -04:00
private void OnRuleLoadedGrids ( Entity < NukeopsRuleComponent > ent , ref RuleLoadedGridsEvent args )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
2024-07-01 18:23:36 -04:00
// Check each nukie shuttle
var query = EntityQueryEnumerator < NukeOpsShuttleComponent > ( ) ;
while ( query . MoveNext ( out var uid , out var shuttle ) )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
2024-07-01 18:23:36 -04:00
// Check if the shuttle's mapID is the one that just got loaded for this rule
if ( Transform ( uid ) . MapID = = args . Map )
{
shuttle . AssociatedRule = ent ;
break ;
}
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
}
}
private void OnShuttleFTLAttempt ( ref ConsoleFTLAttemptEvent ev )
{
var query = QueryActiveRules ( ) ;
2024-04-24 21:31:45 -04:00
while ( query . MoveNext ( out var uid , out _ , out var nukeops , out _ ) )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
2024-04-24 21:31:45 -04:00
if ( ev . Uid ! = GetShuttle ( ( uid , nukeops ) ) )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
continue ;
if ( nukeops . WarDeclaredTime ! = null )
{
var timeAfterDeclaration = Timing . CurTime . Subtract ( nukeops . WarDeclaredTime . Value ) ;
var timeRemain = nukeops . WarNukieArriveDelay . Subtract ( timeAfterDeclaration ) ;
if ( timeRemain > TimeSpan . Zero )
{
ev . Cancelled = true ;
ev . Reason = Loc . GetString ( "war-ops-infiltrator-unavailable" ,
( "time" , timeRemain . ToString ( "mm\\:ss" ) ) ) ;
continue ;
}
}
nukeops . LeftOutpost = true ;
}
}
private void OnShuttleCallAttempt ( ref CommunicationConsoleCallShuttleAttemptEvent ev )
{
var query = QueryActiveRules ( ) ;
while ( query . MoveNext ( out _ , out _ , out var nukeops , out _ ) )
{
// Can't call while war nukies are preparing to arrive
if ( nukeops is { WarDeclaredTime : not null } )
{
// Nukies must wait some time after declaration of war to get on the station
var warTime = Timing . CurTime . Subtract ( nukeops . WarDeclaredTime . Value ) ;
2024-12-13 04:10:20 +01:00
if ( warTime < nukeops . WarEvacShuttleDisabled )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
ev . Cancelled = true ;
ev . Reason = Loc . GetString ( "war-ops-shuttle-call-unavailable" ) ;
return ;
}
}
}
}
private void OnWarDeclared ( ref WarDeclaredEvent ev )
{
// TODO: this is VERY awful for multi-nukies
var query = QueryActiveRules ( ) ;
2024-04-24 21:31:45 -04:00
while ( query . MoveNext ( out var uid , out _ , out var nukeops , out _ ) )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
if ( nukeops . WarDeclaredTime ! = null )
continue ;
2024-06-04 00:04:19 +00:00
if ( TryComp < RuleGridsComponent > ( uid , out var grids ) & & Transform ( ev . DeclaratorEntity ) . MapID ! = grids . Map )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
continue ;
var newStatus = GetWarCondition ( nukeops , ev . Status ) ;
ev . Status = newStatus ;
if ( newStatus = = WarConditionStatus . WarReady )
{
nukeops . WarDeclaredTime = Timing . CurTime ;
var timeRemain = nukeops . WarNukieArriveDelay + Timing . CurTime ;
ev . DeclaratorEntity . Comp . ShuttleDisabledTime = timeRemain ;
2024-04-25 20:25:57 -04:00
DistributeExtraTc ( ( uid , nukeops ) ) ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
}
}
}
#endregion Event Handlers
2023-04-25 20:23:14 -04:00
/// <summary>
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
/// Returns conditions for war declaration
2023-04-25 20:23:14 -04:00
/// </summary>
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
public WarConditionStatus GetWarCondition ( NukeopsRuleComponent nukieRule , WarConditionStatus ? oldStatus )
2022-09-13 19:42:19 -07:00
{
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
if ( ! nukieRule . CanEnableWarOps )
return WarConditionStatus . NoWarUnknown ;
if ( EntityQuery < NukeopsRoleComponent > ( ) . Count ( ) < nukieRule . WarDeclarationMinOps )
return WarConditionStatus . NoWarSmallCrew ;
if ( nukieRule . LeftOutpost )
return WarConditionStatus . NoWarShuttleDeparted ;
if ( oldStatus = = WarConditionStatus . YesWar )
return WarConditionStatus . WarReady ;
return WarConditionStatus . YesWar ;
}
2024-04-25 20:25:57 -04:00
private void DistributeExtraTc ( Entity < NukeopsRuleComponent > nukieRule )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
{
var enumerator = EntityQueryEnumerator < StoreComponent > ( ) ;
while ( enumerator . MoveNext ( out var uid , out var component ) )
{
if ( ! _tag . HasTag ( uid , NukeOpsUplinkTagPrototype ) )
continue ;
2024-04-25 20:25:57 -04:00
if ( GetOutpost ( nukieRule . Owner ) is not { } outpost )
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
continue ;
2024-04-24 21:31:45 -04:00
if ( Transform ( uid ) . MapID ! = Transform ( outpost ) . MapID ) // Will receive bonus TC only on their start outpost
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
continue ;
2024-07-01 18:23:36 -04:00
_store . TryAddCurrency ( new ( ) { { TelecrystalCurrencyPrototype , nukieRule . Comp . WarTcAmountPerNukie } } , uid , component ) ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
var msg = Loc . GetString ( "store-currency-war-boost-given" , ( "target" , uid ) ) ;
_popupSystem . PopupEntity ( msg , uid ) ;
}
2023-04-24 16:21:05 +10:00
}
2023-04-24 01:20:51 -04:00
2024-04-24 21:31:45 -04:00
private void SetWinType ( Entity < NukeopsRuleComponent > ent , WinType type , bool endRound = true )
2023-04-24 16:21:05 +10:00
{
2024-04-24 21:31:45 -04:00
ent . Comp . WinType = type ;
2023-04-25 20:23:14 -04:00
2023-09-25 02:16:33 +06:00
if ( endRound & & ( type = = WinType . CrewMajor | | type = = WinType . OpsMajor ) )
2023-04-25 20:23:14 -04:00
_roundEndSystem . EndRound ( ) ;
}
private void CheckRoundShouldEnd ( )
{
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
var query = QueryActiveRules ( ) ;
while ( query . MoveNext ( out var uid , out _ , out var nukeops , out _ ) )
2023-04-24 16:21:05 +10:00
{
2024-04-24 21:31:45 -04:00
CheckRoundShouldEnd ( ( uid , nukeops ) ) ;
2023-04-25 20:23:14 -04:00
}
2022-09-01 03:36:27 +01:00
}
2024-04-24 21:31:45 -04:00
private void CheckRoundShouldEnd ( Entity < NukeopsRuleComponent > ent )
2022-09-01 03:36:27 +01:00
{
2024-04-24 21:31:45 -04:00
var nukeops = ent . Comp ;
2023-03-19 17:48:05 -07:00
2025-05-18 12:34:33 +01:00
if ( nukeops . WinType = = WinType . CrewMajor | | nukeops . WinType = = WinType . OpsMajor ) // Skip this if the round's victor has already been decided.
2022-09-01 03:36:27 +01:00
return ;
2024-04-24 21:31:45 -04:00
// If there are any nuclear bombs that are active, immediately return. We're not over yet.
foreach ( var nuke in EntityQuery < NukeComponent > ( ) )
2022-05-19 07:48:00 +10:00
{
2024-04-24 21:31:45 -04:00
if ( nuke . Status = = NukeStatus . ARMED )
return ;
2022-05-19 07:48:00 +10:00
}
2024-04-24 21:31:45 -04:00
var shuttle = GetShuttle ( ( ent , ent ) ) ;
2023-03-19 17:48:05 -07:00
2024-04-24 21:31:45 -04:00
MapId ? shuttleMapId = Exists ( shuttle )
? Transform ( shuttle . Value ) . MapID
: null ;
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
2024-04-24 21:31:45 -04:00
MapId ? targetStationMap = null ;
if ( nukeops . TargetStation ! = null & & TryComp ( nukeops . TargetStation , out StationDataComponent ? data ) )
{
var grid = data . Grids . FirstOrNull ( ) ;
targetStationMap = grid ! = null
? Transform ( grid . Value ) . MapID
: null ;
2022-09-01 03:36:27 +01:00
}
2022-05-18 04:48:35 +02:00
2024-04-24 21:31:45 -04:00
// Check if there are nuke operatives still alive on the same map as the shuttle,
// or on the same map as the station.
// If there are, the round can continue.
var operatives = EntityQuery < NukeOperativeComponent , MobStateComponent , TransformComponent > ( true ) ;
var operativesAlive = operatives
. Where ( op = >
op . Item3 . MapID = = shuttleMapId
| | op . Item3 . MapID = = targetStationMap )
. Any ( op = > op . Item2 . CurrentState = = MobState . Alive & & op . Item1 . Running ) ;
if ( operativesAlive )
return ; // There are living operatives than can access the shuttle, or are still on the station's map.
// Check that there are spawns available and that they can access the shuttle.
var spawnsAvailable = EntityQuery < NukeOperativeSpawnerComponent > ( true ) . Any ( ) ;
2024-06-04 00:04:19 +00:00
if ( spawnsAvailable & & CompOrNull < RuleGridsComponent > ( ent ) ? . Map = = shuttleMapId )
2024-04-24 21:31:45 -04:00
return ; // Ghost spawns can still access the shuttle. Continue the round.
// The shuttle is inaccessible to both living nuke operatives and yet to spawn nuke operatives,
// and there are no nuclear operatives on the target station's map.
nukeops . WinConditions . Add ( spawnsAvailable
? WinCondition . NukiesAbandoned
: WinCondition . AllNukiesDead ) ;
SetWinType ( ent , WinType . CrewMajor , false ) ;
2025-05-18 12:34:33 +01:00
2025-07-07 15:57:05 -04:00
if ( nukeops . RoundEndBehavior = = RoundEndBehavior . Nothing ) // It's still worth checking if operatives have all died, even if the round-end behaviour is nothing.
2025-05-18 12:34:33 +01:00
return ; // Shouldn't actually try to end the round in the case of nothing though.
2024-10-10 10:48:56 +02:00
_roundEndSystem . DoRoundEndBehavior ( nukeops . RoundEndBehavior ,
2025-05-18 12:34:33 +01:00
nukeops . EvacShuttleTime ,
nukeops . RoundEndTextSender ,
nukeops . RoundEndTextShuttleCall ,
nukeops . RoundEndTextAnnouncement ) ;
2024-04-24 21:31:45 -04:00
// prevent it called multiple times
nukeops . RoundEndBehavior = RoundEndBehavior . Nothing ;
2023-11-16 16:04:50 -05:00
}
2024-04-24 21:31:45 -04:00
private void OnAfterAntagEntSelected ( Entity < NukeopsRuleComponent > ent , ref AfterAntagEntitySelectedEvent args )
{
2024-10-10 10:48:56 +02:00
var target = ( ent . Comp . TargetStation is not null ) ? Name ( ent . Comp . TargetStation . Value ) : "the target" ;
2022-07-20 05:46:23 -04:00
2024-10-10 10:48:56 +02:00
_antag . SendBriefing ( args . Session ,
Loc . GetString ( "nukeops-welcome" ,
( "station" , target ) ,
2024-04-24 21:31:45 -04:00
( "name" , Name ( ent ) ) ) ,
Color . Red ,
ent . Comp . GreetSoundNotification ) ;
2023-08-30 10:56:20 +03:00
}
2024-10-10 10:48:56 +02:00
private void OnGetBriefing ( Entity < NukeopsRoleComponent > role , ref GetBriefingEvent args )
{
// TODO Different character screen briefing for the 3 nukie types
args . Append ( Loc . GetString ( "nukeops-briefing" ) ) ;
}
2024-04-24 21:31:45 -04:00
/// <remarks>
/// Is this method the shitty glue holding together the last of my sanity? yes.
/// Do i have a better solution? not presently.
/// </remarks>
2024-06-04 00:04:19 +00:00
private EntityUid ? GetOutpost ( Entity < RuleGridsComponent ? > ent )
2023-08-30 10:56:20 +03:00
{
2024-04-24 21:31:45 -04:00
if ( ! Resolve ( ent , ref ent . Comp , false ) )
return null ;
2023-08-30 10:56:20 +03:00
2024-07-21 03:26:30 -04:00
return ent . Comp . MapGrids . Where ( e = > ! HasComp < NukeOpsShuttleComponent > ( e ) ) . FirstOrNull ( ) ;
2023-08-30 10:56:20 +03:00
}
2024-04-24 21:31:45 -04:00
/// <remarks>
/// Is this method the shitty glue holding together the last of my sanity? yes.
/// Do i have a better solution? not presently.
/// </remarks>
private EntityUid ? GetShuttle ( Entity < NukeopsRuleComponent ? > ent )
2022-05-19 20:16:29 +02:00
{
2024-04-24 21:31:45 -04:00
if ( ! Resolve ( ent , ref ent . Comp , false ) )
return null ;
2022-09-01 03:36:27 +01:00
2024-04-24 21:31:45 -04:00
var query = EntityQueryEnumerator < NukeOpsShuttleComponent > ( ) ;
while ( query . MoveNext ( out var uid , out var comp ) )
2022-09-01 03:36:27 +01:00
{
2024-04-24 21:31:45 -04:00
if ( comp . AssociatedRule = = ent . Owner )
return uid ;
2022-09-01 03:36:27 +01:00
}
2024-04-24 21:31:45 -04:00
return null ;
2022-05-19 20:16:29 +02:00
}
2022-05-18 04:48:35 +02:00
}