From 7c99b5c10b1eb34afe6524b827b51203e7c2a31b Mon Sep 17 00:00:00 2001 From: qwerltaz <69696513+qwerltaz@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:22:41 +0200 Subject: [PATCH] fix dragon spawn location and round end summary (#31890) * spawn dragon rule at station edge * 2 * stuff * fix round end summary not showing * no invalid euid --- .../Dragon/Components/DragonRuleComponent.cs | 7 --- .../Rules/Components/DragonRuleComponent.cs | 4 ++ .../GameTicking/Rules/DragonRuleSystem.cs | 52 +++++++++++++++++++ Resources/Locale/en-US/dragon/dragon.ftl | 2 +- Resources/Prototypes/GameRules/events.yml | 7 +-- 5 files changed, 61 insertions(+), 11 deletions(-) delete mode 100644 Content.Server/Dragon/Components/DragonRuleComponent.cs create mode 100644 Content.Server/GameTicking/Rules/Components/DragonRuleComponent.cs create mode 100644 Content.Server/GameTicking/Rules/DragonRuleSystem.cs diff --git a/Content.Server/Dragon/Components/DragonRuleComponent.cs b/Content.Server/Dragon/Components/DragonRuleComponent.cs deleted file mode 100644 index a87232bebc..0000000000 --- a/Content.Server/Dragon/Components/DragonRuleComponent.cs +++ /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 index 0000000000..e3fab85f2d --- /dev/null +++ b/Content.Server/GameTicking/Rules/Components/DragonRuleComponent.cs @@ -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 index 0000000000..96021e6123 --- /dev/null +++ b/Content.Server/GameTicking/Rules/DragonRuleSystem.cs @@ -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 +{ + [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(AfterAntagEntitySelected); + } + + private void AfterAntagEntitySelected(Entity 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(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; + } +} diff --git a/Resources/Locale/en-US/dragon/dragon.ftl b/Resources/Locale/en-US/dragon/dragon.ftl index 11e8a58620..380a24ccf8 100644 --- a/Resources/Locale/en-US/dragon/dragon.ftl +++ b/Resources/Locale/en-US/dragon/dragon.ftl @@ -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}. diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index 7b269406b7..8a56cfc257 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -157,9 +157,12 @@ earliestStart: 40 reoccurrenceDelay: 20 minimumPlayers: 20 - - type: AntagRandomSpawn + duration: null + - type: SpaceSpawnRule + spawnDistance: 0 - type: AntagSpawner prototype: MobDragon + - type: DragonRule - type: AntagObjectives objectives: - CarpRiftsObjective @@ -174,8 +177,6 @@ mindComponents: - type: DragonRole prototype: Dragon - - type: RoleBriefing - briefing: dragon-role-briefing - type: entity parent: BaseGameRule