2023-10-04 22:22:30 -07:00
using Content.Server.Administration.Logs ;
using Content.Server.Antag ;
2024-01-14 03:20:35 +00:00
using Content.Server.EUI ;
2023-10-04 22:22:30 -07:00
using Content.Server.Flash ;
2023-10-04 21:47:33 -04:00
using Content.Server.GameTicking.Rules.Components ;
using Content.Server.Mind ;
2023-10-04 22:22:30 -07:00
using Content.Server.NPC.Components ;
2023-10-04 21:47:33 -04:00
using Content.Server.NPC.Systems ;
2023-10-04 22:22:30 -07:00
using Content.Server.Popups ;
2024-01-14 03:20:35 +00:00
using Content.Server.Revolutionary ;
2023-10-04 22:22:30 -07:00
using Content.Server.Revolutionary.Components ;
2023-10-04 21:47:33 -04:00
using Content.Server.Roles ;
2023-10-04 22:22:30 -07:00
using Content.Server.RoundEnd ;
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.Shuttles.Systems ;
using Content.Server.Station.Systems ;
2023-10-04 22:22:30 -07:00
using Content.Shared.Database ;
2023-10-04 21:47:33 -04:00
using Content.Shared.Humanoid ;
2023-10-04 22:22:30 -07:00
using Content.Shared.IdentityManagement ;
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.Shared.Inventory ;
2023-10-04 22:22:30 -07:00
using Content.Shared.Mind ;
2024-01-14 03:20:35 +00:00
using Content.Shared.Mind.Components ;
2023-10-04 22:22:30 -07:00
using Content.Shared.Mindshield.Components ;
2023-10-04 21:47:33 -04:00
using Content.Shared.Mobs ;
using Content.Shared.Mobs.Components ;
2023-10-04 22:22:30 -07:00
using Content.Shared.Mobs.Systems ;
2023-10-04 21:47:33 -04:00
using Content.Shared.Revolutionary.Components ;
using Content.Shared.Roles ;
using Content.Shared.Stunnable ;
using Content.Shared.Zombies ;
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 Robust.Shared.Prototypes ;
2023-10-04 22:22:30 -07:00
using Robust.Shared.Timing ;
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 ;
2023-10-04 21:47:33 -04:00
namespace Content.Server.GameTicking.Rules ;
/// <summary>
/// Where all the main stuff for Revolutionaries happens (Assigning Head Revs, Command on station, and checking for the game to end.)
/// </summary>
public sealed class RevolutionaryRuleSystem : GameRuleSystem < RevolutionaryRuleComponent >
{
[Dependency] private readonly IAdminLogManager _adminLogManager = default ! ;
[Dependency] private readonly IGameTiming _timing = default ! ;
[Dependency] private readonly AntagSelectionSystem _antagSelection = default ! ;
2024-01-14 03:20:35 +00:00
[Dependency] private readonly EuiManager _euiMan = default ! ;
2023-10-04 21:47:33 -04:00
[Dependency] private readonly MindSystem _mind = default ! ;
[Dependency] private readonly MobStateSystem _mobState = default ! ;
[Dependency] private readonly NpcFactionSystem _npcFaction = default ! ;
[Dependency] private readonly PopupSystem _popup = default ! ;
[Dependency] private readonly RoleSystem _role = default ! ;
[Dependency] private readonly SharedStunSystem _stun = default ! ;
[Dependency] private readonly RoundEndSystem _roundEnd = 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 StationSystem _stationSystem = default ! ;
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default ! ;
[Dependency] private readonly InventorySystem _inventory = default ! ;
2023-10-04 21:47:33 -04: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
//Used in OnPostFlash, no reference to the rule component is available
public readonly ProtoId < NpcFactionPrototype > RevolutionaryNpcFaction = "Revolutionary" ;
public readonly ProtoId < NpcFactionPrototype > RevPrototypeId = "Rev" ;
2023-10-04 21:47:33 -04:00
public override void Initialize ( )
{
base . Initialize ( ) ;
SubscribeLocalEvent < RoundStartAttemptEvent > ( OnStartAttempt ) ;
SubscribeLocalEvent < RulePlayerJobsAssignedEvent > ( OnPlayerJobAssigned ) ;
SubscribeLocalEvent < CommandStaffComponent , MobStateChangedEvent > ( OnCommandMobStateChanged ) ;
SubscribeLocalEvent < HeadRevolutionaryComponent , MobStateChangedEvent > ( OnHeadRevMobStateChanged ) ;
SubscribeLocalEvent < RoundEndTextAppendEvent > ( OnRoundEndText ) ;
2023-10-05 16:05:09 +01:00
SubscribeLocalEvent < RevolutionaryRoleComponent , GetBriefingEvent > ( OnGetBriefing ) ;
2023-10-04 21:47:33 -04:00
SubscribeLocalEvent < HeadRevolutionaryComponent , AfterFlashedEvent > ( OnPostFlash ) ;
}
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
//Set miniumum players
protected override void Added ( EntityUid uid , RevolutionaryRuleComponent component , GameRuleComponent gameRule , GameRuleAddedEvent args )
{
base . Added ( uid , component , gameRule , args ) ;
gameRule . MinPlayers = component . MinPlayers ;
}
2023-10-04 21:47:33 -04:00
protected override void Started ( EntityUid uid , RevolutionaryRuleComponent component , GameRuleComponent gameRule , GameRuleStartedEvent args )
{
base . Started ( uid , component , gameRule , args ) ;
component . CommandCheck = _timing . CurTime + component . TimerWait ;
}
protected override void ActiveTick ( EntityUid uid , RevolutionaryRuleComponent component , GameRuleComponent gameRule , float frameTime )
{
base . ActiveTick ( uid , component , gameRule , frameTime ) ;
if ( component . CommandCheck < = _timing . CurTime )
{
component . CommandCheck = _timing . CurTime + component . TimerWait ;
if ( CheckCommandLose ( ) )
{
_roundEnd . DoRoundEndBehavior ( RoundEndBehavior . ShuttleCall , component . ShuttleCallTime ) ;
GameTicker . EndGameRule ( uid , gameRule ) ;
}
}
}
private void OnRoundEndText ( RoundEndTextAppendEvent ev )
{
var revsLost = CheckRevsLose ( ) ;
var commandLost = CheckCommandLose ( ) ;
var query = AllEntityQuery < RevolutionaryRuleComponent > ( ) ;
while ( query . MoveNext ( out var headrev ) )
{
// This is (revsLost, commandsLost) concatted together
// (moony wrote this comment idk what it means)
var index = ( commandLost ? 1 : 0 ) | ( revsLost ? 2 : 0 ) ;
ev . AddLine ( Loc . GetString ( Outcomes [ index ] ) ) ;
2023-11-27 21:43:48 +00:00
ev . AddLine ( Loc . GetString ( "rev-headrev-count" , ( "initialCount" , headrev . HeadRevs . Count ) ) ) ;
2024-01-03 03:32:38 -05:00
foreach ( var player in headrev . HeadRevs )
2023-10-04 21:47:33 -04:00
{
2023-11-27 21:43:48 +00:00
// TODO: when role entities are a thing this has to change
2024-01-03 03:32:38 -05:00
var count = CompOrNull < RevolutionaryRoleComponent > ( player . Value ) ? . ConvertedCount ? ? 0 ;
_mind . TryGetSession ( player . Value , out var session ) ;
var username = session ? . Name ;
if ( username ! = null )
{
ev . AddLine ( Loc . GetString ( "rev-headrev-name-user" ,
( "name" , player . Key ) ,
( "username" , username ) , ( "count" , count ) ) ) ;
}
else
{
ev . AddLine ( Loc . GetString ( "rev-headrev-name" ,
( "name" , player . Key ) , ( "count" , count ) ) ) ;
}
2023-11-27 21:43:48 +00:00
// TODO: someone suggested listing all alive? revs maybe implement at some point
2023-10-04 21:47:33 -04:00
}
}
}
2023-10-05 16:05:09 +01:00
private void OnGetBriefing ( EntityUid uid , RevolutionaryRoleComponent comp , ref GetBriefingEvent args )
{
if ( ! TryComp < MindComponent > ( uid , out var mind ) | | mind . OwnedEntity = = null )
return ;
var head = HasComp < HeadRevolutionaryComponent > ( mind . OwnedEntity ) ;
args . Append ( Loc . GetString ( head ? "head-rev-briefing" : "rev-briefing" ) ) ;
}
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
//Check for enough players to start rule
2023-10-04 21:47:33 -04:00
private void OnStartAttempt ( RoundStartAttemptEvent 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
TryRoundStartAttempt ( ev , Loc . GetString ( "roles-antag-rev-name" ) ) ;
2023-10-04 21:47:33 -04:00
}
private void OnPlayerJobAssigned ( RulePlayerJobsAssignedEvent ev )
{
var query = QueryActiveRules ( ) ;
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
while ( query . MoveNext ( out var uid , out var activeGameRule , out var comp , out var gameRule ) )
2023-10-04 21:47:33 -04: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
var eligiblePlayers = _antagSelection . GetEligiblePlayers ( ev . Players , comp . HeadRevPrototypeId ) ;
if ( eligiblePlayers . Count = = 0 )
continue ;
var headRevCount = _antagSelection . CalculateAntagCount ( ev . Players . Length , comp . PlayersPerHeadRev , comp . MaxHeadRevs ) ;
var headRevs = _antagSelection . ChooseAntags ( headRevCount , eligiblePlayers ) ;
GiveHeadRev ( headRevs , comp . HeadRevPrototypeId , comp ) ;
2023-10-04 21:47:33 -04: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 GiveHeadRev ( IEnumerable < EntityUid > chosen , ProtoId < AntagPrototype > antagProto , RevolutionaryRuleComponent comp )
2023-10-04 21:47:33 -04:00
{
foreach ( var headRev in chosen )
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
GiveHeadRev ( headRev , antagProto , comp ) ;
}
private void GiveHeadRev ( EntityUid chosen , ProtoId < AntagPrototype > antagProto , RevolutionaryRuleComponent comp )
{
RemComp < CommandStaffComponent > ( chosen ) ;
2023-10-04 21:47:33 -04: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
var inCharacterName = MetaData ( chosen ) . EntityName ;
2023-10-04 21:47:33 -04: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 ( ! _mind . TryGetMind ( chosen , out var mind , out _ ) )
return ;
if ( ! _role . MindHasRole < RevolutionaryRoleComponent > ( mind ) )
{
_role . MindAddRole ( mind , new RevolutionaryRoleComponent { PrototypeId = antagProto } , silent : true ) ;
2023-10-04 21:47:33 -04: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
comp . HeadRevs . Add ( inCharacterName , mind ) ;
_inventory . SpawnItemsOnEntity ( chosen , comp . StartingGear ) ;
var revComp = EnsureComp < RevolutionaryComponent > ( chosen ) ;
EnsureComp < HeadRevolutionaryComponent > ( chosen ) ;
_antagSelection . SendBriefing ( chosen , Loc . GetString ( "head-rev-role-greeting" ) , Color . CornflowerBlue , revComp . RevStartSound ) ;
2023-10-04 21:47:33 -04:00
}
/// <summary>
/// Called when a Head Rev uses a flash in melee to convert somebody else.
/// </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
private void OnPostFlash ( EntityUid uid , HeadRevolutionaryComponent comp , ref AfterFlashedEvent ev )
2023-10-04 21:47:33 -04: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
var alwaysConvertible = HasComp < AlwaysRevolutionaryConvertibleComponent > ( ev . Target ) ;
2023-10-04 21:47:33 -04:00
if ( ! _mind . TryGetMind ( ev . Target , out var mindId , out var mind ) & & ! alwaysConvertible )
return ;
if ( HasComp < RevolutionaryComponent > ( ev . Target ) | |
HasComp < MindShieldComponent > ( ev . Target ) | |
! HasComp < HumanoidAppearanceComponent > ( ev . Target ) & &
! alwaysConvertible | |
! _mobState . IsAlive ( ev . Target ) | |
HasComp < ZombieComponent > ( ev . Target ) )
{
return ;
}
_npcFaction . AddFaction ( ev . Target , RevolutionaryNpcFaction ) ;
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 revComp = EnsureComp < RevolutionaryComponent > ( ev . Target ) ;
2023-10-04 21:47:33 -04:00
_stun . TryParalyze ( ev . Target , comp . StunTime , true ) ;
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
2023-10-04 21:47:33 -04:00
if ( ev . User ! = null )
{
_adminLogManager . Add ( LogType . Mind , LogImpact . Medium , $"{ToPrettyString(ev.User.Value)} converted {ToPrettyString(ev.Target)} into a Revolutionary" ) ;
2023-11-27 21:43:48 +00:00
if ( _mind . TryGetRole < RevolutionaryRoleComponent > ( ev . User . Value , out var headrev ) )
headrev . ConvertedCount + + ;
2023-10-04 21:47:33 -04:00
}
if ( mindId = = default | | ! _role . MindHasRole < RevolutionaryRoleComponent > ( mindId ) )
{
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
_role . MindAddRole ( mindId , new RevolutionaryRoleComponent { PrototypeId = RevPrototypeId } ) ;
2023-10-04 21:47:33 -04: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
2023-10-04 21:47:33 -04:00
if ( mind ? . Session ! = 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
_antagSelection . SendBriefing ( mind . Session , Loc . GetString ( "rev-role-greeting" ) , Color . Red , revComp . RevStartSound ) ;
2023-10-04 21:47:33 -04: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
public void OnHeadRevAdmin ( EntityUid entity )
2023-10-04 21:47:33 -04: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 ( HasComp < HeadRevolutionaryComponent > ( entity ) )
2023-10-04 21:47:33 -04:00
return ;
var revRule = EntityQuery < RevolutionaryRuleComponent > ( ) . FirstOrDefault ( ) ;
if ( revRule = = null )
{
GameTicker . StartGameRule ( "Revolutionary" , out var ruleEnt ) ;
revRule = Comp < RevolutionaryRuleComponent > ( ruleEnt ) ;
}
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
GiveHeadRev ( entity , revRule . HeadRevPrototypeId , revRule ) ;
2023-10-04 21:47:33 -04: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
//TODO: Enemies of the revolution
2023-10-04 21:47:33 -04:00
private void OnCommandMobStateChanged ( EntityUid uid , CommandStaffComponent comp , MobStateChangedEvent ev )
{
if ( ev . NewMobState = = MobState . Dead | | ev . NewMobState = = MobState . Invalid )
CheckCommandLose ( ) ;
}
/// <summary>
/// Checks if all of command is dead and if so will remove all sec and command jobs if there were any left.
/// </summary>
private bool CheckCommandLose ( )
{
var commandList = new List < EntityUid > ( ) ;
var heads = AllEntityQuery < CommandStaffComponent > ( ) ;
while ( heads . MoveNext ( out var id , out _ ) )
{
commandList . Add ( id ) ;
}
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
return IsGroupDead ( commandList , true ) ;
2023-10-04 21:47:33 -04:00
}
private void OnHeadRevMobStateChanged ( EntityUid uid , HeadRevolutionaryComponent comp , MobStateChangedEvent ev )
{
if ( ev . NewMobState = = MobState . Dead | | ev . NewMobState = = MobState . Invalid )
CheckRevsLose ( ) ;
}
/// <summary>
/// Checks if all the Head Revs are dead and if so will deconvert all regular revs.
/// </summary>
private bool CheckRevsLose ( )
{
var stunTime = TimeSpan . FromSeconds ( 4 ) ;
var headRevList = new List < EntityUid > ( ) ;
var headRevs = AllEntityQuery < HeadRevolutionaryComponent , MobStateComponent > ( ) ;
while ( headRevs . MoveNext ( out var uid , out _ , out _ ) )
{
headRevList . Add ( uid ) ;
}
// If no Head Revs are alive all normal Revs will lose their Rev status and rejoin Nanotrasen
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 ( IsGroupDead ( headRevList , false ) )
2023-10-04 21:47:33 -04:00
{
2024-01-14 03:20:35 +00:00
var rev = AllEntityQuery < RevolutionaryComponent , MindContainerComponent > ( ) ;
while ( rev . MoveNext ( out var uid , out _ , out var mc ) )
2023-10-04 21:47:33 -04:00
{
2024-01-14 03:20:35 +00:00
if ( HasComp < HeadRevolutionaryComponent > ( uid ) )
continue ;
_npcFaction . RemoveFaction ( uid , RevolutionaryNpcFaction ) ;
_stun . TryParalyze ( uid , stunTime , true ) ;
RemCompDeferred < RevolutionaryComponent > ( uid ) ;
_popup . PopupEntity ( Loc . GetString ( "rev-break-control" , ( "name" , Identity . Entity ( uid , EntityManager ) ) ) , uid ) ;
_adminLogManager . Add ( LogType . Mind , LogImpact . Medium , $"{ToPrettyString(uid)} was deconverted due to all Head Revolutionaries dying." ) ;
if ( ! _mind . TryGetMind ( uid , out var mindId , out var mind , mc ) )
continue ;
// remove their antag role
_role . MindTryRemoveRole < RevolutionaryRoleComponent > ( mindId ) ;
// make it very obvious to the rev they've been deconverted since
// they may not see the popup due to antag and/or new player tunnel vision
if ( _mind . TryGetSession ( mindId , out var session ) )
_euiMan . OpenEui ( new DeconvertedEui ( ) , session ) ;
2023-10-04 21:47:33 -04:00
}
return true ;
}
return false ;
}
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
/// <summary>
/// Will take a group of entities and check if they are all alive or dead
/// </summary>
/// <param name="list">The list of the entities</param>
/// <param name="checkOffStation">Bool for if you want to check if someone is in space and consider them dead. (Won't check when emergency shuttle arrives just in case)</param>
/// <returns></returns>
private bool IsGroupDead ( List < EntityUid > list , bool checkOffStation )
{
var dead = 0 ;
foreach ( var entity in list )
{
if ( TryComp < MobStateComponent > ( entity , out var state ) )
{
if ( state . CurrentState = = MobState . Dead | | state . CurrentState = = MobState . Invalid )
{
dead + + ;
}
else if ( checkOffStation & & _stationSystem . GetOwningStation ( entity ) = = null & & ! _emergencyShuttle . EmergencyShuttleArrived )
{
dead + + ;
}
}
//If they don't have the MobStateComponent they might as well be dead.
else
{
dead + + ;
}
}
return dead = = list . Count | | list . Count = = 0 ;
}
2023-10-04 21:47:33 -04:00
private static readonly string [ ] Outcomes =
{
// revs survived and heads survived... how
"rev-reverse-stalemate" ,
// revs won and heads died
"rev-won" ,
// revs lost and heads survived
"rev-lost" ,
// revs lost and heads died
"rev-stalemate"
} ;
}