Skip to content

Commit

Permalink
Merge remote-tracking branch 'wizards/master' into 07-01-fix-ghost-lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
lzk228 committed Jul 3, 2024
2 parents 992e819 + 7b3140f commit b6973f8
Show file tree
Hide file tree
Showing 88 changed files with 772 additions and 642 deletions.
15 changes: 10 additions & 5 deletions Content.Client/MouseRotator/MouseRotatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Client.Replays.Loading;
using Robust.Shared.Map;
using Robust.Shared.Timing;

Expand Down Expand Up @@ -46,13 +45,19 @@ public override void Update(float frameTime)
// only raise event if the cardinal direction has changed
if (rotator.Simple4DirMode)
{
var angleDir = angle.GetCardinalDir();
if (angleDir == curRot.GetCardinalDir())
var eyeRot = _eye.CurrentEye.Rotation; // camera rotation
var angleDir = (angle + eyeRot).GetCardinalDir(); // apply GetCardinalDir in the camera frame, not in the world frame
if (angleDir == (curRot + eyeRot).GetCardinalDir())
return;

RaisePredictiveEvent(new RequestMouseRotatorRotationSimpleEvent()
var rotation = angleDir.ToAngle() - eyeRot; // convert back to world frame
if (rotation >= Math.PI) // convert to [-PI, +PI)
rotation -= 2 * Math.PI;
else if (rotation < -Math.PI)
rotation += 2 * Math.PI;
RaisePredictiveEvent(new RequestMouseRotatorRotationEvent
{
Direction = angleDir,
Rotation = rotation
});

return;
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Rotation/RotationVisualizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ private void OnAppearanceChange(EntityUid uid, RotationVisualsComponent componen
if (args.Sprite == null)
return;

// If not defined, defaults to standing.
_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component);
if (!_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component))
return;

switch (state)
{
Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed class ActionsAddedTest
[Test]
public async Task TestCombatActionsAdded()
{
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, DummyTicker = false});
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, DummyTicker = false });
var server = pair.Server;
var client = pair.Client;
var sEntMan = server.ResolveDependency<IEntityManager>();
Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/Body/GibTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Content.IntegrationTests.Tests.Body;

