CrewMonitoring (#3788)

This commit is contained in:
Daniel 2026-01-26 21:00:52 +01:00 committed by GitHub
parent a59277ff01
commit 8a2e13cb0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 815 additions and 187 deletions

View file

@ -31,7 +31,6 @@ public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
_menu = this.CreateWindow<CrewMonitoringWindow>();
_menu.Set(stationName, gridUid);
_menu.SetBoundUserInterface(this);
}
protected override void UpdateState(BoundUserInterfaceState state)
@ -43,7 +42,6 @@ public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
case CrewMonitoringState st:
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowSensors(st.Sensors, Owner, xform?.Coordinates);
_menu?.UpdateCorpseAlertToggle(st.CorpseAlertEnabled);
break;
}
}

View file

@ -34,13 +34,6 @@
HorizontalAlignment="Center"
Visible="false"/>
</ScrollContainer>
<!-- Sunrise - Start -->
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 2 0 3">
<Label Text ="{Loc crew-monitoring-corpse-alert}" VerticalAlignment="Center" Margin="0 0 6 0"/>
<CheckBox Name="CorpseAlertToggle" Text="{Loc 'crew-monitoring-corpse-alert-off'}"
HorizontalAlignment="Center" Margin="0 0 0 0" SetWidth="260"/>
</BoxContainer>
<!-- Sunrise - End -->
</BoxContainer>
</BoxContainer>

View file

@ -4,7 +4,6 @@ using System.Numerics;
using Content.Client.Pinpointer.UI;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Medical.SuitSensor;
using Content.Shared.StatusIcon;
using Robust.Client.AutoGenerated;
@ -26,14 +25,12 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ILocalizationManager _loc = default!; // Sunrise - Added
private readonly SharedTransformSystem _transformSystem;
private readonly SpriteSystem _spriteSystem;
private NetEntity? _trackedEntity;
private bool _tryToScrollToListFocus;
private Texture? _blipTexture;
private CrewMonitoringBoundUserInterface? _boundUserInterface;
public CrewMonitoringWindow()
{
@ -44,11 +41,6 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
_spriteSystem = _entManager.System<SpriteSystem>();
NavMap.TrackedEntitySelectedAction += SetTrackedEntityFromNavMap;
// Sunrise - Start: Alert
CorpseAlertToggle.OnToggled += OnCorpseAlertTogglePressed;
UpdateCorpseAlertToggle(false);
// Sunrise - End: Alert
}
public void Set(string stationName, EntityUid? mapUid)
@ -66,11 +58,6 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
NavMap.ForceNavMapUpdate();
}
public void SetBoundUserInterface(CrewMonitoringBoundUserInterface boundUserInterface)
{
_boundUserInterface = boundUserInterface;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
@ -460,34 +447,6 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
NavMap.TrackedEntities.Clear();
NavMap.LocalizedNames.Clear();
}
// Sunrise - Start: Alert
public void UpdateCorpseAlertToggle(bool enabled)
{
CorpseAlertToggle.Pressed = enabled;
CorpseAlertToggle.Text = _loc.GetString(enabled ? "crew-monitoring-corpse-alert-on" : "crew-monitoring-corpse-alert-off");
CorpseAlertToggle.Label.FontColorOverride = enabled ? Color.LimeGreen : Color.Red;
CorpseAlertToggle.Disabled = false;
}
private void OnCorpseAlertTogglePressed(BaseButton.ButtonToggledEventArgs args)
{
CorpseAlertToggle.Pressed = args.Pressed;
CorpseAlertToggle.Disabled = true;
_boundUserInterface?.SendMessage(new CrewMonitoringToggleCorpseAlertMessage());
}
// Sunrise - End: Alert
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_boundUserInterface = null;
}
}
}
public sealed class CrewMonitoringButton : Button

View file

