* Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
159 lines
6.5 KiB
C#
159 lines
6.5 KiB
C#
using System.Threading.Tasks;
|
|
using Content.Client.Interactable;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Interaction.Helpers;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Content.IntegrationTests.Tests.Interaction
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(SharedInteractionSystem))]
|
|
[TestOf(typeof(SharedUnobstructedExtensions))]
|
|
[TestOf(typeof(UnobstructedExtensions))]
|
|
public class InRangeUnobstructed : ContentIntegrationTest
|
|
{
|
|
private const string HumanId = "BaseHumanMob_Content";
|
|
|
|
private const float InteractionRange = SharedInteractionSystem.InteractionRange;
|
|
|
|
private const float InteractionRangeDivided15 = InteractionRange / 1.5f;
|
|
|
|
private readonly (float, float) _interactionRangeDivided15X = (InteractionRangeDivided15, 0f);
|
|
|
|
private const float InteractionRangeDivided15Times3 = InteractionRangeDivided15 * 3;
|
|
|
|
[Test]
|
|
public async Task EntityEntityTest()
|
|
{
|
|
var server = StartServerDummyTicker();
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
var mapManager = server.ResolveDependency<IMapManager>();
|
|
|
|
IEntity origin = null;
|
|
IEntity other = null;
|
|
IContainer container = null;
|
|
IComponent component = null;
|
|
EntityCoordinates entityCoordinates = default;
|
|
MapCoordinates mapCoordinates = default;
|
|
|
|
server.Assert(() =>
|
|
{
|
|
var mapId = mapManager.CreateMap();
|
|
var coordinates = new MapCoordinates(Vector2.Zero, mapId);
|
|
|
|
origin = entityManager.SpawnEntity(HumanId, coordinates);
|
|
other = entityManager.SpawnEntity(HumanId, coordinates);
|
|
container = ContainerHelpers.EnsureContainer<Container>(other, "InRangeUnobstructedTestOtherContainer");
|
|
component = other.Transform;
|
|
entityCoordinates = other.Transform.Coordinates;
|
|
mapCoordinates = other.Transform.MapPosition;
|
|
});
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
server.Assert(() =>
|
|
{
|
|
// Entity <-> Entity
|
|
Assert.True(origin.InRangeUnobstructed(other));
|
|
Assert.True(other.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> Component
|
|
Assert.True(origin.InRangeUnobstructed(component));
|
|
Assert.True(component.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> Container
|
|
Assert.True(origin.InRangeUnobstructed(container));
|
|
Assert.True(container.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> EntityCoordinates
|
|
Assert.True(origin.InRangeUnobstructed(entityCoordinates));
|
|
Assert.True(entityCoordinates.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> MapCoordinates
|
|
Assert.True(origin.InRangeUnobstructed(mapCoordinates));
|
|
Assert.True(mapCoordinates.InRangeUnobstructed(origin));
|
|
|
|
|
|
// Move them slightly apart
|
|
origin.Transform.LocalPosition += _interactionRangeDivided15X;
|
|
|
|
// Entity <-> Entity
|
|
Assert.True(origin.InRangeUnobstructed(other));
|
|
Assert.True(other.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> Component
|
|
Assert.True(origin.InRangeUnobstructed(component));
|
|
Assert.True(component.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> Container
|
|
Assert.True(origin.InRangeUnobstructed(container));
|
|
Assert.True(container.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> EntityCoordinates
|
|
Assert.True(origin.InRangeUnobstructed(entityCoordinates));
|
|
Assert.True(entityCoordinates.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> MapCoordinates
|
|
Assert.True(origin.InRangeUnobstructed(mapCoordinates));
|
|
Assert.True(mapCoordinates.InRangeUnobstructed(origin));
|
|
|
|
|
|
// Move them out of range
|
|
origin.Transform.LocalPosition += _interactionRangeDivided15X;
|
|
|
|
// Entity <-> Entity
|
|
Assert.False(origin.InRangeUnobstructed(other));
|
|
Assert.False(other.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> Component
|
|
Assert.False(origin.InRangeUnobstructed(component));
|
|
Assert.False(component.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> Container
|
|
Assert.False(origin.InRangeUnobstructed(container));
|
|
Assert.False(container.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> EntityCoordinates
|
|
Assert.False(origin.InRangeUnobstructed(entityCoordinates));
|
|
Assert.False(entityCoordinates.InRangeUnobstructed(origin));
|
|
|
|
// Entity <-> MapCoordinates
|
|
Assert.False(origin.InRangeUnobstructed(mapCoordinates));
|
|
Assert.False(mapCoordinates.InRangeUnobstructed(origin));
|
|
|
|
|
|
// Checks with increased range
|
|
|
|
// Entity <-> Entity
|
|
Assert.True(origin.InRangeUnobstructed(other, InteractionRangeDivided15Times3));
|
|
Assert.True(other.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
|
|
|
|
// Entity <-> Component
|
|
Assert.True(origin.InRangeUnobstructed(component, InteractionRangeDivided15Times3));
|
|
Assert.True(component.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
|
|
|
|
// Entity <-> Container
|
|
Assert.True(origin.InRangeUnobstructed(container, InteractionRangeDivided15Times3));
|
|
Assert.True(container.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
|
|
|
|
// Entity <-> EntityCoordinates
|
|
Assert.True(origin.InRangeUnobstructed(entityCoordinates, InteractionRangeDivided15Times3));
|
|
Assert.True(entityCoordinates.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
|
|
|
|
// Entity <-> MapCoordinates
|
|
Assert.True(origin.InRangeUnobstructed(mapCoordinates, InteractionRangeDivided15Times3));
|
|
Assert.True(mapCoordinates.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
|
|
});
|
|
|
|
await server.WaitIdleAsync();
|
|
}
|
|
}
|
|
}
|