mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 16:47:26 +00:00
* cleanup * fix fixtures * prediction * fix test * review * fix svalinn visuals * fix chargers * fix portable recharger and its unlit visuals * fix borgs * oomba review * fix examination prediction * predict holosign
93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
#nullable enable
|
|
using System.Numerics;
|
|
using Content.IntegrationTests.Tests.Interaction;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.IntegrationTests.Tests.Movement;
|
|
|
|
/// <summary>
|
|
/// This is a variation of <see cref="InteractionTest"/> that sets up the player with a normal human entity and a simple
|
|
/// linear grid with gravity and an atmosphere. It is intended to make it easier to test interactions that involve
|
|
/// walking (e.g., slipping or climbing tables).
|
|
/// </summary>
|
|
public abstract class MovementTest : InteractionTest
|
|
{
|
|
protected override string PlayerPrototype => "MobHuman";
|
|
protected static readonly EntProtoId WallPrototype = "WallSolid";
|
|
|
|
/// <summary>
|
|
/// Number of tiles to add either side of the player.
|
|
/// </summary>
|
|
protected virtual int Tiles => 3;
|
|
|
|
/// <summary>
|
|
/// If true, the tiles at the ends of the grid will have a wall placed on them to avoid players moving off grid.
|
|
/// </summary>
|
|
protected virtual bool AddWalls => true;
|
|
|
|
/// <summary>
|
|
/// The wall entity on the left side.
|
|
/// </summary>
|
|
protected NetEntity? WallLeft;
|
|
/// <summary>
|
|
/// The wall entity on the right side.
|
|
/// </summary>
|
|
protected NetEntity? WallRight;
|
|
|
|
[SetUp]
|
|
public override async Task Setup()
|
|
{
|
|
await base.Setup();
|
|
var pCoords = SEntMan.GetCoordinates(PlayerCoords);
|
|
|
|
for (var i = -Tiles; i <= Tiles; i++)
|
|
{
|
|
await SetTile(Plating, SEntMan.GetNetCoordinates(pCoords.Offset(new Vector2(i, 0))), MapData.Grid);
|
|
}
|
|
AssertGridCount(1);
|
|
|
|
if (AddWalls)
|
|
{
|
|
var sWallLeft = await SpawnEntity(WallPrototype, pCoords.Offset(new Vector2(-Tiles, 0)));
|
|
var sWallRight = await SpawnEntity(WallPrototype, pCoords.Offset(new Vector2(Tiles, 0)));
|
|
|
|
WallLeft = SEntMan.GetNetEntity(sWallLeft);
|
|
WallRight = SEntMan.GetNetEntity(sWallRight);
|
|
}
|
|
|
|
await AddGravity();
|
|
await AddAtmosphere();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the relative horizontal between two entities. Defaults to using the target & player entity.
|
|
/// </summary>
|
|
protected float Delta(NetEntity? target = null, NetEntity? other = null)
|
|
{
|
|
target ??= Target;
|
|
if (target == null)
|
|
{
|
|
Assert.Fail("No target specified");
|
|
return 0;
|
|
}
|
|
|
|
var delta = Transform.GetWorldPosition(SEntMan.GetEntity(target.Value)) - Transform.GetWorldPosition(SEntMan.GetEntity(other ?? Player));
|
|
return delta.X;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the relative horizontal between a set of coordinates and an entity. Defaults to using the target coordinates and the player entity.
|
|
/// </summary>
|
|
protected float DeltaCoordinates(NetCoordinates? coords = null, NetEntity? other = null)
|
|
{
|
|
other ??= Player;
|
|
coords ??= TargetCoords;
|
|
|
|
var delta = Transform.ToWorldPosition(ToServer(coords.Value)) - Transform.GetWorldPosition(ToServer(other.Value));
|
|
return delta.X;
|
|
}
|
|
}
|
|
|