[TestFixture]
public sealed class GibTest
public sealed class GibTest
{
[Test]
public async Task TestGib()
Expand Down
8 changes: 4 additions & 4 deletions Content.IntegrationTests/Tests/Body/LegTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Content.Shared.Rotation;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;

namespace Content.IntegrationTests.Tests.Body
{
Expand Down Expand Up @@ -40,13 +39,14 @@ public async Task RemoveLegsFallTest()
var appearanceSystem = entityManager.System<SharedAppearanceSystem>();
var xformSystem = entityManager.System<SharedTransformSystem>();

var map = await pair.CreateTestMap();

await server.WaitAssertion(() =>
{
var mapId = mapManager.CreateMap();
BodyComponent body = null;
human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy",
new MapCoordinates(Vector2.Zero, mapId));
new MapCoordinates(Vector2.Zero, map.MapId));
Assert.Multiple(() =>
{
Expand All @@ -61,7 +61,7 @@ await server.WaitAssertion(() =>
foreach (var leg in legs)
{
xformSystem.DetachParentToNull(leg.Id, entityManager.GetComponent<TransformComponent>(leg.Id));
xformSystem.DetachEntity(leg.Id, entityManager.GetComponent<TransformComponent>(leg.Id));
}
});

Expand Down
8 changes: 4 additions & 4 deletions Content.IntegrationTests/Tests/Body/LungTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public async Task AirConsistencyTest()
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var mapLoader = entityManager.System<MapLoaderSystem>();
var mapSys = entityManager.System<SharedMapSystem>();

MapId mapId;
EntityUid? grid = null;
BodyComponent body = default;
RespiratorComponent resp = default;
Expand All @@ -73,7 +73,7 @@ public async Task AirConsistencyTest()

await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
mapSys.CreateMap(out var mapId);
Assert.That(mapLoader.TryLoad(mapId, testMapName, out var roots));
var query = entityManager.GetEntityQuery<MapGridComponent>();
Expand Down Expand Up @@ -142,8 +142,8 @@ public async Task NoSuffocationTest()
var entityManager = server.ResolveDependency<IEntityManager>();
var cfg = server.ResolveDependency<IConfigurationManager>();
var mapLoader = entityManager.System<MapLoaderSystem>();
var mapSys = entityManager.System<SharedMapSystem>();

MapId mapId;
EntityUid? grid = null;
RespiratorComponent respirator = null;
EntityUid human = default;
Expand All @@ -152,7 +152,7 @@ public async Task NoSuffocationTest()

await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
mapSys.CreateMap(out var mapId);
Assert.That(mapLoader.TryLoad(mapId, testMapName, out var ents), Is.True);
var query = entityManager.GetEntityQuery<MapGridComponent>();
Expand Down
5 changes: 3 additions & 2 deletions Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public async Task Test()
var mapLoader = entities.System<MapLoaderSystem>();
var bodySystem = entities.System<SharedBodySystem>();
var containerSystem = entities.System<SharedContainerSystem>();
var mapSys = entities.System<SharedMapSystem>();

await server.WaitAssertion(() =>
{
var mapId = maps.CreateMap();
mapSys.CreateMap(out var mapId);
maps.CreateGrid(mapId);
var human = entities.SpawnEntity("HumanBodyDummy", new MapCoordinates(0, 0, mapId));
Expand Down Expand Up @@ -115,7 +116,7 @@ await server.WaitAssertion(() =>
mapLoader.SaveMap(mapId, mapPath);
maps.DeleteMap(mapId);
mapId = maps.CreateMap();
mapSys.CreateMap(out mapId);
Assert.That(mapLoader.TryLoad(mapId, mapPath, out _), Is.True);
var query = EnumerateQueryEnumerator(
Expand Down
4 changes: 2 additions & 2 deletions Content.IntegrationTests/Tests/Buckle/BuckleDragTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public async Task BucklePullTest()
await RunTicks(5);
Assert.That(buckle.Buckled, Is.True);
Assert.That(buckle.BuckledTo, Is.EqualTo(STarget));
Assert.That(strap.BuckledEntities, Is.EquivalentTo(new[]{sUrist}));
Assert.That(strap.BuckledEntities, Is.EquivalentTo(new[] { sUrist }));
Assert.That(puller.Pulling, Is.Null);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);

// Start pulling, and thus unbuckle them
await PressKey(ContentKeyFunctions.TryPullObject, cursorEntity:urist);
await PressKey(ContentKeyFunctions.TryPullObject, cursorEntity: urist);
await RunTicks(5);
Assert.That(buckle.Buckled, Is.False);
Assert.That(buckle.BuckledTo, Is.Null);
Expand Down
6 changes: 3 additions & 3 deletions Content.IntegrationTests/Tests/CargoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ namespace Content.IntegrationTests.Tests;
[TestFixture]
public sealed class CargoTest
{
public static HashSet<ProtoId<CargoProductPrototype>> Ignored = new ()
{
private static readonly HashSet<ProtoId<CargoProductPrototype>> Ignored =
[
// This is ignored because it is explicitly intended to be able to sell for more than it costs.
new("FunCrateGambling")
};
];

[Test]
public async Task NoCargoOrderArbitrage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace Content.IntegrationTests.Tests.Chemistry
{
public sealed class FixedPoint2SerializationTest : SerializationTest
{
protected override Assembly[] Assemblies => new[]
{
protected override Assembly[] Assemblies =>
[
typeof(FixedPoint2SerializationTest).Assembly
};
];

[Test]
public void DeserializeNullTest()
Expand Down Expand Up @@ -53,6 +53,6 @@ public void DeserializeNullDefinitionTest()
[DataDefinition]
public sealed partial class FixedPoint2TestDefinition
{
[DataField("unit")] public FixedPoint2? Unit { get; set; } = FixedPoint2.New(5);
[DataField] public FixedPoint2? Unit { get; set; } = FixedPoint2.New(5);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
Expand Down Expand Up @@ -76,7 +76,7 @@ public async Task Test()

await server.WaitPost(() =>
{
var system = server.System<SolutionContainerSystem>();
var system = server.System<SharedSolutionContainerSystem>();
var beaker = server.EntMan.SpawnEntity("SolutionRoundingTestContainer", testMap.GridCoords);
system.TryGetSolution(beaker, "beaker", out var newSolutionEnt, out var newSolution);
Expand Down
12 changes: 6 additions & 6 deletions Content.IntegrationTests/Tests/Chemistry/SolutionSystemTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
Expand All @@ -11,7 +11,7 @@ namespace Content.IntegrationTests.Tests.Chemistry;
// To ensure volume(A) + volume(B) = volume(A+B)
// reactions can change this assumption
[TestFixture]
[TestOf(typeof(SolutionContainerSystem))]
[TestOf(typeof(SharedSolutionContainerSystem))]
public sealed class SolutionSystemTests
{
[TestPrototypes]
Expand Down Expand Up @@ -51,7 +51,7 @@ public async Task TryAddTwoNonReactiveReagent()

var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var containerSystem = entityManager.System<SharedSolutionContainerSystem>();
var testMap = await pair.CreateTestMap();
var coordinates = testMap.GridCoords;

Expand Down Expand Up @@ -97,7 +97,7 @@ public async Task TryAddTooMuchNonReactiveReagent()

var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var containerSystem = entityManager.System<SharedSolutionContainerSystem>();
var coordinates = testMap.GridCoords;

EntityUid beaker;
Expand Down Expand Up @@ -141,7 +141,7 @@ public async Task TryMixAndOverflowTooMuchReagent()
var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var testMap = await pair.CreateTestMap();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var containerSystem = entityManager.System<SharedSolutionContainerSystem>();
var coordinates = testMap.GridCoords;

EntityUid beaker;
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task TryMixAndOverflowTooBigOverflow()

var entityManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var containerSystem = entityManager.System<SolutionContainerSystem>();
var containerSystem = entityManager.System<SharedSolutionContainerSystem>();
var testMap = await pair.CreateTestMap();
var coordinates = testMap.GridCoords;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
using Content.Shared.Chemistry.EntitySystems;

namespace Content.IntegrationTests.Tests.Chemistry
{
Expand Down Expand Up @@ -34,7 +34,7 @@ public async Task TryAllTest()
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var testMap = await pair.CreateTestMap();
var coordinates = testMap.GridCoords;
var solutionContainerSystem = entityManager.System<SolutionContainerSystem>();
var solutionContainerSystem = entityManager.System<SharedSolutionContainerSystem>();

foreach (var reactionPrototype in prototypeManager.EnumeratePrototypes<ReactionPrototype>())
{
Expand Down
10 changes: 5 additions & 5 deletions Content.IntegrationTests/Tests/Commands/PardonCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task PardonTest()

Assert.That(netMan.IsConnected);

Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(1));
Assert.That(sPlayerManager.Sessions, Has.Length.EqualTo(1));
// No bans on record
Assert.Multiple(async () =>
{
Expand All @@ -50,7 +50,7 @@ public async Task PardonTest()

var banReason = "test";

Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(1));
Assert.That(sPlayerManager.Sessions, Has.Length.EqualTo(1));
// Ban the client for 24 hours
await server.WaitPost(() => sConsole.ExecuteCommand($"ban {clientSession.Name} {banReason} 1440"));

Expand All @@ -63,7 +63,7 @@ public async Task PardonTest()
});

await pair.RunTicksSync(5);
Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(0));
Assert.That(sPlayerManager.Sessions, Has.Length.EqualTo(0));
Assert.That(!netMan.IsConnected);

// Try to pardon a ban that does not exist
Expand Down Expand Up @@ -143,11 +143,11 @@ public async Task PardonTest()
});

// Reconnect client. Slightly faster than dirtying the pair.
Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(0));
Assert.That(sPlayerManager.Sessions, Is.Empty);
client.SetConnectTarget(server);
await client.WaitPost(() => netMan.ClientConnect(null!, 0, null!));
await pair.RunTicksSync(5);
Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(1));
Assert.That(sPlayerManager.Sessions, Has.Length.EqualTo(1));

await pair.CleanReturnAsync();
}
Expand Down
6 changes: 3 additions & 3 deletions Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public async Task RejuvenateDeadTest()
var server = pair.Server;
var entManager = server.ResolveDependency<IEntityManager>();
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var mobStateSystem = entManager.EntitySysManager.GetEntitySystem<MobStateSystem>();
var damSystem = entManager.EntitySysManager.GetEntitySystem<DamageableSystem>();
var rejuvenateSystem = entManager.EntitySysManager.GetEntitySystem<RejuvenateSystem>();
var mobStateSystem = entManager.System<MobStateSystem>();
var damSystem = entManager.System<DamageableSystem>();
var rejuvenateSystem = entManager.System<RejuvenateSystem>();

await server.WaitAssertion(() =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task RestartRoundAfterStart(bool lobbyEnabled)

var configManager = server.ResolveDependency<IConfigurationManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var gameTicker = entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
var gameTicker = entityManager.System<GameTicker>();

await pair.RunTicksSync(5);

Expand Down
Loading

0 comments on commit b6973f8

Please sign in to comment.