@ -1,58 +0,0 @@
using Content.Shared.Medical.CrewMonitoring;
using Robust.Client.UserInterface;
using System.Linq;
using Content.Shared.Access;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Containers.ItemSlots;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
using static Content.Shared.Access.Components.AccessOverriderComponent;
namespace Content.Client.Medical.CrewMonitoring.Brigmedic;
public class BrigmedicCrewMonitoringBoundUserInterface : BoundUserInterface
{
[ViewVariables]
protected CrewMonitoringWindow? _menu;
public BrigmedicCrewMonitoringBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_accessOverriderSystem = EntMan.System<SharedAccessOverriderSystem>();
}
protected readonly SharedAccessOverriderSystem _accessOverriderSystem = default!;
protected override void Open()
{
base.Open();
EntityUid? gridUid = null;
var stationName = string.Empty;
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
if (EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var metaData))
{
stationName = metaData.EntityName;
}
}
_menu = this.CreateWindow<CrewMonitoringWindow>();
_menu.Set(stationName, gridUid);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
switch (state)
{
case CrewMonitoringState st:
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
var securityDepartmentSensors = st.Sensors
.Where(sensor => sensor.JobDepartments.Contains("Security"))
.ToList();
_menu?.ShowSensors(securityDepartmentSensors, Owner, xform?.Coordinates);
break;
}
}
}

View file

@ -1,73 +0,0 @@
using Content.Shared.Medical.CrewMonitoring;
using Robust.Client.UserInterface;
using System.Linq;
using Content.Shared.Access;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Containers.ItemSlots;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
using static Content.Shared.Access.Components.AccessOverriderComponent;
using Content.Shared.Implants.Components;
namespace Content.Client.Medical.CrewMonitoring.BSO;
public class BSOCrewMonitoringBoundUserInterface : BoundUserInterface
{
[ViewVariables]
protected CrewMonitoringWindow? _menu;
public BSOCrewMonitoringBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_accessOverriderSystem = EntMan.System<SharedAccessOverriderSystem>();
}
protected readonly SharedAccessOverriderSystem _accessOverriderSystem = default!;
protected override void Open()
{
base.Open();
EntityUid? gridUid = null;
var stationName = string.Empty;
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
if (EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var metaData))
{
stationName = metaData.EntityName;
}
}
_menu = this.CreateWindow<CrewMonitoringWindow>();
_menu.Set(stationName, gridUid);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
switch (state)
{
case CrewMonitoringState st:
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
var commandDepartmentSensors = st.Sensors
.Where(sensor => sensor.JobDepartments.Contains("Command"))
.ToList();
//also ALWAYS include the trackers
//this is jank as there isnt a direct indication of a tracker in the suit sensor status
//so we need to check the component directly
foreach (var sensor in st.Sensors)
{
//get the client entity
var clientEntity = EntMan.GetEntity(sensor.SuitSensorUid);
if (EntMan.TryGetComponent<SubdermalImplantComponent>(clientEntity, out var suitSensor))
{
commandDepartmentSensors.Add(sensor);
}
}
//remove duplicates
commandDepartmentSensors = commandDepartmentSensors.Distinct().ToList();
_menu?.ShowSensors(commandDepartmentSensors, Owner, xform?.Coordinates);
break;
}
}
}

View file

@ -0,0 +1,46 @@
using Content.Shared.Medical.CrewMonitoring;
using Robust.Client.UserInterface;
namespace Content.Client._Sunrise.Medical.CrewMonitoring;
public class SunriseCrewMonitoringBoundUserInterface : BoundUserInterface
{
[ViewVariables]
protected SunriseCrewMonitoringWindow? _menu;
public SunriseCrewMonitoringBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
EntityUid? gridUid = null;
var stationName = string.Empty;
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
if (EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var metaData))
stationName = metaData.EntityName;
}
_menu = this.CreateWindow<SunriseCrewMonitoringWindow>();
_menu.SetBoundUserInterface(this);
_menu.Set(stationName, gridUid);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not CrewMonitoringState st)
return;
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowSensors(st.Sensors, Owner, xform?.Coordinates);
_menu?.UpdateCorpseAlertToggle(st.CorpseAlertEnabled);
}
}

View file

