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

@@ -53,22 +53,24 @@ public abstract partial class InteractionTest
/// Target coordinates. Note that this does not necessarily correspond to the position of the <see cref="Target"/>
/// entity.
/// </summary>
protected EntityCoordinates TargetCoords;
protected NetCoordinates TargetCoords;
/// <summary>
/// Initial player coordinates. Note that this does not necessarily correspond to the position of the
/// <see cref="Player"/> entity.
/// </summary>
protected EntityCoordinates PlayerCoords;
protected NetCoordinates PlayerCoords;
/// <summary>
/// The player entity that performs all these interactions. Defaults to an admin-observer with 1 hand.
/// </summary>
protected EntityUid Player;
protected NetEntity Player;
protected ICommonSession ClientSession = default!;
protected IPlayerSession ServerSession = default!;
public EntityUid? ClientTarget;
/// <summary>
/// The current target entity. This is the default entity for various helper functions.
/// </summary>
@@ -77,7 +79,7 @@ public abstract partial class InteractionTest
/// interactions often swap out entities, and there are helper methods that attempt to automatically upddate
/// the target entity. See <see cref="CheckTargetChange"/>
/// </remarks>
protected EntityUid? Target;
protected NetEntity? Target;
/// <summary>
/// When attempting to start construction, this is the client-side ID of the construction ghost.
@@ -174,8 +176,8 @@ public abstract partial class InteractionTest
// Setup map.
await Pair.CreateTestMap();
PlayerCoords = MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan);
TargetCoords = MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan);
PlayerCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan));
TargetCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan));
await SetTile(Plating, grid: MapData.MapGrid);
// Get player data
@@ -195,15 +197,16 @@ public abstract partial class InteractionTest
SEntMan.System<SharedMindSystem>().WipeMind(ServerSession.ContentData()?.Mind);
old = cPlayerMan.LocalPlayer.ControlledEntity;
Player = SEntMan.SpawnEntity(PlayerPrototype, PlayerCoords);
Actor.Attach(Player, ServerSession);
Hands = SEntMan.GetComponent<HandsComponent>(Player);
DoAfters = SEntMan.GetComponent<DoAfterComponent>(Player);
Player = SEntMan.GetNetEntity(SEntMan.SpawnEntity(PlayerPrototype, SEntMan.GetCoordinates(PlayerCoords)));
var serverPlayerEnt = SEntMan.GetEntity(Player);
Actor.Attach(serverPlayerEnt, ServerSession);
Hands = SEntMan.GetComponent<HandsComponent>(serverPlayerEnt);
DoAfters = SEntMan.GetComponent<DoAfterComponent>(serverPlayerEnt);
});
// Check player got attached.
await RunTicks(5);
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(Player));
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalPlayer.ControlledEntity), Is.EqualTo(Player));
// Delete old player entity.
await Server.WaitPost(() =>
@@ -216,7 +219,7 @@ public abstract partial class InteractionTest
await Server.WaitPost(() =>
{
var bodySystem = SEntMan.System<BodySystem>();
var hands = bodySystem.GetBodyChildrenOfType(Player, BodyPartType.Hand).ToArray();
var hands = bodySystem.GetBodyChildrenOfType(SEntMan.GetEntity(Player), BodyPartType.Hand).ToArray();
for (var i = 1; i < hands.Length; i++)
{
@@ -229,8 +232,8 @@ public abstract partial class InteractionTest
await Pair.ReallyBeIdle(5);
Assert.Multiple(() =>
{
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(Player));
Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(Player));
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalPlayer.ControlledEntity), Is.EqualTo(Player));
Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(SEntMan.GetEntity(Player)));
});
}