diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs index fcecbad465a..c5c4c33446e 100644 --- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs +++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs @@ -1,6 +1,7 @@ using Content.Client.Pinpointer.UI; using Robust.Client.Graphics; using Robust.Client.UserInterface.Controls; +using Robust.Shared.GameObjects; // Frontier modification namespace Content.Client.Medical.CrewMonitoring; @@ -63,7 +64,9 @@ protected override void Draw(DrawingHandleScreen handle) if (!LocalizedNames.TryGetValue(netEntity, out var name)) name = "Unknown"; - var message = name + "\nLocation: [x = " + MathF.Round(blip.Coordinates.X) + ", y = " + MathF.Round(blip.Coordinates.Y) + "]"; + // Text location of the blip will display GPS coordinates for the purpose of being able to find a person via GPS + // Previously it displayed coordinates relative to the center of the station, which had no use. + var message = name + "\nLocation: [x = " + MathF.Round(blip.MapCoordinates.X) + ", y = " + MathF.Round(blip.MapCoordinates.Y) + "]"; // Frontier modification _trackedEntityLabel.Text = message; _trackedEntityPanel.Visible = true; diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs index 645243b0a3a..57190f6d99e 100644 --- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs +++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs @@ -27,6 +27,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow private readonly IEntityManager _entManager; private readonly IPrototypeManager _prototypeManager; private readonly SpriteSystem _spriteSystem; + private readonly SharedTransformSystem _transformSystem; // Frontier modification private NetEntity? _trackedEntity; private bool _tryToScrollToListFocus; @@ -39,6 +40,7 @@ public CrewMonitoringWindow(string stationName, EntityUid? mapUid) _entManager = IoCManager.Resolve(); _prototypeManager = IoCManager.Resolve(); _spriteSystem = _entManager.System(); + _transformSystem = _entManager.System(); // Frontier modification _blipTexture = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png"))); @@ -149,7 +151,7 @@ public void ShowSensors(List sensors, EntityUid monitor, Entit // Show monitor on nav map if (monitorCoords != null && _blipTexture != null) { - NavMap.TrackedEntities[_entManager.GetNetEntity(monitor)] = new NavMapBlip(monitorCoords.Value, _blipTexture, Color.Cyan, true, false); + NavMap.TrackedEntities[_entManager.GetNetEntity(monitor)] = new NavMapBlip(monitorCoords.Value, monitorCoords.Value.ToMap(_entManager, _transformSystem), _blipTexture, Color.Cyan, true, false); // Frontier modification } } @@ -273,10 +275,13 @@ private void PopulateDepartmentList(IEnumerable departmentSens jobContainer.AddChild(jobIcon); } - // Job name + // Job name area + // Frontier modification + // Made in its name appear location name as its much more convenient + // While job icons should do good enough job of conveying job var jobLabel = new Label() { - Text = sensor.Job, + Text = sensor.LocationName, HorizontalExpand = true, ClipText = true, }; @@ -289,6 +294,7 @@ private void PopulateDepartmentList(IEnumerable departmentSens NavMap.TrackedEntities.TryAdd(sensor.SuitSensorUid, new NavMapBlip (coordinates.Value, + coordinates.Value.ToMap(_entManager, _transformSystem), // Frontier modification _blipTexture, (_trackedEntity == null || sensor.SuitSensorUid == _trackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray, sensor.SuitSensorUid == _trackedEntity)); @@ -355,6 +361,7 @@ private void UpdateSensorsTable(NetEntity? currTrackedEntity, NetEntity? prevTra { data = new NavMapBlip (data.Coordinates, + data.Coordinates.ToMap(_entManager, _transformSystem), // Frontier modification data.Texture, (currTrackedEntity == null || castSensor.SuitSensorUid == currTrackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray, castSensor.SuitSensorUid == currTrackedEntity); diff --git a/Content.Client/Pinpointer/UI/NavMapControl.cs b/Content.Client/Pinpointer/UI/NavMapControl.cs index 3b426e73d89..28e6a05b09d 100644 --- a/Content.Client/Pinpointer/UI/NavMapControl.cs +++ b/Content.Client/Pinpointer/UI/NavMapControl.cs @@ -642,14 +642,16 @@ protected Vector2 GetOffset() public struct NavMapBlip { public EntityCoordinates Coordinates; + public MapCoordinates MapCoordinates; //Frontier modification public Texture Texture; public Color Color; public bool Blinks; public bool Selectable; - public NavMapBlip(EntityCoordinates coordinates, Texture texture, Color color, bool blinks, bool selectable = true) + public NavMapBlip(EntityCoordinates coordinates, MapCoordinates mapCoordinates, Texture texture, Color color, bool blinks, bool selectable = true) //Frontier modification { Coordinates = coordinates; + MapCoordinates = mapCoordinates; // Frontier modification Texture = texture; Color = color; Blinks = blinks; diff --git a/Content.Client/Power/PowerMonitoringWindow.xaml.cs b/Content.Client/Power/PowerMonitoringWindow.xaml.cs index edc0eaa18a8..eeea8b2aef8 100644 --- a/Content.Client/Power/PowerMonitoringWindow.xaml.cs +++ b/Content.Client/Power/PowerMonitoringWindow.xaml.cs @@ -18,6 +18,7 @@ public sealed partial class PowerMonitoringWindow : FancyWindow private readonly IEntityManager _entManager; private readonly SpriteSystem _spriteSystem; private readonly IGameTiming _gameTiming; + private readonly SharedTransformSystem _transformSystem; // Frontier modification private const float BlinkFrequency = 1f; @@ -39,6 +40,7 @@ public PowerMonitoringWindow(PowerMonitoringConsoleBoundUserInterface userInterf RobustXamlLoader.Load(this); _entManager = IoCManager.Resolve(); _gameTiming = IoCManager.Resolve(); + _transformSystem = _entManager.System(); // Frontier modification _spriteSystem = _entManager.System(); _owner = owner; @@ -166,7 +168,7 @@ public void ShowEntites if (monitorCoords != null && mon != null) { var texture = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png"))); - var blip = new NavMapBlip(monitorCoords.Value, texture, Color.Cyan, true, false); + var blip = new NavMapBlip(monitorCoords.Value, monitorCoords.Value.ToMap(_entManager, _transformSystem), texture, Color.Cyan, true, false); // Frontier modification NavMap.TrackedEntities[mon.Value] = blip; } @@ -233,7 +235,7 @@ private void AddTrackedEntityToNavMap(NetEntity netEntity, PowerMonitoringDevice if (_focusEntity != null && usedEntity != _focusEntity && !entitiesOfInterest.Contains(usedEntity.Value)) modulator = Color.DimGray; - var blip = new NavMapBlip(coords, _spriteSystem.Frame0(texture), color * modulator, blink); + var blip = new NavMapBlip(coords, coords.ToMap(_entManager, _transformSystem), _spriteSystem.Frame0(texture), color * modulator, blink); //Frontier modification NavMap.TrackedEntities[netEntity] = blip; } diff --git a/Content.Server/Medical/CrewMonitoring/CrewMonitoringServerSystem.cs b/Content.Server/Medical/CrewMonitoring/CrewMonitoringServerSystem.cs index bff7f1565a1..887165330f7 100644 --- a/Content.Server/Medical/CrewMonitoring/CrewMonitoringServerSystem.cs +++ b/Content.Server/Medical/CrewMonitoring/CrewMonitoringServerSystem.cs @@ -3,7 +3,8 @@ using Content.Server.DeviceNetwork.Systems; using Content.Server.Medical.SuitSensors; using Content.Server.Power.Components; -using Content.Server.Station.Systems; +//using Content.Server.Station.Systems; +using Robust.Shared.Map; // Frontier modification using Content.Shared.DeviceNetwork; using Content.Shared.Medical.SuitSensor; using Robust.Shared.Timing; @@ -15,7 +16,7 @@ public sealed class CrewMonitoringServerSystem : EntitySystem [Dependency] private readonly SuitSensorSystem _sensors = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!; - [Dependency] private readonly StationSystem _stationSystem = default!; + //[Dependency] private readonly StationSystem _stationSystem = default!; // Frontier modification private const float UpdateRate = 3f; private float _updateDiff; @@ -66,16 +67,18 @@ public override void Update(float frameTime) } /// - /// Returns the address of the currently active server for the given station id if there is one + /// Returns the address of the currently active server for the given map (instead of station id) if there is one /// - public bool TryGetActiveServerAddress(EntityUid stationId, out string? address) + //public bool TryGetActiveServerAddress(EntityUid stationId, out string? address) // Frontier modification + public bool TryGetActiveServerAddress(MapId map, out string? address) // Frontier modification { - var servers = EntityQueryEnumerator(); + var servers = EntityQueryEnumerator(); // Frontier modification (EntityUid id, CrewMonitoringServerComponent server, DeviceNetworkComponent device)? last = default; - while (servers.MoveNext(out var uid, out var server, out var device)) + while (servers.MoveNext(out var uid, out var server, out var device, out var xform)) // Frontier modification { - if (!_stationSystem.GetOwningStation(uid)?.Equals(stationId) ?? true) + //if (!_stationSystem.GetOwningStation(uid)?.Equals(stationId) ?? true) + if (xform.MapID != map) //Frontier modification continue; if (!server.Available) diff --git a/Content.Server/Medical/SuitSensors/SuitSensorComponent.cs b/Content.Server/Medical/SuitSensors/SuitSensorComponent.cs index 9079655c80c..c7bd961e2cb 100644 --- a/Content.Server/Medical/SuitSensors/SuitSensorComponent.cs +++ b/Content.Server/Medical/SuitSensors/SuitSensorComponent.cs @@ -59,13 +59,15 @@ public sealed partial class SuitSensorComponent : Component [DataField("nextUpdate", customTypeSerializer:typeof(TimeOffsetSerializer))] [AutoPausedField] public TimeSpan NextUpdate = TimeSpan.Zero; - + + /* -- Frontier modification /// /// The station this suit sensor belongs to. If it's null the suit didn't spawn on a station and the sensor doesn't work. /// [DataField("station")] public EntityUid? StationId = null; - + */ + /// /// The server the suit sensor sends it state to. /// The suit sensor will try connecting to a new server when no server is connected. diff --git a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs index 94ecf5fd0e7..2c4819b9b99 100644 --- a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs +++ b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs @@ -6,7 +6,7 @@ using Content.Server.GameTicking; using Content.Server.Medical.CrewMonitoring; using Content.Server.Popups; -using Content.Server.Station.Systems; +//using Content.Server.Station.Systems; // Frontier modification using Content.Shared.Damage; using Content.Shared.DeviceNetwork; using Content.Shared.Emp; @@ -20,6 +20,8 @@ using Robust.Shared.Map; using Robust.Shared.Random; using Robust.Shared.Timing; +using System.Numerics; //Frontier modification +using Content.Server.Salvage.Expeditions; // Frontier modification namespace Content.Server.Medical.SuitSensors; @@ -33,12 +35,13 @@ public sealed class SuitSensorSystem : EntitySystem [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly StationSystem _stationSystem = default!; + //[Dependency] private readonly StationSystem _stationSystem = default!; // Frontier modification + [Dependency] private readonly MetaDataSystem _metaData = default!; // Frontier modification public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnPlayerSpawn); + //SubscribeLocalEvent(OnPlayerSpawn); // Frontier modification SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnEquipped); SubscribeLocalEvent(OnUnequipped); @@ -55,9 +58,10 @@ public override void Update(float frameTime) base.Update(frameTime); var curTime = _gameTiming.CurTime; - var sensors = EntityManager.EntityQueryEnumerator(); + //var sensors = EntityManager.EntityQueryEnumerator(); // Frontier modification + var sensors = EntityQueryEnumerator(); // Frontier modification - while (sensors.MoveNext(out var uid, out var sensor, out var device)) + while (sensors.MoveNext(out var uid, out var sensor, out var device, out var xform)) // Frontier modification { if (device.TransmitFrequency is null) continue; @@ -66,8 +70,10 @@ public override void Update(float frameTime) if (curTime < sensor.NextUpdate) continue; + /* -- Frontier modification if (!CheckSensorAssignedStation(uid, sensor)) continue; + */ // TODO: This would cause imprecision at different tick rates. sensor.NextUpdate = curTime + sensor.UpdateRate; @@ -80,8 +86,10 @@ public override void Update(float frameTime) //Retrieve active server address if the sensor isn't connected to a server if (sensor.ConnectedServer == null) { - if (!_monitoringServerSystem.TryGetActiveServerAddress(sensor.StationId!.Value, out var address)) + //if (!_monitoringServerSystem.TryGetActiveServerAddress(sensor.StationId!.Value, out var address)) // Frontier modification + if (!_monitoringServerSystem.TryGetActiveServerAddress(xform.MapID, out var address)) // Frontier modification continue; + sensor.ConnectedServer = address; } @@ -100,6 +108,7 @@ public override void Update(float frameTime) } } + /* -- Frontier modification /// /// Checks whether the sensor is assigned to a station or not /// and tries to assign an unassigned sensor to a station if it's currently on a grid @@ -139,11 +148,14 @@ private void RecursiveSensor(EntityUid uid, EntityUid stationUid, EntityQuery(); + var userLocationName = Loc.GetString("suit-sensor-location-unknown"); // Frontier modification if (_idCardSystem.TryFindIdCard(sensor.User.Value, out var card)) { @@ -346,7 +360,8 @@ public void SetSensor(EntityUid uid, SuitSensorMode mode, EntityUid? userUid = n totalDamage = damageable.TotalDamage.Int(); // finally, form suit sensor status - var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments); + // will additonally check the grid and name if it exists, as well if its expedition + var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments, userLocationName); switch (sensor.Mode) { case SuitSensorMode.SensorBinary: @@ -355,6 +370,32 @@ public void SetSensor(EntityUid uid, SuitSensorMode mode, EntityUid? userUid = n case SuitSensorMode.SensorVitals: status.IsAlive = isAlive; status.TotalDamage = totalDamage; + string locationName; // Frontier modification + + //Frontier modification + if (transform.GridUid != null) + { + if(TryComp(transform.GridUid.Value, out var salvageComp)) + { + locationName = Loc.GetString("suit-sensor-location-expedition"); + } + else + { + var meta = MetaData(transform.GridUid.Value); + + locationName = meta.EntityName; + } + } + else if (transform.MapUid != null) + { + locationName = Loc.GetString("suit-sensor-location-space"); // Frontier modification + } + else + { + locationName = Loc.GetString("suit-sensor-location-unknown"); // Frontier modification + } + + status.LocationName = locationName; //Frontier modification break; case SuitSensorMode.SensorCords: status.IsAlive = isAlive; @@ -364,21 +405,49 @@ public void SetSensor(EntityUid uid, SuitSensorMode mode, EntityUid? userUid = n if (transform.GridUid != null) { - coordinates = new EntityCoordinates(transform.GridUid.Value, + + coordinates = new EntityCoordinates(transform.GridUid.Value, _transform.GetInvWorldMatrix(xformQuery.GetComponent(transform.GridUid.Value), xformQuery) .Transform(_transform.GetWorldPosition(transform, xformQuery))); + /* + coordinates = new EntityCoordinates(uid, + new Vector2(transform.WorldPosition.X, transform.WorldPosition.Y)); //Frontier modification + */ + + // Frontier modification + /// Checks if sensor is present on expedition grid + if(TryComp(transform.GridUid.Value, out var salvageComp)) + { + locationName = Loc.GetString("suit-sensor-location-expedition"); + } + else + { + var meta = MetaData(transform.GridUid.Value); + + locationName = meta.EntityName; + } } else if (transform.MapUid != null) { + coordinates = new EntityCoordinates(transform.MapUid.Value, _transform.GetWorldPosition(transform, xformQuery)); + /* + coordinates = new EntityCoordinates(uid, + new Vector2(transform.WorldPosition.X, transform.WorldPosition.Y)); //Frontier modification + */ + + locationName = Loc.GetString("suit-sensor-location-space"); // Frontier modification } else { coordinates = EntityCoordinates.Invalid; + + locationName = Loc.GetString("suit-sensor-location-unknown"); // Frontier modification } status.Coordinates = GetNetCoordinates(coordinates); + status.LocationName = locationName; //Frontier modification break; } @@ -405,6 +474,8 @@ public NetworkPayload SuitSensorToPacket(SuitSensorStatus status) payload.Add(SuitSensorConstants.NET_TOTAL_DAMAGE, status.TotalDamage); if (status.Coordinates != null) payload.Add(SuitSensorConstants.NET_COORDINATES, status.Coordinates); + if (status.LocationName != null) + payload.Add(SuitSensorConstants.NET_LOCATION_NAME, status.LocationName); return payload; } @@ -427,12 +498,13 @@ public NetworkPayload SuitSensorToPacket(SuitSensorStatus status) if (!payload.TryGetValue(SuitSensorConstants.NET_JOB_DEPARTMENTS, out List? jobDepartments)) return null; if (!payload.TryGetValue(SuitSensorConstants.NET_IS_ALIVE, out bool? isAlive)) return null; if (!payload.TryGetValue(SuitSensorConstants.NET_SUIT_SENSOR_UID, out NetEntity suitSensorUid)) return null; + if (!payload.TryGetValue(SuitSensorConstants.NET_LOCATION_NAME, out string? location)) return null; // Frontier modification - // try get total damage and cords (optionals) + // try get total damage and cords and location name (optionals) payload.TryGetValue(SuitSensorConstants.NET_TOTAL_DAMAGE, out int? totalDamage); payload.TryGetValue(SuitSensorConstants.NET_COORDINATES, out NetCoordinates? coords); - var status = new SuitSensorStatus(suitSensorUid, name, job, jobIcon, jobDepartments) + var status = new SuitSensorStatus(suitSensorUid, name, job, jobIcon, jobDepartments, location) { IsAlive = isAlive.Value, TotalDamage = totalDamage, diff --git a/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs b/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs index 07e0eca33bd..34d7d221649 100644 --- a/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs +++ b/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs @@ -6,13 +6,14 @@ namespace Content.Shared.Medical.SuitSensor; [Serializable, NetSerializable] public sealed class SuitSensorStatus { - public SuitSensorStatus(NetEntity suitSensorUid, string name, string job, string jobIcon, List jobDepartments) + public SuitSensorStatus(NetEntity suitSensorUid, string name, string job, string jobIcon, List jobDepartments, string locationName) { SuitSensorUid = suitSensorUid; Name = name; Job = job; JobIcon = jobIcon; JobDepartments = jobDepartments; + LocationName = locationName; } public TimeSpan Timestamp; @@ -24,6 +25,7 @@ public SuitSensorStatus(NetEntity suitSensorUid, string name, string job, string public bool IsAlive; public int? TotalDamage; public NetCoordinates? Coordinates; + public string LocationName; } [Serializable, NetSerializable] @@ -60,6 +62,7 @@ public static class SuitSensorConstants public const string NET_TOTAL_DAMAGE = "vitals"; public const string NET_COORDINATES = "coords"; public const string NET_SUIT_SENSOR_UID = "uid"; + public const string NET_LOCATION_NAME = "location"; // Frontier modification ///Used by the CrewMonitoringServerSystem to send the status of all connected suit sensors to each crew monitor public const string NET_STATUS_COLLECTION = "suit-status-collection"; diff --git a/Resources/Locale/en-US/_NF/medical/suit-sensor.ftl b/Resources/Locale/en-US/_NF/medical/suit-sensor.ftl new file mode 100644 index 00000000000..ea74f4a0507 --- /dev/null +++ b/Resources/Locale/en-US/_NF/medical/suit-sensor.ftl @@ -0,0 +1,5 @@ +## Components + +suit-sensor-location-unknown = Unidentified Location +suit-sensor-location-space = In Space +suit-sensor-location-expedition = On Expedition \ No newline at end of file