Have crew monitor display entity coordinates instead (#13120)
closes https://github.com/space-wizards/space-station-14/issues/13042
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Content.Client.Medical.CrewMonitoring
|
|||||||
private List<Control> _rowsContent = new();
|
private List<Control> _rowsContent = new();
|
||||||
private List<(DirectionIcon Icon, Vector2 Position)> _directionIcons = new();
|
private List<(DirectionIcon Icon, Vector2 Position)> _directionIcons = new();
|
||||||
private readonly IEyeManager _eye;
|
private readonly IEyeManager _eye;
|
||||||
|
private readonly IEntityManager _entityManager;
|
||||||
|
|
||||||
public static int IconSize = 16; // XAML has a `VSeparationOverride` of 20 for each row.
|
public static int IconSize = 16; // XAML has a `VSeparationOverride` of 20 for each row.
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ namespace Content.Client.Medical.CrewMonitoring
|
|||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
_eye = IoCManager.Resolve<IEyeManager>();
|
_eye = IoCManager.Resolve<IEyeManager>();
|
||||||
|
_entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowSensors(List<SuitSensorStatus> stSensors, Vector2 worldPosition, bool snap, float precision)
|
public void ShowSensors(List<SuitSensorStatus> stSensors, Vector2 worldPosition, bool snap, float precision)
|
||||||
@@ -72,7 +74,7 @@ namespace Content.Client.Medical.CrewMonitoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BoxContainer GetPositionBox(MapCoordinates? coordinates, Vector2 sensorPosition, bool snap, float precision)
|
private BoxContainer GetPositionBox(EntityCoordinates? coordinates, Vector2 sensorPosition, bool snap, float precision)
|
||||||
{
|
{
|
||||||
var box = new BoxContainer() { Orientation = LayoutOrientation.Horizontal };
|
var box = new BoxContainer() { Orientation = LayoutOrientation.Horizontal };
|
||||||
|
|
||||||
@@ -90,6 +92,7 @@ namespace Content.Client.Medical.CrewMonitoring
|
|||||||
{
|
{
|
||||||
// todo: add locations names (kitchen, bridge, etc)
|
// todo: add locations names (kitchen, bridge, etc)
|
||||||
var pos = (Vector2i) coordinates.Value.Position;
|
var pos = (Vector2i) coordinates.Value.Position;
|
||||||
|
var mapCoords = coordinates.Value.ToMap(_entityManager).Position;
|
||||||
var dirIcon = new DirectionIcon(snap, precision)
|
var dirIcon = new DirectionIcon(snap, precision)
|
||||||
{
|
{
|
||||||
SetSize = (IconSize, IconSize),
|
SetSize = (IconSize, IconSize),
|
||||||
@@ -97,7 +100,7 @@ namespace Content.Client.Medical.CrewMonitoring
|
|||||||
};
|
};
|
||||||
box.AddChild(dirIcon);
|
box.AddChild(dirIcon);
|
||||||
box.AddChild(new Label() { Text = pos.ToString() });
|
box.AddChild(new Label() { Text = pos.ToString() });
|
||||||
_directionIcons.Add((dirIcon, coordinates.Value.Position - sensorPosition));
|
_directionIcons.Add((dirIcon, mapCoords - sensorPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
return box;
|
return box;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Content.Server.DeviceNetwork.Systems;
|
|||||||
using Content.Server.Medical.SuitSensors;
|
using Content.Server.Medical.SuitSensors;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.Medical.CrewMonitoring;
|
using Content.Shared.Medical.CrewMonitoring;
|
||||||
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Server.Medical.CrewMonitoring
|
namespace Content.Server.Medical.CrewMonitoring
|
||||||
@@ -66,9 +67,9 @@ namespace Content.Server.Medical.CrewMonitoring
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// update all sensors info
|
// update all sensors info
|
||||||
var worldPos = _xform.GetWorldPosition(uid);
|
var xform = Transform(uid);
|
||||||
var allSensors = component.ConnectedSensors.Values.ToList();
|
var allSensors = component.ConnectedSensors.Values.ToList();
|
||||||
var uiState = new CrewMonitoringState(allSensors, worldPos, component.Snap, component.Precision);
|
var uiState = new CrewMonitoringState(allSensors, xform.WorldPosition, component.Snap, component.Precision);
|
||||||
ui.SetState(uiState);
|
ui.SetState(uiState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ using Content.Shared.MobState.Components;
|
|||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -26,6 +25,7 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
[Dependency] private readonly SharedTransformSystem _xform = default!;
|
||||||
|
|
||||||
private const float UpdateRate = 1f;
|
private const float UpdateRate = 1f;
|
||||||
private float _updateDif;
|
private float _updateDif;
|
||||||
@@ -228,7 +228,7 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// check if sensor is enabled and worn by user
|
// check if sensor is enabled and worn by user
|
||||||
if (sensor.Mode == SuitSensorMode.SensorOff || sensor.User == null)
|
if (sensor.Mode == SuitSensorMode.SensorOff || sensor.User == null || transform.GridUid == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// try to get mobs id from ID slot
|
// try to get mobs id from ID slot
|
||||||
@@ -245,18 +245,17 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
// get health mob state
|
// get health mob state
|
||||||
var isAlive = false;
|
var isAlive = false;
|
||||||
if (EntityManager.TryGetComponent(sensor.User.Value, out MobStateComponent? mobState))
|
if (EntityManager.TryGetComponent(sensor.User.Value, out MobStateComponent? mobState))
|
||||||
{
|
|
||||||
isAlive = _mobStateSystem.IsAlive(sensor.User.Value, mobState);
|
isAlive = _mobStateSystem.IsAlive(sensor.User.Value, mobState);
|
||||||
}
|
|
||||||
|
|
||||||
// get mob total damage
|
// get mob total damage
|
||||||
var totalDamage = 0;
|
var totalDamage = 0;
|
||||||
if (EntityManager.TryGetComponent(sensor.User.Value, out DamageableComponent? damageable))
|
if (TryComp<DamageableComponent>(sensor.User.Value, out var damageable))
|
||||||
{
|
|
||||||
totalDamage = damageable.TotalDamage.Int();
|
totalDamage = damageable.TotalDamage.Int();
|
||||||
}
|
|
||||||
|
|
||||||
// finally, form suit sensor status
|
// finally, form suit sensor status
|
||||||
|
var xForm = Transform(sensor.User.Value);
|
||||||
|
var xFormQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
var coords = _xform.GetMoverCoordinates(xForm, xFormQuery);
|
||||||
var status = new SuitSensorStatus(userName, userJob);
|
var status = new SuitSensorStatus(userName, userJob);
|
||||||
switch (sensor.Mode)
|
switch (sensor.Mode)
|
||||||
{
|
{
|
||||||
@@ -270,7 +269,7 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
case SuitSensorMode.SensorCords:
|
case SuitSensorMode.SensorCords:
|
||||||
status.IsAlive = isAlive;
|
status.IsAlive = isAlive;
|
||||||
status.TotalDamage = totalDamage;
|
status.TotalDamage = totalDamage;
|
||||||
status.Coordinates = transform.MapPosition;
|
status.Coordinates = coords;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +294,7 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
if (status.Coordinates != null)
|
if (status.Coordinates != null)
|
||||||
payload.Add(SuitSensorConstants.NET_CORDINATES, status.Coordinates);
|
payload.Add(SuitSensorConstants.NET_CORDINATES, status.Coordinates);
|
||||||
|
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,13 +316,13 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
|
|
||||||
// try get total damage and cords (optionals)
|
// try get total damage and cords (optionals)
|
||||||
payload.TryGetValue(SuitSensorConstants.NET_TOTAL_DAMAGE, out int? totalDamage);
|
payload.TryGetValue(SuitSensorConstants.NET_TOTAL_DAMAGE, out int? totalDamage);
|
||||||
payload.TryGetValue(SuitSensorConstants.NET_CORDINATES, out MapCoordinates? cords);
|
payload.TryGetValue(SuitSensorConstants.NET_CORDINATES, out EntityCoordinates? cords);
|
||||||
|
|
||||||
var status = new SuitSensorStatus(name, job)
|
var status = new SuitSensorStatus(name, job)
|
||||||
{
|
{
|
||||||
IsAlive = isAlive.Value,
|
IsAlive = isAlive.Value,
|
||||||
TotalDamage = totalDamage,
|
TotalDamage = totalDamage,
|
||||||
Coordinates = cords
|
Coordinates = cords,
|
||||||
};
|
};
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Content.Shared.Medical.SuitSensor
|
|||||||
public string Job;
|
public string Job;
|
||||||
public bool IsAlive;
|
public bool IsAlive;
|
||||||
public int? TotalDamage;
|
public int? TotalDamage;
|
||||||
public MapCoordinates? Coordinates;
|
public EntityCoordinates? Coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
randomMode: false
|
randomMode: false
|
||||||
controlsLocked: true
|
controlsLocked: true
|
||||||
mode: SensorCords
|
mode: SensorCords
|
||||||
activationContainer: "ImplantContainer"
|
activationContainer: "implant"
|
||||||
- type: DeviceNetwork
|
- type: DeviceNetwork
|
||||||
deviceNetId: Wireless
|
deviceNetId: Wireless
|
||||||
transmitFrequencyId: SuitSensor
|
transmitFrequencyId: SuitSensor
|
||||||
|
|||||||
Reference in New Issue
Block a user