@ -0,0 +1,58 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:ui="clr-namespace:Content.Client.Medical.CrewMonitoring"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc crew-monitoring-ui-title}"
Resizable="False"
SetSize="1210 700"
MinSize="1210 700">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" VerticalExpand="True" HorizontalExpand="True">
<ui:CrewMonitoringNavMapControl Name="NavMap" HorizontalExpand="True" VerticalExpand="True" Margin="5 20"/>
<BoxContainer Orientation="Vertical" Margin="0 0 10 0">
<controls:StripeBack>
<PanelContainer>
<Label Name="StationName" Text="{Loc crew-monitoring-ui-no-station-label}" Align="Center" Margin="0 5 0 3"/>
</PanelContainer>
</controls:StripeBack>
<LineEdit Name="SearchLineEdit" HorizontalExpand="True"
PlaceHolder="{Loc crew-monitoring-ui-filter-line-placeholder}" />
<ScrollContainer Name="SensorScroller"
VerticalExpand="True"
SetWidth="520"
Margin="8, 8, 8, 8">
<BoxContainer Name="SensorsTable"
Orientation="Vertical"
HorizontalExpand="True"
Margin="0 0 10 0">
<!-- Table rows are filled by code -->
</BoxContainer>
<Label Name="NoServerLabel"
Text="{Loc crew-monitoring-ui-no-server-label}"
StyleClasses="LabelHeading"
FontColorOverride="Red"
HorizontalAlignment="Center"
Visible="false"/>
</ScrollContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 2 0 3">
<Label Text ="{Loc crew-monitoring-corpse-alert}" VerticalAlignment="Center" Margin="0 0 6 0"/>
<CheckBox Name="CorpseAlertToggle" Text="{Loc 'crew-monitoring-corpse-alert-off'}"
HorizontalAlignment="Center" Margin="0 0 0 0" SetWidth="260"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
<!-- Footer -->
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc crew-monitoring-ui-flavor-left-label}" StyleClasses="WindowFooterText" />
<Label Text="{Loc crew-monitoring-ui-flavor-right-label}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>

View file

