]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
dragon antag refactor (#28217)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Fri, 31 May 2024 15:08:26 +0000 (15:08 +0000)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 15:08:26 +0000 (11:08 -0400)
* 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>
Content.Server/Antag/AntagRandomSpawnRule.cs [new file with mode: 0644]
Content.Server/Antag/AntagSpawnerSystem.cs [new file with mode: 0644]
Content.Server/Antag/Components/AntagRandomSpawnComponent.cs [new file with mode: 0644]
Content.Server/Antag/Components/AntagSpawnerComponent.cs [new file with mode: 0644]
Content.Server/Dragon/DragonSystem.cs
Resources/Locale/en-US/prototypes/roles/antags.ftl
Resources/Prototypes/Entities/Markers/Spawners/ghost_roles.yml
Resources/Prototypes/Entities/Mobs/Player/dragon.yml
Resources/Prototypes/GameRules/events.yml
Resources/Prototypes/GameRules/midround.yml
Resources/Prototypes/Roles/Antags/dragon.yml [new file with mode: 0644]

diff --git a/Content.Server/Antag/AntagRandomSpawnRule.cs b/Content.Server/Antag/AntagRandomSpawnRule.cs
new file mode 100644 (file)
index 0000000..499761a
--- /dev/null
@@ -0,0 +1,22 @@
+using Content.Server.Antag.Components;
+using Content.Server.GameTicking.Rules;
+
+namespace Content.Server.Antag;
+
+public sealed class AntagRandomSpawnSystem : GameRuleSystem<AntagRandomSpawnComponent>
+{
+    [Dependency] private readonly SharedTransformSystem _transform = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<AntagRandomSpawnComponent, AntagSelectLocationEvent>(OnSelectLocation);
+    }
+
+    private void OnSelectLocation(Entity<AntagRandomSpawnComponent> 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 (file)
index 0000000..f8a0367
--- /dev/null
@@ -0,0 +1,21 @@
+using Content.Server.Antag.Components;
+
+namespace Content.Server.Antag;
+
+/// <summary>
+/// Spawns an entity when creating an antag for <see cref="AntagSpawnerComponent"/>.
+/// </summary>
+public sealed class AntagSpawnerSystem : EntitySystem
+{
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<AntagSpawnerComponent, AntagSelectEntityEvent>(OnSelectEntity);
+    }
+
+    private void OnSelectEntity(Entity<AntagSpawnerComponent> 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 (file)
index 0000000..16edd25
--- /dev/null
@@ -0,0 +1,8 @@
+namespace Content.Server.Antag.Components;
+
+/// <summary>
+/// Spawns this rule's antags at random tiles on a station using <c>TryGetRandomTile</c>.
+/// Requires <see cref="AntagSelectionComponent"/>.
+/// </summary>
+[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 (file)
index 0000000..7153bab
--- /dev/null
@@ -0,0 +1,17 @@
+using Content.Server.Antag;
+using Robust.Shared.Prototypes;
+
+namespace Content.Server.Antag.Components;
+
+/// <summary>
+/// Spawns a prototype for antags created with a spawner.
+/// </summary>
+[RegisterComponent, Access(typeof(AntagSpawnerSystem))]
+public sealed partial class AntagSpawnerComponent : Component
+{
+    /// <summary>
+    /// The entity to spawn.
+    /// </summary>
+    [DataField(required: true)]
+    public EntProtoId Prototype = string.Empty;
+}
index 1e29b80ebafb3fdb08b3022596e0c20af4147b95..62d1f61a35b4690d558b369c933c0fd53f0db598 100644 (file)
@@ -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<DragonComponent, DragonSpawnRiftActionEvent>(OnSpawnRift);
         SubscribeLocalEvent<DragonComponent, RefreshMovementSpeedModifiersEvent>(OnDragonMove);
         SubscribeLocalEvent<DragonComponent, MobStateChangedEvent>(OnMobStateChanged);
-        SubscribeLocalEvent<DragonComponent, GenericAntagCreatedEvent>(OnCreated);
         SubscribeLocalEvent<DragonComponent, EntityZombifiedEvent>(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<DragonComponent> ent, ref EntityZombifiedEvent args)
     {
         // prevent carp attacking zombie dragon
index 5c514dba8eccd9d3dbf6637f1d7830ce97b1ebf0..f0038b0eb96d5e6aa2ff601834f771cd67d09f26 100644 (file)
@@ -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.
index 7942d26f3212b68ea4a11c1f0b78bb8071202dcd..b21792579f455bd51571c1cad90c89c8dac25593 100644 (file)
@@ -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
 
 - 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:
     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
index cb9dc1c911a28c79a1d602ee4ea29495b8b7b4e7..258488af9b462a6c226b91734e575afd8d7ac713 100644 (file)
 - 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
index b1b48258bade2d0bd955911367297076c3ed0f40..9dabc14a344e70fcad604f2448dd1fce7d5c3aa8 100644 (file)
   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
index 1b58ada64855dcf73f16dd5b9c42679ee4bd93b5..fe5af117e68b08fd2b571df6b05dfdc925db38e0 100644 (file)
   - 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 (file)
index 0000000..6630b81
--- /dev/null
@@ -0,0 +1,5 @@
+- type: antag
+  id: Dragon
+  name: roles-antag-dragon-name
+  antagonist: true
+  objective: roles-antag-dragon-objective