]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix dragon spawn location and round end summary (#31890)
authorqwerltaz <69696513+qwerltaz@users.noreply.github.com>
Mon, 9 Sep 2024 19:22:41 +0000 (21:22 +0200)
committerGitHub <noreply@github.com>
Mon, 9 Sep 2024 19:22:41 +0000 (13:22 -0600)
* spawn dragon rule at station edge

* 2

* stuff

* fix round end summary not showing

* no invalid euid

Content.Server/Dragon/Components/DragonRuleComponent.cs [deleted file]
Content.Server/GameTicking/Rules/Components/DragonRuleComponent.cs [new file with mode: 0644]
Content.Server/GameTicking/Rules/DragonRuleSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/dragon/dragon.ftl
Resources/Prototypes/GameRules/events.yml

diff --git a/Content.Server/Dragon/Components/DragonRuleComponent.cs b/Content.Server/Dragon/Components/DragonRuleComponent.cs
deleted file mode 100644 (file)
index a87232b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Content.Server.Dragon;
-
-[RegisterComponent]
-public sealed partial class DragonRuleComponent : Component
-{
-
-}
diff --git a/Content.Server/GameTicking/Rules/Components/DragonRuleComponent.cs b/Content.Server/GameTicking/Rules/Components/DragonRuleComponent.cs
new file mode 100644 (file)
index 0000000..e3fab85
--- /dev/null
@@ -0,0 +1,4 @@
+namespace Content.Server.GameTicking.Rules.Components;
+
+[RegisterComponent]
+public sealed partial class DragonRuleComponent : Component;
diff --git a/Content.Server/GameTicking/Rules/DragonRuleSystem.cs b/Content.Server/GameTicking/Rules/DragonRuleSystem.cs
new file mode 100644 (file)
index 0000000..96021e6
--- /dev/null
@@ -0,0 +1,52 @@
+using Content.Server.Antag;
+using Content.Server.GameTicking.Rules.Components;
+using Content.Server.Station.Components;
+using Content.Server.Station.Systems;
+using Content.Shared.Localizations;
+using Robust.Server.GameObjects;
+
+namespace Content.Server.GameTicking.Rules;
+
+public sealed class DragonRuleSystem : GameRuleSystem<DragonRuleComponent>
+{
+    [Dependency] private readonly TransformSystem _transform = default!;
+    [Dependency] private readonly AntagSelectionSystem _antag = default!;
+    [Dependency] private readonly StationSystem _station = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<DragonRuleComponent, AfterAntagEntitySelectedEvent>(AfterAntagEntitySelected);
+    }
+
+    private void AfterAntagEntitySelected(Entity<DragonRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
+    {
+        _antag.SendBriefing(args.EntityUid, MakeBriefing(args.EntityUid), null, null);
+    }
+
+    private string MakeBriefing(EntityUid dragon)
+    {
+        var direction = string.Empty;
+
+        var dragonXform = Transform(dragon);
+
+        var station = _station.GetStationInMap(dragonXform.MapID);
+        EntityUid? stationGrid = null;
+        if (TryComp<StationDataComponent>(station, out var stationData))
+            stationGrid = _station.GetLargestGrid(stationData);
+
+        if (stationGrid is not null)
+        {
+            var stationPosition = _transform.GetWorldPosition((EntityUid)stationGrid);
+            var dragonPosition = _transform.GetWorldPosition(dragon);
+
+            var vectorToStation = stationPosition - dragonPosition;
+            direction = ContentLocalizationManager.FormatDirection(vectorToStation.GetDir());
+        }
+
+        var briefing = Loc.GetString("dragon-role-briefing", ("direction", direction));
+
+        return briefing;
+    }
+}
index 11e8a58620300dfae92097bcb3a4014e82469436..380a24ccf8e9bb96b08c970aa9f851ad7a8fe05f 100644 (file)
@@ -2,4 +2,4 @@ dragon-round-end-agent-name = dragon
 
 objective-issuer-dragon = [color=#7567b6]Space Dragon[/color]
 
-dragon-role-briefing = Summon 3 carp rifts and take over this quadrant!
+dragon-role-briefing = Summon 3 carp rifts and take over this quadrant! The station is located {$direction}.
index 7b269406b7500ab729412becc3fef5a2d4196910..8a56cfc25744e0872b12c9d6da93f8a6d5245141 100644 (file)
     earliestStart: 40
     reoccurrenceDelay: 20
     minimumPlayers: 20
-  - type: AntagRandomSpawn
+    duration: null
+  - type: SpaceSpawnRule
+    spawnDistance: 0
   - type: AntagSpawner
     prototype: MobDragon
+  - type: DragonRule
   - type: AntagObjectives
     objectives:
     - CarpRiftsObjective
       mindComponents:
       - type: DragonRole
         prototype: Dragon
-      - type: RoleBriefing
-        briefing: dragon-role-briefing
 
 - type: entity
   parent: BaseGameRule