@ -0,0 +1,504 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using Content.Client.Pinpointer.UI;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Medical.SuitSensor;
using Content.Shared.StatusIcon;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client._Sunrise.Medical.CrewMonitoring;
[GenerateTypedNameReferences]
public sealed partial class SunriseCrewMonitoringWindow : FancyWindow
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private readonly SharedTransformSystem _transformSystem;
private readonly SpriteSystem _spriteSystem;
private NetEntity? _trackedEntity;
private bool _tryToScrollToListFocus;
private Texture? _blipTexture;
private BoundUserInterface? _boundUserInterface;
private TimeSpan _lastStateUpdateTime;
private bool _showingEmptyState;
private int _emptyStateUpdateCount;
private bool _serverFound;
private const float ServerUpdateTimeoutSeconds = 7f;
public SunriseCrewMonitoringWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_transformSystem = _entManager.System<SharedTransformSystem>();
_spriteSystem = _entManager.System<SpriteSystem>();
NavMap.TrackedEntitySelectedAction += SetTrackedEntityFromNavMap;
CorpseAlertToggle.OnToggled += OnCorpseAlertTogglePressed;
UpdateCorpseAlertToggle(false);
}
public void Set(string stationName, EntityUid? mapUid)
{
_blipTexture = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png")));
if (_entManager.TryGetComponent<TransformComponent>(mapUid, out var xform))
NavMap.MapUid = xform.GridUid;
else
NavMap.Visible = false;
StationName.AddStyleClass("LabelBig");
StationName.Text = stationName;
NavMap.ForceNavMapUpdate();
}
public void SetBoundUserInterface(BoundUserInterface boundUserInterface)
{
_boundUserInterface = boundUserInterface;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (_tryToScrollToListFocus)
TryToScrollToFocus();
if (_showingEmptyState)
UpdateNoServerLabelText();
}
public void ShowSensors(List<SuitSensorStatus> sensors, EntityUid monitor, EntityCoordinates? monitorCoords)
{
ClearOutDatedData();
_lastStateUpdateTime = _gameTiming.CurTime;
if (sensors.Count == 0)
{
NoServerLabel.Visible = true;
_showingEmptyState = true;
if (!_serverFound && ++_emptyStateUpdateCount >= 2)
_serverFound = true;
UpdateNoServerLabelText();
return;
}
NoServerLabel.Visible = false;
_showingEmptyState = false;
_serverFound = true;
_emptyStateUpdateCount = 0;
Dictionary<NetEntity, SuitSensorStatus> uniqueSensorsMap = new();
foreach (var sensor in sensors)
{
if (uniqueSensorsMap.TryGetValue(sensor.OwnerUid, out var existingSensor))
{
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();
var orderedSensors = uniqueSensors.OrderBy(j => j.Job).ThenBy(n => n.Name);
var assignedSensors = new HashSet<SuitSensorStatus>();
var departments = uniqueSensors.SelectMany(d => d.JobDepartments).Distinct().OrderBy(n => n);
foreach (var department in departments)
{
var departmentSensors = orderedSensors.Where(d => d.JobDepartments.Contains(department));
if (departmentSensors == null || !departmentSensors.Any())
continue;
foreach (var sensor in departmentSensors)
assignedSensors.Add(sensor);
if (SensorsTable.ChildCount > 0)
{
var spacer = new Control()
{
SetHeight = 20,
};
SensorsTable.AddChild(spacer);
}
var deparmentLabel = new RichTextLabel()
{
Margin = new Thickness(10, 0),
HorizontalExpand = true,
};
deparmentLabel.SetMessage(department);
deparmentLabel.StyleClasses.Add("font-large");
SensorsTable.AddChild(deparmentLabel);
PopulateDepartmentList(departmentSensors);
}
var remainingSensors = orderedSensors.Except(assignedSensors);
if (remainingSensors.Any())
{
var spacer = new Control()
{
SetHeight = 20,
};
SensorsTable.AddChild(spacer);
var deparmentLabel = new RichTextLabel()
{
Margin = new Thickness(10, 0),
HorizontalExpand = true,
};
deparmentLabel.SetMessage(Loc.GetString("crew-monitoring-ui-no-department-label"));
SensorsTable.AddChild(deparmentLabel);
PopulateDepartmentList(remainingSensors);
}
if (monitorCoords != null && _blipTexture != null)
{
NavMap.TrackedEntities[_entManager.GetNetEntity(monitor)] = new NavMapBlip(monitorCoords.Value, _blipTexture, Color.Cyan, true, false);
}
}
private void UpdateNoServerLabelText()
{
var timedOut = (_gameTiming.CurTime - _lastStateUpdateTime) > TimeSpan.FromSeconds(ServerUpdateTimeoutSeconds);
if (timedOut)
{
_serverFound = false;
_emptyStateUpdateCount = 0;
}
NoServerLabel.Text = Loc.GetString(_serverFound && !timedOut
? "crew-monitoring-ui-no-sensors-label"
: "crew-monitoring-ui-no-server-label");
}
public void ClearSensors(bool showNoServerLabel)
{
ClearOutDatedData();
NoServerLabel.Visible = showNoServerLabel;
_showingEmptyState = showNoServerLabel;
if (showNoServerLabel)
{
_serverFound = false;
_emptyStateUpdateCount = 0;
_lastStateUpdateTime = TimeSpan.Zero;
UpdateNoServerLabelText();
}
}
private void PopulateDepartmentList(IEnumerable<SuitSensorStatus> departmentSensors)
{
foreach (var sensor in departmentSensors)
{
if (!string.IsNullOrEmpty(SearchLineEdit.Text)
&& !sensor.Name.Contains(SearchLineEdit.Text, StringComparison.CurrentCultureIgnoreCase)
&& !sensor.Job.Contains(SearchLineEdit.Text, StringComparison.CurrentCultureIgnoreCase))
continue;
var coordinates = _entManager.GetCoordinates(sensor.Coordinates);
NavMap.LocalizedNames.TryAdd(sensor.SuitSensorUid, sensor.Name + ", " + sensor.Job);
var sensorButton = new CrewMonitoringButton()
{
SuitSensorUid = sensor.SuitSensorUid,
Coordinates = coordinates,
Disabled = (coordinates == null),
HorizontalExpand = true,
};
if (sensor.SuitSensorUid == _trackedEntity)
sensorButton.AddStyleClass(StyleClass.Positive);
SensorsTable.AddChild(sensorButton);
var mainContainer = new BoxContainer()
{
Orientation = LayoutOrientation.Horizontal,
HorizontalExpand = true,
};
sensorButton.AddChild(mainContainer);
var statusContainer = new BoxContainer()
{
SizeFlagsStretchRatio = 1.25f,
Orientation = LayoutOrientation.Horizontal,
HorizontalExpand = true,
};
mainContainer.AddChild(statusContainer);
var suitCoordsIndicator = new TextureRect()
{
Texture = _blipTexture,
TextureScale = new Vector2(0.25f, 0.25f),
Modulate = coordinates != null ? Color.LimeGreen : Color.DarkRed,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
};
statusContainer.AddChild(suitCoordsIndicator);
var specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "alive");
if (!sensor.IsAlive)
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "dead");
else if (sensor.DamagePercentage != null)
{
var index = MathF.Round(4f * sensor.DamagePercentage.Value);
if (index >= 5)
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "critical");
else
specifier = new SpriteSpecifier.Rsi(new ResPath("Interface/Alerts/human_crew_monitoring.rsi"), "health" + index);
}
var statusIcon = new AnimatedTextureRect
{
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
Margin = new Thickness(0, 1, 3, 0),
};
statusIcon.SetFromSpriteSpecifier(specifier);
statusIcon.DisplayRect.TextureScale = new Vector2(2f, 2f);
statusContainer.AddChild(statusIcon);
var nameLabel = new Label()
{
Text = sensor.Name,
HorizontalExpand = true,
ClipText = true,
};
statusContainer.AddChild(nameLabel);
var jobContainer = new BoxContainer()
{
Orientation = LayoutOrientation.Horizontal,
HorizontalExpand = true,
};
mainContainer.AddChild(jobContainer);
if (_prototypeManager.TryIndex<JobIconPrototype>(sensor.JobIcon, out var proto))
{
var jobIcon = new TextureRect()
{
TextureScale = new Vector2(2f, 2f),
VerticalAlignment = VAlignment.Center,
Texture = _spriteSystem.Frame0(proto.Icon),
Margin = new Thickness(5, 0, 5, 0),
};
jobContainer.AddChild(jobIcon);
}
var jobLabel = new Label()
{
Text = sensor.Job,
HorizontalExpand = true,
ClipText = true,
};
jobContainer.AddChild(jobLabel);
if (coordinates != null && NavMap.Visible && _blipTexture != null)
{
NavMap.TrackedEntities.TryAdd(sensor.SuitSensorUid,
new NavMapBlip
(CoordinatesToLocal(coordinates.Value),
_blipTexture,
(_trackedEntity == null || sensor.SuitSensorUid == _trackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray,
sensor.SuitSensorUid == _trackedEntity));
NavMap.Focus = _trackedEntity;
sensorButton.OnButtonUp += args =>
{
var prevTrackedEntity = _trackedEntity;
if (_trackedEntity == sensor.SuitSensorUid)
_trackedEntity = null;
else
{
_trackedEntity = sensor.SuitSensorUid;
NavMap.CenterToCoordinates(coordinates.Value);
}
NavMap.Focus = _trackedEntity;
UpdateSensorsTable(_trackedEntity, prevTrackedEntity);
};
}
}
}
private void SetTrackedEntityFromNavMap(NetEntity? netEntity)
{
var prevTrackedEntity = _trackedEntity;
_trackedEntity = netEntity;
if (_trackedEntity == prevTrackedEntity)
prevTrackedEntity = null;
NavMap.Focus = _trackedEntity;
_tryToScrollToListFocus = true;
UpdateSensorsTable(_trackedEntity, prevTrackedEntity);
}
private void UpdateSensorsTable(NetEntity? currTrackedEntity, NetEntity? prevTrackedEntity)
{
foreach (var sensor in SensorsTable.Children)
{
if (sensor is not CrewMonitoringButton)
continue;
var castSensor = (CrewMonitoringButton)sensor;
if (castSensor.SuitSensorUid == prevTrackedEntity)
castSensor.RemoveStyleClass(StyleClass.Positive);
else if (castSensor.SuitSensorUid == currTrackedEntity)
castSensor.AddStyleClass(StyleClass.Positive);
if (castSensor?.Coordinates == null)
continue;
if (NavMap.TrackedEntities.TryGetValue(castSensor.SuitSensorUid, out var data))
{
data = new NavMapBlip
(CoordinatesToLocal(data.Coordinates),
data.Texture,
(currTrackedEntity == null || castSensor.SuitSensorUid == currTrackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray,
castSensor.SuitSensorUid == currTrackedEntity);
NavMap.TrackedEntities[castSensor.SuitSensorUid] = data;
}
}
}
private void TryToScrollToFocus()
{
if (!_tryToScrollToListFocus)
return;
if (TryGetNextScrollPosition(out float? nextScrollPosition))
{
SensorScroller.VScrollTarget = nextScrollPosition.Value;
if (MathHelper.CloseToPercent(SensorScroller.VScroll, SensorScroller.VScrollTarget))
{
_tryToScrollToListFocus = false;
return;
}
}
}
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
{
nextScrollPosition = 0;
foreach (var sensor in SensorsTable.Children)
{
if (sensor is CrewMonitoringButton &&
((CrewMonitoringButton)sensor).SuitSensorUid == _trackedEntity)
return true;
nextScrollPosition += sensor.Height;
}
nextScrollPosition = null;
return false;
}
private EntityCoordinates CoordinatesToLocal(EntityCoordinates refCoords)
{
if (NavMap.MapUid != null)
return _transformSystem.WithEntityId(refCoords, (EntityUid)NavMap.MapUid);
else
return refCoords;
}
private void ClearOutDatedData()
{
SensorsTable.RemoveAllChildren();
NavMap.TrackedCoordinates.Clear();
NavMap.TrackedEntities.Clear();
NavMap.LocalizedNames.Clear();
}
public void UpdateCorpseAlertToggle(bool enabled)
{
CorpseAlertToggle.Pressed = enabled;
CorpseAlertToggle.Text = _loc.GetString(enabled ? "crew-monitoring-corpse-alert-on" : "crew-monitoring-corpse-alert-off");
CorpseAlertToggle.Label.FontColorOverride = enabled ? Color.LimeGreen : Color.Red;
CorpseAlertToggle.Disabled = false;
}
private void OnCorpseAlertTogglePressed(BaseButton.ButtonToggledEventArgs args)
{
CorpseAlertToggle.Pressed = args.Pressed;
CorpseAlertToggle.Disabled = true;
_boundUserInterface?.SendMessage(new CrewMonitoringToggleCorpseAlertMessage());
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_boundUserInterface = null;
}
}
}
public sealed class CrewMonitoringButton : Button
{
public int IndexInTable;
public NetEntity SuitSensorUid;
public EntityCoordinates? Coordinates;
}

