Content update for NetEntities (#18935)

This commit is contained in:
metalgearsloth
2023-09-11 09:42:41 +10:00
committed by GitHub
parent 389c8d1a2c
commit 5a0fc68be2
526 changed files with 3058 additions and 2215 deletions

View File

@@ -38,7 +38,7 @@ public sealed class RadarConsoleBoundUserInterface : BoundUserInterface
base.UpdateState(state);
if (state is not RadarConsoleBoundInterfaceState cState) return;
_window?.SetMatrix(cState.Coordinates, cState.Angle);
_window?.SetMatrix(EntMan.GetCoordinates(cState.Coordinates), cState.Angle);
_window?.UpdateState(cState);
}
}

View File

@@ -28,7 +28,7 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
_window.OnClose += OnClose;
}
private void OnDestinationPressed(EntityUid obj)
private void OnDestinationPressed(NetEntity obj)
{
SendMessage(new ShuttleConsoleFTLRequestMessage()
{
@@ -51,17 +51,17 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
}
}
private void OnStopAutodockPressed(EntityUid obj)
private void OnStopAutodockPressed(NetEntity obj)
{
SendMessage(new StopAutodockRequestMessage() { DockEntity = obj });
}
private void OnAutodockPressed(EntityUid obj)
private void OnAutodockPressed(NetEntity obj)
{
SendMessage(new AutodockRequestMessage() { DockEntity = obj });
}
private void OnUndockPressed(EntityUid obj)
private void OnUndockPressed(NetEntity obj)
{
SendMessage(new UndockRequestMessage() { DockEntity = obj });
}
@@ -71,7 +71,7 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
base.UpdateState(state);
if (state is not ShuttleConsoleBoundInterfaceState cState) return;
_window?.SetMatrix(cState.Coordinates, cState.Angle);
_window?.SetMatrix(EntMan.GetCoordinates(cState.Coordinates), cState.Angle);
_window?.UpdateState(cState);
}
}

View File

