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>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
@@ -57,7 +58,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
args.Roles.Add(new RoleInfo(component, name, true, null, prototype));
|
||||
});
|
||||
|
||||
SubscribeLocalEvent((EntityUid _, T _, ref MindIsAntagonistEvent args) => args.IsAntagonist = true);
|
||||
SubscribeLocalEvent((EntityUid _, T _, ref MindIsAntagonistEvent args) => { args.IsAntagonist = true; args.IsExclusiveAntagonist |= typeof(T).TryGetCustomAttribute<ExclusiveAntagonistAttribute>(out _); });
|
||||
_antagTypes.Add(typeof(T));
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
AddComp(mindId, component);
|
||||
var antagonist = IsAntagonistRole<T>();
|
||||
|
||||
var mindEv = new MindRoleAddedEvent();
|
||||
var mindEv = new MindRoleAddedEvent(silent);
|
||||
RaiseLocalEvent(mindId, ref mindEv);
|
||||
|
||||
var message = new RoleAddedEvent(mindId, mind, antagonist, silent);
|
||||
@@ -156,6 +157,21 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
return ev.IsAntagonist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does this mind possess an exclusive antagonist role
|
||||
/// </summary>
|
||||
/// <param name="mindId">The mind entity</param>
|
||||
/// <returns>True if the mind possesses an exclusive antag role</returns>
|
||||
public bool MindIsExclusiveAntagonist(EntityUid? mindId)
|
||||
{
|
||||
if (mindId == null)
|
||||
return false;
|
||||
|
||||
var ev = new MindIsAntagonistEvent();
|
||||
RaiseLocalEvent(mindId.Value, ref ev);
|
||||
return ev.IsExclusiveAntagonist;
|
||||
}
|
||||
|
||||
public bool IsAntagonistRole<T>()
|
||||
{
|
||||
return _antagTypes.Contains(typeof(T));
|
||||
|
||||
Reference in New Issue
Block a user