View file

@ -82,7 +82,10 @@ public sealed partial class CrewMonitoringConsoleSystem : EntitySystem // Sunris
// Update all sensors info
var allSensors = component.ConnectedSensors.Values.ToList();
// Sunrise - Start
ApplyFilter(uid, ref allSensors);
var corpseAlertEnabled = TryComp(uid, out CrewMonitoringCorpseAlertComponent? alert) && alert.DoCorpseAlert;
_uiSystem.SetUiState(uid, CrewMonitoringUIKey.Key, new CrewMonitoringState(allSensors, corpseAlertEnabled));
// Sunrise - End

View file

@ -0,0 +1,84 @@
using Content.Shared.Implants.Components;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Medical.SuitSensor;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
namespace Content.Server.Medical.CrewMonitoring;
public sealed partial class CrewMonitoringConsoleSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private void ApplyFilter(EntityUid uid, ref List<SuitSensorStatus> sensors)
{
if (!TryComp(uid, out CrewMonitoringFilterComponent? filter))
return;
var showOnlyWoundedOrDead = filter.OnlyShowWoundedOrDead;
var filterByDepartment = filter.AllowedDepartmentIds.Count > 0;
if (!showOnlyWoundedOrDead && !filterByDepartment)
return;
HashSet<string>? allowedDepartmentNames = null;
if (filterByDepartment)
allowedDepartmentNames = BuildAllowedDepartmentNameSet(filter.AllowedDepartmentIds);
var includeTrackers = filter.IncludeTrackers;
var filteredSensors = new List<SuitSensorStatus>(sensors.Count);
foreach (var sensor in sensors)
{
if (showOnlyWoundedOrDead && !IsWoundedOrDead(sensor))
continue;
if (allowedDepartmentNames != null)
{
if (!IsInAllowedDepartments(sensor, allowedDepartmentNames, includeTrackers))
continue;
}
filteredSensors.Add(sensor);
}
sensors = filteredSensors;
}
private HashSet<string> BuildAllowedDepartmentNameSet(List<string> departmentIds)
{
var allowedDepartments = new HashSet<string>();
foreach (var departmentId in departmentIds)
{
if (_prototypeManager.TryIndex<DepartmentPrototype>(departmentId, out var department))
allowedDepartments.Add(Loc.GetString(department.Name));
else
allowedDepartments.Add(departmentId);
}
return allowedDepartments;
}
private bool IsWoundedOrDead(SuitSensorStatus sensor)
{
if (!sensor.IsAlive)
return true;
return sensor.DamagePercentage is >= CriticalDamagePercentage;
}
private bool IsInAllowedDepartments(SuitSensorStatus sensor, HashSet<string> allowedDepartmentNames, bool includeTrackers)
{
foreach (var department in sensor.JobDepartments)
{
if (allowedDepartmentNames.Contains(department))
return true;
}
if (!includeTrackers)
return false;
var sensorEntity = GetEntity(sensor.SuitSensorUid);
return HasComp<SubdermalImplantComponent>(sensorEntity);
}
}

