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
This commit is contained in:
52
Content.Server/GameTicking/Rules/DragonRuleSystem.cs
Normal file
52
Content.Server/GameTicking/Rules/DragonRuleSystem.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user