From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Fri, 31 May 2024 15:08:26 +0000 (+0000) Subject: dragon antag refactor (#28217) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=5da2151924f372bf8c88ddda191886a0da62e0f1;p=space-station-14.git dragon antag refactor (#28217) * remove dragon system usage of GenericAntag * add AntagRandomSpawn for making antags spawn at a random tile * add AntagSpawner to make an antag spawner just spawn an entity * add antag prototype for dragon since it never had one * make dragon spawner a GhostRoleAntagSpawner, remove GenericAntag * make dragon rule use AntagSelection and stuff * remove dragon GenericAntag rule * add back to spawn menu --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- diff --git a/Content.Server/Antag/AntagRandomSpawnRule.cs b/Content.Server/Antag/AntagRandomSpawnRule.cs new file mode 100644 index 0000000000..499761a8df --- /dev/null +++ b/Content.Server/Antag/AntagRandomSpawnRule.cs @@ -0,0 +1,22 @@ +using Content.Server.Antag.Components; +using Content.Server.GameTicking.Rules; + +namespace Content.Server.Antag; + +public sealed class AntagRandomSpawnSystem : GameRuleSystem +{ + [Dependency] private readonly SharedTransformSystem _transform = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnSelectLocation); + } + + private void OnSelectLocation(Entity ent, ref AntagSelectLocationEvent args) + { + if (TryFindRandomTile(out _, out _, out _, out var coords)) + args.Coordinates.Add(_transform.ToMapCoordinates(coords)); + } +} diff --git a/Content.Server/Antag/AntagSpawnerSystem.cs b/Content.Server/Antag/AntagSpawnerSystem.cs new file mode 100644 index 0000000000..f8a036749a --- /dev/null +++ b/Content.Server/Antag/AntagSpawnerSystem.cs @@ -0,0 +1,21 @@ +using Content.Server.Antag.Components; + +namespace Content.Server.Antag; + +/// +/// Spawns an entity when creating an antag for . +/// +public sealed class AntagSpawnerSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnSelectEntity); + } + + private void OnSelectEntity(Entity ent, ref AntagSelectEntityEvent args) + { + args.Entity = Spawn(ent.Comp.Prototype); + } +} diff --git a/Content.Server/Antag/Components/AntagRandomSpawnComponent.cs b/Content.Server/Antag/Components/AntagRandomSpawnComponent.cs new file mode 100644 index 0000000000..16edd256a2 --- /dev/null +++ b/Content.Server/Antag/Components/AntagRandomSpawnComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server.Antag.Components; + +/// +/// Spawns this rule's antags at random tiles on a station using TryGetRandomTile. +/// Requires . +/// +[RegisterComponent] +public sealed partial class AntagRandomSpawnComponent : Component; diff --git a/Content.Server/Antag/Components/AntagSpawnerComponent.cs b/Content.Server/Antag/Components/AntagSpawnerComponent.cs new file mode 100644 index 0000000000..7153babc76 --- /dev/null +++ b/Content.Server/Antag/Components/AntagSpawnerComponent.cs @@ -0,0 +1,17 @@ +using Content.Server.Antag; +using Robust.Shared.Prototypes; + +namespace Content.Server.Antag.Components; + +/// +/// Spawns a prototype for antags created with a spawner. +/// +[RegisterComponent, Access(typeof(AntagSpawnerSystem))] +public sealed partial class AntagSpawnerComponent : Component +{ + /// + /// The entity to spawn. + /// + [DataField(required: true)] + public EntProtoId Prototype = string.Empty; +} diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 1e29b80eba..62d1f61a35 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -1,4 +1,3 @@ -using Content.Server.GenericAntag; using Content.Server.Objectives.Components; using Content.Server.Objectives.Systems; using Content.Server.Popups; @@ -55,7 +54,6 @@ public sealed partial class DragonSystem : EntitySystem SubscribeLocalEvent(OnSpawnRift); SubscribeLocalEvent(OnDragonMove); SubscribeLocalEvent(OnMobStateChanged); - SubscribeLocalEvent(OnCreated); SubscribeLocalEvent(OnZombified); } @@ -192,18 +190,6 @@ public sealed partial class DragonSystem : EntitySystem DeleteRifts(uid, false, component); } - private void OnCreated(EntityUid uid, DragonComponent comp, ref GenericAntagCreatedEvent args) - { - var mindId = args.MindId; - var mind = args.Mind; - - _role.MindAddRole(mindId, new DragonRoleComponent(), mind); - _role.MindAddRole(mindId, new RoleBriefingComponent() - { - Briefing = Loc.GetString("dragon-role-briefing") - }, mind); - } - private void OnZombified(Entity ent, ref EntityZombifiedEvent args) { // prevent carp attacking zombie dragon diff --git a/Resources/Locale/en-US/prototypes/roles/antags.ftl b/Resources/Locale/en-US/prototypes/roles/antags.ftl index 5c514dba8e..f0038b0eb9 100644 --- a/Resources/Locale/en-US/prototypes/roles/antags.ftl +++ b/Resources/Locale/en-US/prototypes/roles/antags.ftl @@ -30,3 +30,6 @@ roles-antag-space-ninja-objective = Use your stealth to sabotage the station, no roles-antag-thief-name = Thief roles-antag-thief-objective = Add some NT property to your personal collection without using violence. + +roles-antag-dragon-name = Space Dragon +roles-antag-dragon-objective = Create a carp army to take over this quadrant. diff --git a/Resources/Prototypes/Entities/Markers/Spawners/ghost_roles.yml b/Resources/Prototypes/Entities/Markers/Spawners/ghost_roles.yml index 7942d26f32..b21792579f 100644 --- a/Resources/Prototypes/Entities/Markers/Spawners/ghost_roles.yml +++ b/Resources/Prototypes/Entities/Markers/Spawners/ghost_roles.yml @@ -1,3 +1,14 @@ +- type: entity + abstract: true + parent: MarkerBase + id: BaseAntagSpawner + name: ghost role spawn point + components: + - type: GhostRole + raffle: + settings: default + - type: GhostRoleAntagSpawner + - type: entity id: SpawnPointGhostRatKing name: ghost role spawn point @@ -83,18 +94,13 @@ - type: entity noSpawn: true + parent: BaseAntagSpawner id: SpawnPointLoneNukeOperative - name: ghost role spawn point - suffix: loneops - parent: MarkerBase components: - type: GhostRole name: ghost-role-information-loneop-name description: ghost-role-information-loneop-description rules: ghost-role-information-loneop-rules - raffle: - settings: default - - type: GhostRoleAntagSpawner - type: Sprite sprite: Markers/jobs.rsi layers: @@ -130,20 +136,14 @@ description: roles-antag-nuclear-operative-objective - type: entity - parent: MarkerBase - id: SpawnPointGhostDragon noSpawn: true - name: ghost role spawn point - suffix: dragon + parent: BaseAntagSpawner + id: SpawnPointGhostDragon components: - type: GhostRole name: ghost-role-information-space-dragon-name description: ghost-role-information-space-dragon-description rules: ghost-role-component-default-rules - raffle: - settings: default - - type: GhostRoleMobSpawner - prototype: MobDragon - type: Sprite layers: - state: green diff --git a/Resources/Prototypes/Entities/Mobs/Player/dragon.yml b/Resources/Prototypes/Entities/Mobs/Player/dragon.yml index cb9dc1c911..258488af9b 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/dragon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/dragon.yml @@ -142,11 +142,10 @@ - type: entity parent: BaseMobDragon id: MobDragon + suffix: No role or objectives components: - type: Dragon spawnRiftAction: ActionSpawnRift - - type: GenericAntag - rule: Dragon - type: ActionGun action: ActionDragonsBreath gunProto: DragonsBreathGun diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index b1b48258ba..9dabc14a34 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -86,12 +86,28 @@ components: - type: StationEvent weight: 6.5 - duration: 1 earliestStart: 40 reoccurrenceDelay: 20 minimumPlayers: 20 - - type: RandomSpawnRule - prototype: SpawnPointGhostDragon + - type: AntagRandomSpawn + - type: AntagSpawner + prototype: MobDragon + - type: AntagObjectives + objectives: + - CarpRiftsObjective + - DragonSurviveObjective + - type: AntagSelection + agentName: dragon-round-end-agent-name + definitions: + - spawnerPrototype: SpawnPointGhostDragon + min: 1 + max: 1 + pickPlayer: false + mindComponents: + - type: DragonRole + prototype: Dragon + - type: RoleBriefing + briefing: dragon-role-briefing - type: entity parent: BaseGameRule diff --git a/Resources/Prototypes/GameRules/midround.yml b/Resources/Prototypes/GameRules/midround.yml index 1b58ada648..fe5af117e6 100644 --- a/Resources/Prototypes/GameRules/midround.yml +++ b/Resources/Prototypes/GameRules/midround.yml @@ -17,18 +17,6 @@ - type: NinjaRule threats: NinjaThreats -# stores configuration for dragon -- type: entity - noSpawn: true - parent: BaseGameRule - id: Dragon - components: - - type: GenericAntagRule - agentName: dragon-round-end-agent-name - objectives: - - CarpRiftsObjective - - DragonSurviveObjective - - type: entity noSpawn: true parent: BaseGameRule diff --git a/Resources/Prototypes/Roles/Antags/dragon.yml b/Resources/Prototypes/Roles/Antags/dragon.yml new file mode 100644 index 0000000000..6630b812e3 --- /dev/null +++ b/Resources/Prototypes/Roles/Antags/dragon.yml @@ -0,0 +1,5 @@ +- type: antag + id: Dragon + name: roles-antag-dragon-name + antagonist: true + objective: roles-antag-dragon-objective