View file

@ -0,0 +1,22 @@
namespace Content.Shared.Medical.CrewMonitoring;
[RegisterComponent]
public sealed partial class CrewMonitoringFilterComponent : Component
{
/// <summary>
/// Разрешенные отделы. Если пустое все доступны
/// </summary>
[DataField]
public List<string> AllowedDepartmentIds = new();
/// <summary>
/// Будут ли отображаться по трекерам
/// </summary>
[DataField]
public bool IncludeTrackers;
/// <summary>
/// Показывать ли мертвых, в крите, в ужасном
/// </summary>
[DataField]
public bool OnlyShowWoundedOrDead;
}

View file

@ -0,0 +1,5 @@
ent-HandheldEmergencyCrewMonitor = PulseGuard™ XR
.desc = A hand-held crew monitor displaying the status of suit sensors of injured crew.
ent-HandheldEmergencyCrewMonitorEmpty = { ent-HandheldEmergencyCrewMonitor }
.suffix = Empty
.desc = { ent-HandheldEmergencyCrewMonitor.desc }

View file

@ -1,6 +1,7 @@
crew-monitoring-corpse-alert = Alert signal:
crew-monitoring-corpse-alert-on = ON
crew-monitoring-corpse-alert-off = OFF
crew-monitoring-ui-no-sensors-label = Server found, no matching sensors
item-toggle-deactivate-alert = Deactivate alert
item-toggle-activate-alert = Activate alert

