99using Content . Shared . Hands . Components ;
1010using Content . Shared . Humanoid ;
1111using Content . Shared . Players ;
12- using Content . Shared . Preferences ;
12+ using Content . Shared . Silicons . Borgs . Components ;
13+ using Content . Shared . Xenoborgs . Components ;
1314using JetBrains . Annotations ;
1415using Robust . Shared . Player ;
1516using Robust . Shared . Prototypes ;
@@ -72,53 +73,6 @@ public bool CanBeAntag(ICommonSession player,
7273 return true ;
7374 }
7475
75- #region Starlight
76- /// <summary>
77- /// Checks if a player has already been pre-selected for a different antag within the same game rule.
78- /// </summary>
79- private bool HasConflictingPreSelection (
80- Entity < AntagSelectionComponent > gameRule ,
81- ProtoId < AntagSpecifierPrototype > definition ,
82- ICommonSession player )
83- {
84- foreach ( var ( proto , sessions ) in gameRule . Comp . PreSelectedSessions )
85- {
86- if ( proto != definition && sessions . Contains ( player ) )
87- return true ;
88- }
89-
90- return false ;
91- }
92-
93- /// <summary>
94- /// Checks if a given player is valid for a given antag definition, checking the player's selected profile if it exists.
95- /// </summary>
96- /// <param name="player">The player session to check.</param>
97- /// <param name="antagEntity">The entity representing the antag.</param>
98- /// <param name="selectedProfile">The player's selected character profile, if any.</param>
99- /// <param name="definition">The antag definition to check against.</param>
100- /// <returns>True if the player is valid for the antag, false otherwise.</returns>
101- private bool IsSelectedProfileValidForAntag (
102- ICommonSession player ,
103- EntityUid antagEntity ,
104- HumanoidCharacterProfile ? selectedProfile ,
105- AntagSpecifierPrototype definition )
106- {
107- if ( selectedProfile != null )
108- return IsProfileValidForAntag ( player , selectedProfile , definition ) ;
109-
110- // Bodies without HumanoidAppearanceComponent have no character profile to
111- // validate and are allowed through here. Humanoid bodies must have a recoverable
112- // profile so profile-specific antag requirements, including species restrictions
113- // and preferences, cannot be bypassed.
114- if ( ! TryComp < HumanoidAppearanceComponent > ( antagEntity , out var humanoid ) )
115- return true ;
116-
117- var profile = _humanoidAppearance . GetBaseProfile ( ( antagEntity , humanoid ) ) ;
118- return profile != null && IsProfileValidForAntag ( player , profile , definition ) ;
119- }
120- #endregion
121-
12276 /// <inhereitdoc cref="IsSessionValid(ICommonSession,Entity{AntagSelectionComponent},ProtoId{AntagSpecifierPrototype})"/>
12377 public bool IsSessionValid ( ICommonSession player ,
12478 Entity < AntagSelectionComponent > gameRule ,
@@ -239,6 +193,9 @@ public bool IsEntityValid(EntityUid? uid, AntagSpecifierPrototype def) // Starli
239193 if ( HasComp < GhostComponent > ( uid ) )
240194 return false ;
241195
196+ if ( HasComp < BorgChassisComponent > ( uid ) & & ! HasComp < XenoborgComponent > ( uid ) ) // Starlight, we should really make this look better in the future if we add more borg antags
197+ return false ; // Starlight
198+
242199 if ( ! HasComp < HumanoidAppearanceComponent > ( uid ) & & ( ! def . AllowNonHumans || ! HasComp < HandsComponent > ( uid ) ) ) // Starlight, Cheese, you have sent me down the path of the hell trying to get this working reliably
243200 return false ;
244201
@@ -268,27 +225,6 @@ public bool IsAntagBanned(ICommonSession session, AntagSpecifierPrototype defini
268225 return false ;
269226 }
270227
271- #region Starlight
272- /// <summary>
273- /// Returns whether a player may claim an antagonist ghost role.
274- /// This intentionally does not require the antag preference to be enabled.
275- /// </summary>
276- [ PublicAPI ]
277- public bool CanTakeAntagGhostRole ( ICommonSession session , ProtoId < AntagSpecifierPrototype > definition )
278- {
279- return Proto . Resolve ( definition , out var antag ) && CanTakeAntagGhostRole ( session , antag ) ;
280- }
281-
282- /// <summary>
283- /// Returns whether a player may claim an antagonist ghost role.
284- /// </summary>
285- [ PublicAPI ]
286- public bool CanTakeAntagGhostRole ( ICommonSession session , AntagSpecifierPrototype definition )
287- {
288- return ! IsAntagBanned ( session , definition ) && _playTime . IsAllowedNonSpawning ( session , definition . PrefRoles ) ;
289- }
290- #endregion
291-
292228 /// <inheritdoc cref="TryMakeAntag(Entity{AntagSelectionComponent},AntagSpecifierPrototype,ICommonSession,bool)"/>
293229 [ PublicAPI ]
294230 public bool TryMakeAntag ( Entity < AntagSelectionComponent > gameRule ,
@@ -338,6 +274,18 @@ public bool TryAssignNextAvailableAntag(Entity<AntagSelectionComponent> gameRule
338274 ICommonSession session ,
339275 int players )
340276 {
277+ #region Starlight
278+ return TryAssignNextAvailableAntag ( gameRule , session , players , out _ ) ;
279+ }
280+
281+ /// <summary>
282+ /// Tries to find an open antag slot for a given player and returns the definition that was assigned.
283+ /// </summary>
284+ private bool TryAssignNextAvailableAntag ( Entity < AntagSelectionComponent > gameRule , ICommonSession session , int players , [ NotNullWhen ( true ) ] out AntagSpecifierPrototype ? assignedAntag )
285+ {
286+ assignedAntag = null ;
287+ #endregion
288+
341289 foreach ( var selector in gameRule . Comp . Antags )
342290 {
343291 if ( ! Proto . Resolve ( selector . Proto , out var antag ) )
@@ -348,8 +296,13 @@ public bool TryAssignNextAvailableAntag(Entity<AntagSelectionComponent> gameRule
348296 continue ;
349297
350298 // Try and assign this antag, if we fail, then try the next definition!
351- if ( TryMakeAntag ( gameRule , antag , session ) )
352- return true ;
299+ #region Starlight
300+ if ( ! TryMakeAntag ( gameRule , antag , session ) )
301+ continue ;
302+
303+ assignedAntag = antag ;
304+ return true ;
305+ #endregion
353306 }
354307
355308 return false ;
@@ -385,8 +338,13 @@ public bool TryMakeLateJoinAntag(ICommonSession session)
385338
386339 foreach ( var ( uid , antag ) in rules )
387340 {
388- if ( TryAssignNextAvailableAntag ( ( uid , antag ) , session , players ) )
389- return true ;
341+ #region Starlight
342+ if ( ! TryAssignNextAvailableAntag ( ( uid , antag ) , session , players , out var assignedAntag ) )
343+ continue ;
344+
345+ RecordLateJoinAntagAssignment ( ( uid , antag ) , assignedAntag ) ; // logging
346+ return true ;
347+ #endregion
390348 }
391349
392350 return false ;
0 commit comments