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:
@@ -33,6 +33,7 @@ public sealed class SuitSensorSystem : EntitySystem
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
||||
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -344,6 +345,11 @@ public sealed class SuitSensorSystem : EntitySystem
|
||||
if (TryComp<DamageableComponent>(sensor.User.Value, out var damageable))
|
||||
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
|
||||
var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments);
|
||||
switch (sensor.Mode)
|
||||
@@ -354,10 +360,12 @@ public sealed class SuitSensorSystem : EntitySystem
|
||||
case SuitSensorMode.SensorVitals:
|
||||
status.IsAlive = isAlive;
|
||||
status.TotalDamage = totalDamage;
|
||||
status.TotalDamageThreshold = totalDamageThreshold;
|
||||
break;
|
||||
case SuitSensorMode.SensorCords:
|
||||
status.IsAlive = isAlive;
|
||||
status.TotalDamage = totalDamage;
|
||||
status.TotalDamageThreshold = totalDamageThreshold;
|
||||
EntityCoordinates coordinates;
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
|
||||
@@ -402,6 +410,8 @@ public sealed class SuitSensorSystem : EntitySystem
|
||||
|
||||
if (status.TotalDamage != null)
|
||||
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)
|
||||
payload.Add(SuitSensorConstants.NET_COORDINATES, status.Coordinates);
|
||||
|
||||
@@ -429,12 +439,14 @@ public sealed class SuitSensorSystem : EntitySystem
|
||||
|
||||
// try get total damage and cords (optionals)
|
||||
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);
|
||||
|
||||
var status = new SuitSensorStatus(suitSensorUid, name, job, jobIcon, jobDepartments)
|
||||
{
|
||||
IsAlive = isAlive.Value,
|
||||
TotalDamage = totalDamage,
|
||||
TotalDamageThreshold = totalDamageThreshold,
|
||||
Coordinates = coords,
|
||||
};
|
||||
return status;
|
||||
|
||||
Reference in New Issue
Block a user