View file

@ -1,5 +1,5 @@
ent-HandheldBSOCrewMonitor = CommandFriend™ X-02
.desc = Не отслеживает уровень компетентности командного состава.
ent-HandheldBSOCrewMonitor = Команд-Друг™ X-02
.desc = Не отслеживает уровень компетентности командного состава. Показывает только командный состав.
ent-HandheldBSOCrewMonitorEmpty = { ent-HandheldBSOCrewMonitor }
.suffix = Пустой
.desc = { ent-HandheldBSOCrewMonitor.desc }

View file

@ -0,0 +1,5 @@
ent-HandheldEmergencyCrewMonitor = Пульс-Гард™ XR
.desc = Ручной монитор экипажа, отображающий состояние датчиков скафандра раненых членов экипажа.
ent-HandheldEmergencyCrewMonitorEmpty = { ent-HandheldEmergencyCrewMonitor }
.suffix = Пустой
.desc = { ent-HandheldEmergencyCrewMonitor.desc }

View file

@ -1,6 +1,8 @@
crew-monitoring-corpse-alert = Сигнал тревоги:
crew-monitoring-corpse-alert-on = ВКЛ
crew-monitoring-corpse-alert-off = ВЫКЛ
crew-monitoring-ui-no-server-label = Сервер не найден
crew-monitoring-ui-no-sensors-label = Сервер найден, подходящих датчиков нет
item-toggle-deactivate-alert = Деактивировать тревогу
item-toggle-activate-alert = Активировать тревогу

