Merge branch 'master' into replace-sounds-with-sound-specifier
# Conflicts: # Content.Server/Actions/Actions/DisarmAction.cs # Content.Server/Actions/Actions/ScreamAction.cs # Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs # Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs # Content.Server/Explosion/Components/FlashExplosiveComponent.cs # Content.Server/Physics/Controllers/MoverController.cs # Content.Server/Portal/Components/PortalComponent.cs # Content.Server/Portal/Components/TeleporterComponent.cs # Content.Server/Projectiles/Components/ProjectileComponent.cs # Content.Server/Singularity/Components/EmitterComponent.cs # Content.Server/Sound/EmitSoundSystem.cs # Content.Server/Stunnable/Components/StunbatonComponent.cs # Content.Server/Tools/Components/MultitoolComponent.cs # Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs # Content.Shared/Gravity/GravityComponent.cs # Content.Shared/Light/Component/SharedExpendableLightComponent.cs # Content.Shared/Maps/ContentTileDefinition.cs # Content.Shared/Slippery/SlipperyComponent.cs # Content.Shared/Standing/StandingStateComponent.cs # Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
This commit is contained in:
@@ -126,8 +126,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
mapManager.CreateNewMapEntity(mapId);
|
||||
var mapId = mapManager.CreateMap();
|
||||
|
||||
var humanCoordinates = new MapCoordinates((physicsDummyStartingX, 0), mapId);
|
||||
physicsDummy = entityManager.SpawnEntity("PhysicsDummy", humanCoordinates);
|
||||
@@ -159,6 +158,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
// Sanity check
|
||||
// Sloth: Okay I'm sorry but I hate having to rewrite tests for every refactor
|
||||
// If you see this yell at me in discord so I can continue to pretend this didn't happen.
|
||||
// REMINDER THAT I STILL HAVE TO FIX THIS TEST EVERY OTHER PHYSICS PR
|
||||
// Assert.That(physicsDummy.Transform.MapPosition.X, Is.GreaterThan(physicsDummyStartingX));
|
||||
|
||||
// Blocked by the airlock
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Client.Lobby;
|
||||
using Content.Client.Preferences;
|
||||
using Content.Client.State;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Preferences;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Shared;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Networking
|
||||
{
|
||||
[TestFixture]
|
||||
class NetworkIdsMatchTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public async Task TestConnect()
|
||||
{
|
||||
var client = StartClient();
|
||||
var server = StartServer();
|
||||
|
||||
await ConnectNetworking(client, server);
|
||||
|
||||
var clientCompFactory = client.ResolveDependency<IComponentFactory>();
|
||||
var serverCompFactory = server.ResolveDependency<IComponentFactory>();
|
||||
|
||||
var clientNetComps = clientCompFactory.NetworkedComponents;
|
||||
var serverNetComps = serverCompFactory.NetworkedComponents;
|
||||
|
||||
Assert.That(clientNetComps, Is.Not.Null);
|
||||
Assert.That(serverNetComps, Is.Not.Null);
|
||||
Assert.That(clientNetComps.Count, Is.EqualTo(serverNetComps.Count));
|
||||
|
||||
// Checks that at least Metadata and Transform are registered.
|
||||
Assert.That(clientNetComps.Count, Is.GreaterThanOrEqualTo(2));
|
||||
|
||||
for (var netId = 0; netId < clientNetComps.Count; netId++)
|
||||
{
|
||||
Assert.That(clientNetComps[netId].Name, Is.EqualTo(serverNetComps[netId].Name));
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task ConnectNetworking(ClientIntegrationInstance client, ServerIntegrationInstance server)
|
||||
{
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
// Connect.
|
||||
|
||||
client.SetConnectTarget(server);
|
||||
|
||||
client.Post(() => IoCManager.Resolve<IClientNetManager>().ClientConnect(null, 0, null));
|
||||
|
||||
// Run some ticks for the handshake to complete and such.
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
server.RunTicks(1);
|
||||
await server.WaitIdleAsync();
|
||||
client.RunTicks(1);
|
||||
await client.WaitIdleAsync();
|
||||
}
|
||||
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.NetIDs;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameStates;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
@@ -391,10 +391,10 @@ namespace Content.IntegrationTests.Tests.Networking
|
||||
}
|
||||
}
|
||||
|
||||
[NetworkedComponent()]
|
||||
private sealed class PredictionTestComponent : Component
|
||||
{
|
||||
public override string Name => "PredictionTest";
|
||||
public override uint? NetID => ContentNetIDs.PREDICTION_TEST;
|
||||
|
||||
private bool _foo;
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace Content.IntegrationTests.Tests.Networking
|
||||
{
|
||||
public bool Foo { get; }
|
||||
|
||||
public PredictionComponentState(bool foo) : base(ContentNetIDs.PREDICTION_TEST)
|
||||
public PredictionComponentState(bool foo)
|
||||
{
|
||||
Foo = foo;
|
||||
}
|
||||
|
||||
@@ -1,267 +0,0 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Erin Catto
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
These tests are derived from box2d's testbed tests but done in a way as to be automated and useful for CI.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Physics
|
||||
{
|
||||
[TestFixture]
|
||||
public class PhysicsTestBedTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public async Task TestBoxStack()
|
||||
{
|
||||
var server = StartServer();
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
||||
var physicsSystem = entitySystemManager.GetEntitySystem<SharedPhysicsSystem>();
|
||||
MapId mapId;
|
||||
|
||||
var columnCount = 1;
|
||||
var rowCount = 15;
|
||||
PhysicsComponent[] bodies = new PhysicsComponent[columnCount * rowCount];
|
||||
Vector2 firstPos = Vector2.Zero;
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
mapId = mapManager.CreateMap();
|
||||
physicsSystem.Maps[mapId].Gravity = new Vector2(0, -9.8f);
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
var ground = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
|
||||
|
||||
var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
|
||||
var horizontalFixture = new Fixture(ground, horizontal)
|
||||
{
|
||||
CollisionLayer = 1,
|
||||
CollisionMask = 1,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(horizontalFixture);
|
||||
|
||||
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
|
||||
var verticalFixture = new Fixture(ground, vertical)
|
||||
{
|
||||
CollisionLayer = 1,
|
||||
CollisionMask = 1,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(verticalFixture);
|
||||
|
||||
var xs = new[]
|
||||
{
|
||||
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
|
||||
};
|
||||
|
||||
PolygonShape shape;
|
||||
|
||||
for (var j = 0; j < columnCount; j++)
|
||||
{
|
||||
for (var i = 0; i < rowCount; i++)
|
||||
{
|
||||
var x = 0.0f;
|
||||
|
||||
var box = entityManager.SpawnEntity(null,
|
||||
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
|
||||
|
||||
box.BodyType = BodyType.Dynamic;
|
||||
box.SleepingAllowed = false;
|
||||
shape = new PolygonShape(0.001f) {Vertices = new List<Vector2>()
|
||||
{
|
||||
new(0.5f, -0.5f),
|
||||
new(0.5f, 0.5f),
|
||||
new(-0.5f, 0.5f),
|
||||
new(-0.5f, -0.5f),
|
||||
}};
|
||||
box.FixedRotation = true;
|
||||
// TODO: Need to detect shape and work out if we need to use fixedrotation
|
||||
|
||||
var fixture = new Fixture(box, shape)
|
||||
{
|
||||
CollisionMask = 1,
|
||||
CollisionLayer = 1,
|
||||
Hard = true,
|
||||
};
|
||||
box.AddFixture(fixture);
|
||||
|
||||
bodies[j * rowCount + i] = box;
|
||||
}
|
||||
}
|
||||
|
||||
firstPos = bodies[0].Owner.Transform.WorldPosition;
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
// Check that gravity workin
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(firstPos != bodies[0].Owner.Transform.WorldPosition);
|
||||
});
|
||||
|
||||
// Assert
|
||||
|
||||
await server.WaitRunTicks(150);
|
||||
|
||||
// Assert settled, none below 0, etc.
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
for (var j = 0; j < columnCount; j++)
|
||||
{
|
||||
for (var i = 0; i < bodies.Length; i++)
|
||||
{
|
||||
var body = bodies[j * columnCount + i];
|
||||
var worldPos = body.Owner.Transform.WorldPosition;
|
||||
|
||||
// TODO: Multi-column support but I cbf right now
|
||||
// Can't be more exact as some level of sinking is allowed.
|
||||
Assert.That(worldPos.EqualsApprox(new Vector2(0.0f, i + 0.5f), 0.1f), $"Expected y-value of {i + 0.5f} but found {worldPos.Y}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestCircleStack()
|
||||
{
|
||||
var server = StartServer();
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
||||
var physicsSystem = entitySystemManager.GetEntitySystem<SharedPhysicsSystem>();
|
||||
MapId mapId;
|
||||
|
||||
var columnCount = 1;
|
||||
var rowCount = 15;
|
||||
PhysicsComponent[] bodies = new PhysicsComponent[columnCount * rowCount];
|
||||
Vector2 firstPos = Vector2.Zero;
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
mapId = mapManager.CreateMap();
|
||||
physicsSystem.Maps[mapId].Gravity = new Vector2(0, -9.8f);
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
var ground = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
|
||||
|
||||
var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
|
||||
var horizontalFixture = new Fixture(ground, horizontal)
|
||||
{
|
||||
CollisionLayer = 1,
|
||||
CollisionMask = 1,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(horizontalFixture);
|
||||
|
||||
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
|
||||
var verticalFixture = new Fixture(ground, vertical)
|
||||
{
|
||||
CollisionLayer = 1,
|
||||
CollisionMask = 1,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(verticalFixture);
|
||||
|
||||
var xs = new[]
|
||||
{
|
||||
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
|
||||
};
|
||||
|
||||
PhysShapeCircle shape;
|
||||
|
||||
for (var j = 0; j < columnCount; j++)
|
||||
{
|
||||
for (var i = 0; i < rowCount; i++)
|
||||
{
|
||||
var x = 0.0f;
|
||||
|
||||
var circle = entityManager.SpawnEntity(null,
|
||||
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
|
||||
|
||||
circle.BodyType = BodyType.Dynamic;
|
||||
circle.SleepingAllowed = false;
|
||||
shape = new PhysShapeCircle {Radius = 0.5f};
|
||||
|
||||
var fixture = new Fixture(circle, shape)
|
||||
{
|
||||
CollisionMask = 1,
|
||||
CollisionLayer = 1,
|
||||
Hard = true,
|
||||
};
|
||||
circle.AddFixture(fixture);
|
||||
|
||||
bodies[j * rowCount + i] = circle;
|
||||
}
|
||||
}
|
||||
|
||||
firstPos = bodies[0].Owner.Transform.WorldPosition;
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
// Check that gravity workin
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(firstPos != bodies[0].Owner.Transform.WorldPosition);
|
||||
});
|
||||
|
||||
// Assert
|
||||
|
||||
await server.WaitRunTicks(150);
|
||||
|
||||
// Assert settled, none below 0, etc.
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
for (var j = 0; j < columnCount; j++)
|
||||
{
|
||||
for (var i = 0; i < bodies.Length; i++)
|
||||
{
|
||||
var body = bodies[j * columnCount + i];
|
||||
var worldPos = body.Owner.Transform.WorldPosition;
|
||||
|
||||
// TODO: Multi-column support but I cbf right now
|
||||
// Can't be more exact as some level of sinking is allowed.
|
||||
Assert.That(worldPos.EqualsApprox(new Vector2(0.0f, i + 0.5f), 0.1f), $"Expected y-value of {i + 0.5f} but found {worldPos.Y}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,12 @@ namespace Content.IntegrationTests.Tests
|
||||
var mapLoader = server.ResolveDependency<IMapLoader>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var resManager = server.ResolveDependency<IResourceManager>();
|
||||
|
||||
server.Post(() =>
|
||||
{
|
||||
var dir = new ResourcePath(mapPath).Directory;
|
||||
IoCManager.Resolve<IResourceManager>()
|
||||
.UserData.CreateDir(dir);
|
||||
resManager.UserData.CreateDir(dir);
|
||||
|
||||
var mapId = mapManager.CreateMap(new MapId(5));
|
||||
|
||||
|
||||
49
Content.IntegrationTests/Tests/ShuttleTest.cs
Normal file
49
Content.IntegrationTests/Tests/ShuttleTest.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Shuttles;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ShuttleTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var entMan = server.ResolveDependency<IEntityManager>();
|
||||
var mapMan = server.ResolveDependency<IMapManager>();
|
||||
IEntity? gridEnt = null;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = mapMan.CreateMap();
|
||||
var grid = mapMan.CreateGrid(mapId);
|
||||
gridEnt = entMan.GetEntity(grid.GridEntityId);
|
||||
|
||||
Assert.That(gridEnt.TryGetComponent(out ShuttleComponent? shuttleComponent));
|
||||
Assert.That(gridEnt.TryGetComponent(out PhysicsComponent? physicsComponent));
|
||||
Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic));
|
||||
Assert.That(gridEnt.Transform.LocalPosition, Is.EqualTo(Vector2.Zero));
|
||||
physicsComponent.ApplyLinearImpulse(Vector2.One);
|
||||
});
|
||||
|
||||
// TODO: Should have tests that collision + rendertree + pointlights work on a moved grid but I'll deal with that
|
||||
// when we get rotations.
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(gridEnt?.Transform.LocalPosition, Is.Not.EqualTo(Vector2.Zero));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Spawning;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Utility
|
||||
@@ -39,7 +40,7 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
|
||||
var sMapManager = server.ResolveDependency<IMapManager>();
|
||||
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
||||
var broady = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedBroadPhaseSystem>();
|
||||
var broady = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedBroadphaseSystem>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user