NoServerLabel.Visible = false;
+ // Collect one status per user, using the sensor with the most data available.
+ Dictionary<NetEntity, SuitSensorStatus> uniqueSensorsMap = new();
+ foreach (var sensor in sensors)
+ {
+ if (uniqueSensorsMap.TryGetValue(sensor.OwnerUid, out var existingSensor))
+ {
+ // Skip if we already have a sensor with more data for this mob.
+ if (existingSensor.Coordinates != null && sensor.Coordinates == null)
+ continue;
+
+ if (existingSensor.DamagePercentage != null && sensor.DamagePercentage == null)
+ continue;
+ }
+
+ uniqueSensorsMap[sensor.OwnerUid] = sensor;
+ }
+ var uniqueSensors = uniqueSensorsMap.Values.ToList();
+
// Order sensor data
- var orderedSensors = sensors.OrderBy(n => n.Name).OrderBy(j => j.Job);
+ var orderedSensors = uniqueSensors.OrderBy(n => n.Name).OrderBy(j => j.Job);
var assignedSensors = new HashSet<SuitSensorStatus>();
- var departments = sensors.SelectMany(d => d.JobDepartments).Distinct().OrderBy(n => n);
+ var departments = uniqueSensors.SelectMany(d => d.JobDepartments).Distinct().OrderBy(n => n);
// Create department labels and populate lists
foreach (var department in departments)
totalDamageThreshold = critThreshold.Value.Int();
// finally, form suit sensor status
- var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments);
+ var status = new SuitSensorStatus(GetNetEntity(sensor.User.Value), GetNetEntity(uid), userName, userJob, userJobIcon, userJobDepartments);
switch (sensor.Mode)
{
case SuitSensorMode.SensorBinary:
[SuitSensorConstants.NET_JOB_DEPARTMENTS] = status.JobDepartments,
[SuitSensorConstants.NET_IS_ALIVE] = status.IsAlive,
[SuitSensorConstants.NET_SUIT_SENSOR_UID] = status.SuitSensorUid,
+ [SuitSensorConstants.NET_OWNER_UID] = status.OwnerUid,
};
if (status.TotalDamage != null)
if (!payload.TryGetValue(SuitSensorConstants.NET_JOB_DEPARTMENTS, out List<string>? 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_OWNER_UID, out NetEntity ownerUid)) return null;
// 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)
+ var status = new SuitSensorStatus(ownerUid, suitSensorUid, name, job, jobIcon, jobDepartments)
{
IsAlive = isAlive.Value,
TotalDamage = totalDamage,
[Serializable, NetSerializable]
public sealed class SuitSensorStatus
{
- public SuitSensorStatus(NetEntity suitSensorUid, string name, string job, string jobIcon, List<string> jobDepartments)
+ public SuitSensorStatus(NetEntity ownerUid, NetEntity suitSensorUid, string name, string job, string jobIcon, List<string> jobDepartments)
{
+ OwnerUid = ownerUid;
SuitSensorUid = suitSensorUid;
Name = name;
Job = job;
public TimeSpan Timestamp;
public NetEntity SuitSensorUid;
+ public NetEntity OwnerUid;
public string Name;
public string Job;
public string JobIcon;
public static class SuitSensorConstants
{
+ public const string NET_OWNER_UID = "ownerUid";
public const string NET_NAME = "name";
public const string NET_JOB = "job";
public const string NET_JOB_ICON = "jobIcon";