View file

@ -26,7 +26,7 @@
storage:
back:
- EmergencyRollerBedSpawnFolded
- HandheldCrewMonitor # Sunrise-Edit
- HandheldEmergencyCrewMonitor # Sunrise - edit
- type: chameleonOutfit
id: ParamedicChameleonOutfit

View file

@ -8,15 +8,18 @@
tags:
- BrigmedicBeltEquip
- type: Sprite
sprite: _Starlight/Objects/Specific/Medical/handheld_brigmedic_crewmonitor.rsi
sprite: _Sunrise/Objects/Specific/Medical/handheld_brigmedic_crewmonitor.rsi
state: scanner
- type: ActivatableUI
key: enum.CrewMonitoringUIKey.Key
- type: UserInterface
interfaces:
enum.CrewMonitoringUIKey.Key:
type: BrigmedicCrewMonitoringBoundUserInterface
type: SunriseCrewMonitoringBoundUserInterface
- type: CrewMonitoringConsole
- type: CrewMonitoringFilter
allowedDepartmentIds:
- Security
- type: DeviceNetwork
deviceNetId: Wireless
receiveFrequencyId: CrewMonitor

View file

@ -12,8 +12,12 @@
- type: UserInterface
interfaces:
enum.CrewMonitoringUIKey.Key:
type: BSOCrewMonitoringBoundUserInterface
type: SunriseCrewMonitoringBoundUserInterface
- type: CrewMonitoringConsole
- type: CrewMonitoringFilter
allowedDepartmentIds:
- Command
includeTrackers: true
- type: DeviceNetwork
deviceNetId: Wireless
receiveFrequencyId: CrewMonitor

View file

@ -0,0 +1,39 @@
- type: entity
name: PulseGuard™ XR
categories: [ DoNotMap ]
parent: [ BaseHandheldComputer ]
id: HandheldEmergencyCrewMonitor
description: A hand-held crew monitor displaying the status of suit sensors of injured crew.
components:
- type: Item
heldPrefix: scanner
- type: Sprite
sprite: _Sunrise/Objects/Specific/Medical/handheld_emergency_crewmonitor.rsi
state: scanner
- type: ActivatableUI
key: enum.CrewMonitoringUIKey.Key
- type: UserInterface
interfaces:
enum.CrewMonitoringUIKey.Key:
type: SunriseCrewMonitoringBoundUserInterface
- type: CrewMonitoringConsole
- type: CrewMonitoringFilter
onlyShowWoundedOrDead: true
- type: DeviceNetwork
deviceNetId: Wireless
receiveFrequencyId: CrewMonitor
- type: WirelessNetworkConnection
range: 500
- type: StationLimitedNetwork
- type: StaticPrice
price: 500
- type: entity
id: HandheldEmergencyCrewMonitorEmpty
parent: HandheldEmergencyCrewMonitor
suffix: Empty
components:
- type: ItemSlots
slots:
cell_slot:
name: power-cell-slot-component-slot-name-default

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

View file

@ -0,0 +1,33 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation https://github.com/tgstation/tgstation/commit/ab4abf318f293a701754656dd4e9261eb70f8824#diff-9ab5c8a5e47ab7cfaeadd859a23e32b05de1fe839e99ea767fd7e340b6385d67, in-hands modified by SeamLesss (github) from Objects/Misc/qm_clipboard.rsi/inhand-(left/right) respritet by seraphimttt (discord)",
"states": [
{
"name": "scanner",
"directions": 1,
"delays": [
[
0.4,
0.4
]
]
},
{
"name": "scanner-inhand-left",
"directions": 4
},
{
"name": "scanner-inhand-right",
"directions": 4
},
{
"name": "icon",
"directions": 1
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B