Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beacons #1193

Closed
wants to merge 11 commits into from
3 changes: 1 addition & 2 deletions Content.Server/Dragon/DragonRiftSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ public override void Update(float frameTime)
comp.State = DragonRiftState.AlmostFinished;
Dirty(comp);

var location = xform.LocalPosition;
_announcer.SendAnnouncement(_announcer.GetAnnouncementId("CarpRift"), Filter.Broadcast(),
"carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", location));
"carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, xform)))));
_navMap.SetBeaconEnabled(uid, true);
}

Expand Down
7 changes: 1 addition & 6 deletions Content.Server/Nuke/NukeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,6 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null)
if (stationUid != null)
_alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true);

var pos = nukeXform.MapPosition;
var x = (int) pos.X;
var y = (int) pos.Y;
var posText = $"({x}, {y})";

// We are collapsing the randomness here, otherwise we would get separate random song picks for checking duration and when actually playing the song afterwards
_selectedNukeSong = _audio.GetSound(component.ArmMusic);

Expand All @@ -467,7 +462,7 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null)
Color.Red,
stationUid ?? uid,
null,
("time", (int) component.RemainingTime), ("position", posText)
("time", (int) component.RemainingTime), ("position", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, nukeXform))))
);

_sound.PlayGlobalOnStation(uid, _audio.GetSound(component.ArmSound));
Expand Down
44 changes: 29 additions & 15 deletions Content.Server/Pinpointer/NavMapSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
Expand All @@ -7,8 +8,12 @@
using Content.Shared.Examine;
using Content.Shared.Localizations;
using Content.Shared.Maps;
using Content.Shared.Localizations;
using Content.Shared.Pinpointer;
using Content.Shared.Tag;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Timing;
Expand All @@ -23,19 +28,17 @@
{
[Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly TagSystem _tags = default!;
[Dependency] private readonly MapSystem _map = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
[Dependency] private readonly TransformSystem _transform = default!;

private EntityQuery<PhysicsComponent> _physicsQuery;

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in Content.Server/Pinpointer/NavMapSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'PhysicsComponent' could not be found (are you missing a using directive or an assembly reference?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your missing a using, Robust.Shared.Physics.Components;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer relevant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"no longer relevant" look at your checks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, somehow relevant? I moved back to the commit with EE's stuff

private EntityQuery<TagComponent> _tagQuery;

public const float CloseDistance = 15f;
public const float FarDistance = 30f;

private EntityQuery<AirtightComponent> _airtightQuery;
private EntityQuery<MapGridComponent> _gridQuery;
private EntityQuery<NavMapComponent> _navQuery;

public override void Initialize()
{
base.Initialize();
Expand All @@ -57,8 +60,8 @@

SubscribeLocalEvent<AirtightChanged>(OnAirtightChange);

// Beacon events
SubscribeLocalEvent<NavMapBeaconComponent, MapInitEvent>(OnNavMapBeaconMapInit);
SubscribeLocalEvent<NavMapBeaconComponent, ComponentStartup>(OnNavMapBeaconStartup);
SubscribeLocalEvent<NavMapBeaconComponent, AnchorStateChangedEvent>(OnNavMapBeaconAnchor);
SubscribeLocalEvent<ConfigurableNavMapBeaconComponent, NavMapBeaconConfigureBuiMessage>(OnConfigureMessage);
SubscribeLocalEvent<ConfigurableNavMapBeaconComponent, MapInitEvent>(OnConfigurableMapInit);
Expand Down Expand Up @@ -87,6 +90,17 @@
RefreshGrid(comp, _gridQuery.GetComponent(args.Grid));
}

private void OnNavMapBeaconStartup(EntityUid uid, NavMapBeaconComponent component, ComponentStartup args)
{
if (component.DefaultText == null || component.Text != null)
return;

component.Text = Loc.GetString(component.DefaultText);
Dirty(uid, component);

UpdateNavMapBeaconData(uid, component);
}

private NavMapChunk EnsureChunk(NavMapComponent component, Vector2i origin)
{
if (!component.Chunks.TryGetValue(origin, out var chunk))
Expand Down Expand Up @@ -377,7 +391,7 @@
if (!Resolve(ent, ref ent.Comp))
return false;

return TryGetNearestBeacon(_transformSystem.GetMapCoordinates(ent, ent.Comp), out beacon, out beaconCoords);
return TryGetNearestBeacon(_transform.GetMapCoordinates(ent, ent.Comp), out beacon, out beaconCoords);
}

/// <summary>
Expand All @@ -404,7 +418,7 @@
if (coordinates.MapId != xform.MapID)
continue;

var coords = _transformSystem.GetWorldPosition(xform);
var coords = _transform.GetWorldPosition(xform);
var distanceSquared = (coordinates.Position - coords).LengthSquared();
if (!float.IsInfinity(minDistance) && distanceSquared >= minDistance)
continue;
Expand All @@ -423,7 +437,7 @@
if (!Resolve(ent, ref ent.Comp))
return Loc.GetString("nav-beacon-pos-no-beacons");

return GetNearestBeaconString(_transformSystem.GetMapCoordinates(ent, ent.Comp));
return GetNearestBeaconString(_transform.GetMapCoordinates(ent, ent.Comp));
}

public string GetNearestBeaconString(MapCoordinates coordinates)
Expand Down Expand Up @@ -452,13 +466,13 @@
? Loc.GetString("nav-beacon-pos-format-direction-mod-far")
: string.Empty;

// we can null suppress the text being null because TryGetNearestVisibleStationBeacon always gives us a beacon with not-null text.
// we can null suppress the text being null because TRyGetNearestVisibleStationBeacon always gives us a beacon with not-null text.
return Loc.GetString("nav-beacon-pos-format-direction",
("modifier", modifier),
("direction", ContentLocalizationManager.FormatDirection(adjustedDir).ToLowerInvariant()),
("color", beacon.Value.Comp.Color),
("marker", beacon.Value.Comp.Text!));
}

#endregion
sleepyyapril marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
7 changes: 1 addition & 6 deletions Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,7 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo
else
{
var location = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform)));
_announcer.SendAnnouncementMessage(
_announcer.GetAnnouncementId("ShuttleNearby"),
"emergency-shuttle-nearby",
null, null, null, null,
("direction", location)
);
_chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("direction", location)), playDefaultSound: false);

_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} unable to find a valid docking port for {ToPrettyString(stationUid)}");
_announcer.SendAnnouncementAudio(_announcer.GetAnnouncementId("ShuttleNearby"), Filter.Broadcast());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,4 @@
suffix: Escape Pod
components:
- type: NavMapBeacon
defaultText: station-beacon-escape-pod
defaultText: station-beacon-escape-pod
Loading