Suit Sensors No Longer Use a Hardcoded 'Total Health' (#26658)
* Suit sensors now know the 'total health' of an entity
* Missed the constructor 😔
This commit is contained in:
@@ -210,9 +210,9 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "dead");
|
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "dead");
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (sensor.TotalDamage != null)
|
else if (sensor.DamagePercentage != null)
|
||||||
{
|
{
|
||||||
var index = MathF.Round(4f * (sensor.TotalDamage.Value / 100f));
|
var index = MathF.Round(4f * sensor.DamagePercentage.Value);
|
||||||
|
|
||||||
if (index >= 5)
|
if (index >= 5)
|
||||||
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "critical");
|
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "critical");
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public sealed class SuitSensorSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||||
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
||||||
|
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -344,6 +345,11 @@ public sealed class SuitSensorSystem : EntitySystem
|
|||||||
if (TryComp<DamageableComponent>(sensor.User.Value, out var damageable))
|
if (TryComp<DamageableComponent>(sensor.User.Value, out var damageable))
|
||||||
totalDamage = damageable.TotalDamage.Int();
|
totalDamage = damageable.TotalDamage.Int();
|
||||||
|
|
||||||
|
// Get mob total damage crit threshold
|
||||||
|
int? totalDamageThreshold = null;
|
||||||
|
if (_mobThresholdSystem.TryGetThresholdForState(sensor.User.Value, Shared.Mobs.MobState.Critical, out var critThreshold))
|
||||||
|
totalDamageThreshold = critThreshold.Value.Int();
|
||||||
|
|
||||||
// finally, form suit sensor status
|
// finally, form suit sensor status
|
||||||
var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments);
|
var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments);
|
||||||
switch (sensor.Mode)
|
switch (sensor.Mode)
|
||||||
@@ -354,10 +360,12 @@ public sealed class SuitSensorSystem : EntitySystem
|
|||||||
case SuitSensorMode.SensorVitals:
|
case SuitSensorMode.SensorVitals:
|
||||||
status.IsAlive = isAlive;
|
status.IsAlive = isAlive;
|
||||||
status.TotalDamage = totalDamage;
|
status.TotalDamage = totalDamage;
|
||||||
|
status.TotalDamageThreshold = totalDamageThreshold;
|
||||||
break;
|
break;
|
||||||
case SuitSensorMode.SensorCords:
|
case SuitSensorMode.SensorCords:
|
||||||
status.IsAlive = isAlive;
|
status.IsAlive = isAlive;
|
||||||
status.TotalDamage = totalDamage;
|
status.TotalDamage = totalDamage;
|
||||||
|
status.TotalDamageThreshold = totalDamageThreshold;
|
||||||
EntityCoordinates coordinates;
|
EntityCoordinates coordinates;
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
@@ -402,6 +410,8 @@ public sealed class SuitSensorSystem : EntitySystem
|
|||||||
|
|
||||||
if (status.TotalDamage != null)
|
if (status.TotalDamage != null)
|
||||||
payload.Add(SuitSensorConstants.NET_TOTAL_DAMAGE, status.TotalDamage);
|
payload.Add(SuitSensorConstants.NET_TOTAL_DAMAGE, status.TotalDamage);
|
||||||
|
if (status.TotalDamageThreshold != null)
|
||||||
|
payload.Add(SuitSensorConstants.NET_TOTAL_DAMAGE_THRESHOLD, status.TotalDamageThreshold);
|
||||||
if (status.Coordinates != null)
|
if (status.Coordinates != null)
|
||||||
payload.Add(SuitSensorConstants.NET_COORDINATES, status.Coordinates);
|
payload.Add(SuitSensorConstants.NET_COORDINATES, status.Coordinates);
|
||||||
|
|
||||||
@@ -429,12 +439,14 @@ public sealed class SuitSensorSystem : EntitySystem
|
|||||||
|
|
||||||
// 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_TOTAL_DAMAGE_THRESHOLD, out int? totalDamageThreshold);
|
||||||
payload.TryGetValue(SuitSensorConstants.NET_COORDINATES, out NetCoordinates? coords);
|
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)
|
||||||
{
|
{
|
||||||
IsAlive = isAlive.Value,
|
IsAlive = isAlive.Value,
|
||||||
TotalDamage = totalDamage,
|
TotalDamage = totalDamage,
|
||||||
|
TotalDamageThreshold = totalDamageThreshold,
|
||||||
Coordinates = coords,
|
Coordinates = coords,
|
||||||
};
|
};
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public sealed class SuitSensorStatus
|
|||||||
public List<string> JobDepartments;
|
public List<string> JobDepartments;
|
||||||
public bool IsAlive;
|
public bool IsAlive;
|
||||||
public int? TotalDamage;
|
public int? TotalDamage;
|
||||||
|
public int? TotalDamageThreshold;
|
||||||
|
public float? DamagePercentage => TotalDamageThreshold == null || TotalDamage == null ? null : TotalDamage / TotalDamageThreshold;
|
||||||
public NetCoordinates? Coordinates;
|
public NetCoordinates? Coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +60,7 @@ public static class SuitSensorConstants
|
|||||||
public const string NET_JOB_DEPARTMENTS = "jobDepartments";
|
public const string NET_JOB_DEPARTMENTS = "jobDepartments";
|
||||||
public const string NET_IS_ALIVE = "alive";
|
public const string NET_IS_ALIVE = "alive";
|
||||||
public const string NET_TOTAL_DAMAGE = "vitals";
|
public const string NET_TOTAL_DAMAGE = "vitals";
|
||||||
|
public const string NET_TOTAL_DAMAGE_THRESHOLD = "vitalsThreshold";
|
||||||
public const string NET_COORDINATES = "coords";
|
public const string NET_COORDINATES = "coords";
|
||||||
public const string NET_SUIT_SENSOR_UID = "uid";
|
public const string NET_SUIT_SENSOR_UID = "uid";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user