From 489efeb7171040305861c8af136788ea3940a086 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Thu, 8 Aug 2024 08:16:02 +0000 Subject: [PATCH] remove GenericAntag completely (#28218) Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: metalgearsloth --- .../Components/GenericAntagRuleComponent.cs | 30 --------- .../Rules/GenericAntagRuleSystem.cs | 56 ---------------- .../GenericAntag/GenericAntagComponent.cs | 30 --------- .../GenericAntag/GenericAntagSystem.cs | 67 ------------------- 4 files changed, 183 deletions(-) delete mode 100644 Content.Server/GameTicking/Rules/Components/GenericAntagRuleComponent.cs delete mode 100644 Content.Server/GameTicking/Rules/GenericAntagRuleSystem.cs delete mode 100644 Content.Server/GenericAntag/GenericAntagComponent.cs delete mode 100644 Content.Server/GenericAntag/GenericAntagSystem.cs diff --git a/Content.Server/GameTicking/Rules/Components/GenericAntagRuleComponent.cs b/Content.Server/GameTicking/Rules/Components/GenericAntagRuleComponent.cs deleted file mode 100644 index 8d212ebaa3..0000000000 --- a/Content.Server/GameTicking/Rules/Components/GenericAntagRuleComponent.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Content.Server.GameTicking.Rules; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; - -namespace Content.Server.GameTicking.Rules.Components; - -/// -/// Gamerule for simple antagonists that have fixed objectives. -/// -[RegisterComponent, Access(typeof(GenericAntagRuleSystem))] -public sealed partial class GenericAntagRuleComponent : Component -{ - /// - /// All antag minds that are using this rule. - /// - [DataField] - public List Minds = new(); - - /// - /// Locale id for the name of the antag used by the roundend summary. - /// - [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] - public string AgentName = string.Empty; - - /// - /// List of objective entity prototypes to add to the antag when a mind is added. - /// - [DataField(required: true)] - public List Objectives = new(); -} diff --git a/Content.Server/GameTicking/Rules/GenericAntagRuleSystem.cs b/Content.Server/GameTicking/Rules/GenericAntagRuleSystem.cs deleted file mode 100644 index 0367aa1460..0000000000 --- a/Content.Server/GameTicking/Rules/GenericAntagRuleSystem.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Content.Server.GameTicking.Rules.Components; -using Content.Server.Objectives; -using Content.Shared.Mind; -using System.Diagnostics.CodeAnalysis; -using System.Linq; - -namespace Content.Server.GameTicking.Rules; - -/// -/// Handles round end text for simple antags. -/// Adding objectives is handled in its own system. -/// -public sealed class GenericAntagRuleSystem : GameRuleSystem -{ - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnObjectivesTextGetInfo); - } - - /// - /// Start a simple antag's game rule. - /// If it is invalid the rule is deleted and null is returned. - /// - public bool StartRule(string rule, EntityUid mindId, [NotNullWhen(true)] out EntityUid? ruleId, [NotNullWhen(true)] out GenericAntagRuleComponent? comp) - { - ruleId = GameTicker.AddGameRule(rule); - if (!TryComp(ruleId, out comp)) - { - Log.Error($"Simple antag rule prototype {rule} is invalid, deleting it."); - Del(ruleId); - ruleId = null; - return false; - } - - if (!GameTicker.StartGameRule(ruleId.Value)) - { - Log.Error($"Simple antag rule prototype {rule} failed to start, deleting it."); - Del(ruleId); - ruleId = null; - comp = null; - return false; - } - - comp.Minds.Add(mindId); - return true; - } - - private void OnObjectivesTextGetInfo(EntityUid uid, GenericAntagRuleComponent comp, ref ObjectivesTextGetInfoEvent args) - { - // just temporary until this is deleted - args.Minds = comp.Minds.Select(mindId => (mindId, Comp(mindId).CharacterName ?? "?")).ToList(); - args.AgentName = Loc.GetString(comp.AgentName); - } -} diff --git a/Content.Server/GenericAntag/GenericAntagComponent.cs b/Content.Server/GenericAntag/GenericAntagComponent.cs deleted file mode 100644 index b8ed9cf6ef..0000000000 --- a/Content.Server/GenericAntag/GenericAntagComponent.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Content.Server.GameTicking.Rules.Components; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; - -namespace Content.Server.GenericAntag; - -/// -/// Added to a mob to make it a generic antagonist where all its objectives are fixed. -/// This is unlike say traitor where it gets objectives picked randomly using difficulty. -/// -/// -/// A GenericAntag is not necessarily an antagonist, that depends on the roles you do or do not add after. -/// -[RegisterComponent, Access(typeof(GenericAntagSystem))] -public sealed partial class GenericAntagComponent : Component -{ - /// - /// Gamerule to start when a mind is added. - /// This must have or it will not work. - /// - [DataField(required: true), ViewVariables(VVAccess.ReadWrite)] - public EntProtoId Rule = string.Empty; - - /// - /// The rule that's been spawned. - /// Used to prevent spawning multiple rules. - /// - [DataField, ViewVariables(VVAccess.ReadWrite)] - public EntityUid? RuleEntity; -} diff --git a/Content.Server/GenericAntag/GenericAntagSystem.cs b/Content.Server/GenericAntag/GenericAntagSystem.cs deleted file mode 100644 index 6b1774159c..0000000000 --- a/Content.Server/GenericAntag/GenericAntagSystem.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Content.Server.GameTicking.Rules; -using Content.Shared.Mind; -using Content.Shared.Mind.Components; - -namespace Content.Server.GenericAntag; - -/// -/// Handles adding objectives to s. -/// Roundend summary is handled by . -/// -public sealed class GenericAntagSystem : EntitySystem -{ - [Dependency] private readonly SharedMindSystem _mind = default!; - [Dependency] private readonly GenericAntagRuleSystem _genericAntagRule = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnMindAdded); - } - - private void OnMindAdded(EntityUid uid, GenericAntagComponent comp, MindAddedMessage args) - { - if (!TryComp(uid, out var mindContainer) || mindContainer.Mind == null) - return; - - var mindId = mindContainer.Mind.Value; - MakeAntag(uid, mindId, comp); - } - - /// - /// Turns a player into this antagonist. - /// Does the same thing that having a mind added does, use for antag ctrl. - /// - public void MakeAntag(EntityUid uid, EntityUid mindId, GenericAntagComponent? comp = null, MindComponent? mind = null) - { - if (!Resolve(uid, ref comp) || !Resolve(mindId, ref mind)) - return; - - // only add the rule once - if (comp.RuleEntity != null) - return; - - // start the rule - if (!_genericAntagRule.StartRule(comp.Rule, mindId, out comp.RuleEntity, out var rule)) - return; - - // let other systems know the antag was created so they can add briefing, roles, etc. - // its important that this is before objectives are added since they may depend on roles added here - var ev = new GenericAntagCreatedEvent(mindId, mind); - RaiseLocalEvent(uid, ref ev); - - // add the objectives from the rule - foreach (var id in rule.Objectives) - { - _mind.TryAddObjective(mindId, mind, id); - } - } -} - -/// -/// Event raised on a player's entity after its simple antag rule is started. -/// Use this to add a briefing, roles, etc. -/// -[ByRefEvent] -public record struct GenericAntagCreatedEvent(EntityUid MindId, MindComponent Mind); -- 2.52.0