@@ -44,8 +44,9 @@ namespace Content.Client.Shuttles.Systems
{
if (args.Current is not PilotComponentState state) return;
var console = state.Console.GetValueOrDefault();
if (!console.IsValid())
var console = EnsureEntity<PilotComponent>(state.Console, uid);
if (console == null)
{
component.Console = null;
_input.Contexts.SetActiveContext("human");

View File

@@ -47,7 +47,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
{
if (_overlay == null) return;
_overlay.StationUid = ev.StationUid;
_overlay.StationUid = GetEntity(ev.StationUid);
_overlay.Position = ev.Position;
}
}

View File

@@ -32,7 +32,7 @@ public class DockingControl : Control
private int ScaledMinimapRadius => (int) (MapGridControl.UIDisplayRadius * UIScale);
private float MinimapScale => _range != 0 ? ScaledMinimapRadius / _range : 0f;
public EntityUid? ViewedDock;
public NetEntity? ViewedDock;
public EntityUid? GridEntity;
public EntityCoordinates? Coordinates;
@@ -41,7 +41,7 @@ public class DockingControl : Control
/// <summary>
/// Stored by GridID then by docks
/// </summary>
public Dictionary<EntityUid, List<DockingInterfaceState>> Docks = new();
public Dictionary<NetEntity, List<DockingInterfaceState>> Docks = new();
public DockingControl()
{
@@ -204,7 +204,7 @@ public class DockingControl : Control
}
// Draw any docks on that grid
if (Docks.TryGetValue(grid.Owner, out var gridDocks))
if (Docks.TryGetValue(_entManager.GetNetEntity(grid.Owner), out var gridDocks))
{
foreach (var dock in gridDocks)
{

View File

@@ -124,7 +124,7 @@ public sealed class RadarControl : MapGridControl
foreach (var state in ls.Docks)
{
var coordinates = state.Coordinates;
var grid = _docks.GetOrNew(coordinates.EntityId);
var grid = _docks.GetOrNew(_entManager.GetEntity(coordinates.NetEntity));
grid.Add(state);
}
}
@@ -324,7 +324,7 @@ public sealed class RadarControl : MapGridControl
{
foreach (var state in docks)
{
var ent = state.Entity;
var ent = _entManager.GetEntity(state.Entity);
var position = state.Coordinates.Position;
var uiPosition = matrix.Transform(position);

View File

@@ -22,7 +22,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
private readonly IEntityManager _entManager;
private readonly IGameTiming _timing;
private EntityUid? _shuttleUid;
private EntityUid? _shuttleEntity;
/// <summary>
/// Currently selected dock button for camera.
@@ -32,19 +32,19 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
/// <summary>
/// Stored by grid entityid then by states
/// </summary>
private readonly Dictionary<EntityUid, List<DockingInterfaceState>> _docks = new();
private readonly Dictionary<NetEntity, List<DockingInterfaceState>> _docks = new();
private readonly Dictionary<BaseButton, EntityUid> _destinations = new();
private readonly Dictionary<BaseButton, NetEntity> _destinations = new();
/// <summary>
/// Next FTL state change.
/// </summary>
public TimeSpan FTLTime;
public Action<EntityUid>? UndockPressed;
public Action<EntityUid>? StartAutodockPressed;
public Action<EntityUid>? StopAutodockPressed;
public Action<EntityUid>? DestinationPressed;
public Action<NetEntity>? UndockPressed;
public Action<NetEntity>? StartAutodockPressed;
public Action<NetEntity>? StopAutodockPressed;
public Action<NetEntity>? DestinationPressed;
public ShuttleConsoleWindow()
{
@@ -89,7 +89,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
public void SetMatrix(EntityCoordinates? coordinates, Angle? angle)
{
_shuttleUid = coordinates?.EntityId;
_shuttleEntity = coordinates?.EntityId;
RadarScreen.SetMatrix(coordinates, angle);
}
@@ -101,7 +101,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
MaxRadarRange.Text = $"{scc.MaxRange:0}";
}
private void UpdateFTL(List<(EntityUid Entity, string Destination, bool Enabled)> destinations, FTLState state, TimeSpan time)
private void UpdateFTL(List<(NetEntity Entity, string Destination, bool Enabled)> destinations, FTLState state, TimeSpan time)
{
HyperspaceDestinations.DisposeAllChildren();
_destinations.Clear();
@@ -183,14 +183,15 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
foreach (var dock in docks)
{
var grid = _docks.GetOrNew(dock.Coordinates.EntityId);
var grid = _docks.GetOrNew(dock.Coordinates.NetEntity);
grid.Add(dock);
}
DockPorts.DisposeAllChildren();
DockingScreen.Docks = _docks;
var shuttleNetEntity = _entManager.GetNetEntity(_shuttleEntity);
if (_shuttleUid != null && _docks.TryGetValue(_shuttleUid.Value, out var gridDocks))
if (shuttleNetEntity != null && _docks.TryGetValue(shuttleNetEntity.Value, out var gridDocks))
{
var index = 1;
@@ -233,7 +234,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
private void OnDockMouseEntered(GUIMouseHoverEventArgs obj, DockingInterfaceState state)
{
RadarScreen.HighlightedDock = state.Entity;
RadarScreen.HighlightedDock = _entManager.GetEntity(state.Entity);
}
private void OnDockMouseExited(GUIMouseHoverEventArgs obj, DockingInterfaceState state)
@@ -246,8 +247,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
/// </summary>
private void OnDockToggled(BaseButton.ButtonEventArgs obj, DockingInterfaceState state)
{
var ent = state.Entity;
if (_selectedDock != null)
{
// If it got untoggled via other means then we'll stop viewing the old dock.
@@ -274,9 +273,9 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
}
else
{
if (_shuttleUid != null)
if (_shuttleEntity != null)
{
DockingScreen.Coordinates = state.Coordinates;
DockingScreen.Coordinates = _entManager.GetCoordinates(state.Coordinates);
DockingScreen.Angle = state.Angle;
}
else
@@ -288,9 +287,9 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
UndockButton.Disabled = false;
RadarScreen.Visible = false;
DockingScreen.Visible = true;
DockingScreen.ViewedDock = ent;
StartAutodockPressed?.Invoke(ent);
DockingScreen.GridEntity = _shuttleUid;
DockingScreen.ViewedDock = state.Entity;
StartAutodockPressed?.Invoke(state.Entity);
DockingScreen.GridEntity = _shuttleEntity;
_selectedDock = obj.Button;
}
}
@@ -310,13 +309,13 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
{
base.Draw(handle);
if (!_entManager.TryGetComponent<PhysicsComponent>(_shuttleUid, out var gridBody) ||
!_entManager.TryGetComponent<TransformComponent>(_shuttleUid, out var gridXform))
if (!_entManager.TryGetComponent<PhysicsComponent>(_shuttleEntity, out var gridBody) ||
!_entManager.TryGetComponent<TransformComponent>(_shuttleEntity, out var gridXform))
{
return;
}
if (_entManager.TryGetComponent<MetaDataComponent>(_shuttleUid, out var metadata) && metadata.EntityPaused)
if (_entManager.TryGetComponent<MetaDataComponent>(_shuttleEntity, out var metadata) && metadata.EntityPaused)
{
FTLTime += _timing.FrameTime;
}