Content update for NetEntities (#18935)
This commit is contained in:
@@ -65,7 +65,7 @@ public sealed partial class DockingSystem
|
||||
if ((worldPos - otherWorldPos).Length() < comp.Radius)
|
||||
continue;
|
||||
|
||||
_sawmill.Debug($"Removed RecentlyDocked from {ToPrettyString(uid)} and {ToPrettyString(comp.LastDocked)}");
|
||||
Log.Debug($"Removed RecentlyDocked from {ToPrettyString(uid)} and {ToPrettyString(comp.LastDocked)}");
|
||||
RemComp<RecentlyDockedComponent>(uid);
|
||||
RemComp<RecentlyDockedComponent>(comp.LastDocked);
|
||||
}
|
||||
@@ -73,48 +73,52 @@ public sealed partial class DockingSystem
|
||||
|
||||
private void OnRequestUndock(EntityUid uid, ShuttleConsoleComponent component, UndockRequestMessage args)
|
||||
{
|
||||
_sawmill.Debug($"Received undock request for {ToPrettyString(args.DockEntity)}");
|
||||
var dork = GetEntity(args.DockEntity);
|
||||
|
||||
Log.Debug($"Received undock request for {ToPrettyString(dork)}");
|
||||
|
||||
// TODO: Validation
|
||||
if (!TryComp<DockingComponent>(args.DockEntity, out var dock) ||
|
||||
if (!TryComp<DockingComponent>(dork, out var dock) ||
|
||||
!dock.Docked ||
|
||||
HasComp<PreventPilotComponent>(Transform(uid).GridUid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Undock(args.DockEntity, dock);
|
||||
Undock(dork, dock);
|
||||
}
|
||||
|
||||
private void OnRequestAutodock(EntityUid uid, ShuttleConsoleComponent component, AutodockRequestMessage args)
|
||||
{
|
||||
_sawmill.Debug($"Received autodock request for {ToPrettyString(args.DockEntity)}");
|
||||
var dork = GetEntity(args.DockEntity);
|
||||
Log.Debug($"Received autodock request for {ToPrettyString(dork)}");
|
||||
var player = args.Session.AttachedEntity;
|
||||
|
||||
if (player == null ||
|
||||
!HasComp<DockingComponent>(args.DockEntity) ||
|
||||
!HasComp<DockingComponent>(dork) ||
|
||||
HasComp<PreventPilotComponent>(Transform(uid).GridUid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Validation
|
||||
var comp = EnsureComp<AutoDockComponent>(args.DockEntity);
|
||||
var comp = EnsureComp<AutoDockComponent>(dork);
|
||||
comp.Requesters.Add(player.Value);
|
||||
}
|
||||
|
||||
private void OnRequestStopAutodock(EntityUid uid, ShuttleConsoleComponent component, StopAutodockRequestMessage args)
|
||||
{
|
||||
_sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.DockEntity)}");
|
||||
var dork = GetEntity(args.DockEntity);
|
||||
Log.Debug($"Received stop autodock request for {ToPrettyString(dork)}");
|
||||
|
||||
var player = args.Session.AttachedEntity;
|
||||
|
||||
// TODO: Validation
|
||||
if (player == null || !TryComp<AutoDockComponent>(args.DockEntity, out var comp)) return;
|
||||
if (player == null || !TryComp<AutoDockComponent>(dork, out var comp)) return;
|
||||
|
||||
comp.Requesters.Remove(player.Value);
|
||||
|
||||
if (comp.Requesters.Count == 0)
|
||||
RemComp<AutoDockComponent>(args.DockEntity);
|
||||
RemComp<AutoDockComponent>(dork);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
private const string DockingFixture = "docking";
|
||||
private const string DockingJoint = "docking";
|
||||
private const float DockingRadius = 0.20f;
|
||||
@@ -36,7 +35,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_sawmill = Logger.GetSawmill("docking");
|
||||
SubscribeLocalEvent<DockingComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<DockingComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<DockingComponent, AnchorStateChangedEvent>(OnAnchorChange);
|
||||
@@ -114,7 +112,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
if (otherDockingFixture == null)
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
_sawmill.Error($"Found null docking fixture on {ent}");
|
||||
Log.Error($"Found null docking fixture on {ent}");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -159,7 +157,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
!TryComp(dockBUid, out DockingComponent? dockB))
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
_sawmill.Error($"Tried to cleanup {dockAUid} but not docked?");
|
||||
Log.Error($"Tried to cleanup {dockAUid} but not docked?");
|
||||
|
||||
dockA.DockedWith = null;
|
||||
if (dockA.DockJoint != null)
|
||||
@@ -288,7 +286,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
(dockAUid, dockBUid) = (dockBUid, dockAUid);
|
||||
}
|
||||
|
||||
_sawmill.Debug($"Docking between {dockAUid} and {dockBUid}");
|
||||
Log.Debug($"Docking between {dockAUid} and {dockBUid}");
|
||||
|
||||
// https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ public sealed partial class EmergencyShuttleSystem
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, EmergencyConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(
|
||||
_uiSystem.SetUiState(
|
||||
bui,
|
||||
new EmergencyConsoleBoundUserInterfaceState()
|
||||
{
|
||||
|
||||
@@ -165,7 +165,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
|
||||
|
||||
RaiseNetworkEvent(new EmergencyShuttlePositionMessage()
|
||||
{
|
||||
StationUid = targetGrid,
|
||||
StationUid = GetNetEntity(targetGrid),
|
||||
Position = config.Area,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, RadarConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState(
|
||||
_uiSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState(
|
||||
component.MaxRange,
|
||||
coordinates,
|
||||
GetNetCoordinates(coordinates),
|
||||
angle,
|
||||
new List<DockingInterfaceState>()
|
||||
));
|
||||
|
||||
@@ -74,7 +74,9 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
private void OnDestinationMessage(EntityUid uid, ShuttleConsoleComponent component,
|
||||
ShuttleConsoleFTLRequestMessage args)
|
||||
{
|
||||
if (!TryComp<FTLDestinationComponent>(args.Destination, out var dest))
|
||||
var destination = GetEntity(args.Destination);
|
||||
|
||||
if (!TryComp<FTLDestinationComponent>(destination, out var dest))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -118,14 +120,14 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var dock = HasComp<MapComponent>(args.Destination) && HasComp<MapGridComponent>(args.Destination);
|
||||
var dock = HasComp<MapComponent>(destination) && HasComp<MapGridComponent>(destination);
|
||||
var tagEv = new FTLTagEvent();
|
||||
RaiseLocalEvent(xform.GridUid.Value, ref tagEv);
|
||||
|
||||
var ev = new ShuttleConsoleFTLTravelStartEvent(uid);
|
||||
RaiseLocalEvent(ref ev);
|
||||
|
||||
_shuttle.FTLTravel(xform.GridUid.Value, shuttle, args.Destination, dock: dock, priorityTag: tagEv.Tag);
|
||||
_shuttle.FTLTravel(xform.GridUid.Value, shuttle, destination, dock: dock, priorityTag: tagEv.Tag);
|
||||
}
|
||||
|
||||
private void OnDock(DockEvent ev)
|
||||
@@ -225,7 +227,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
|
||||
private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new PilotComponentState(component.Console);
|
||||
args.State = new PilotComponentState(GetNetEntity(component.Console));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -244,9 +246,9 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
|
||||
var state = new DockingInterfaceState()
|
||||
{
|
||||
Coordinates = xform.Coordinates,
|
||||
Coordinates = GetNetCoordinates(xform.Coordinates),
|
||||
Angle = xform.LocalRotation,
|
||||
Entity = uid,
|
||||
Entity = GetNetEntity(uid),
|
||||
Connected = comp.Docked,
|
||||
Color = comp.RadarColor,
|
||||
HighlightedColor = comp.HighlightedRadarColor,
|
||||
@@ -275,7 +277,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
|
||||
var shuttleGridUid = consoleXform?.GridUid;
|
||||
|
||||
var destinations = new List<(EntityUid, string, bool)>();
|
||||
var destinations = new List<(NetEntity, string, bool)>();
|
||||
var ftlState = FTLState.Available;
|
||||
var ftlTime = TimeSpan.Zero;
|
||||
|
||||
@@ -324,22 +326,24 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
canTravel = false;
|
||||
}
|
||||
|
||||
destinations.Add((destUid, name, canTravel));
|
||||
destinations.Add((GetNetEntity(destUid), name, canTravel));
|
||||
}
|
||||
}
|
||||
|
||||
docks ??= GetAllDocks();
|
||||
|
||||
if (_ui.TryGetUi(consoleUid, ShuttleConsoleUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new ShuttleConsoleBoundInterfaceState(
|
||||
{
|
||||
_ui.SetUiState(bui, new ShuttleConsoleBoundInterfaceState(
|
||||
ftlState,
|
||||
ftlTime,
|
||||
destinations,
|
||||
range,
|
||||
consoleXform?.Coordinates,
|
||||
GetNetCoordinates(consoleXform?.Coordinates),
|
||||
consoleXform?.LocalRotation,
|
||||
docks
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
|
||||
Reference in New Issue
Block a user