Fix 3000 errors

This commit is contained in:
DrSmugleaf
2021-12-05 18:09:01 +01:00
parent 2bfec7ec62
commit 2a3b7d809d
569 changed files with 2979 additions and 3280 deletions

View File

@@ -42,10 +42,10 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
var server = StartServer(options);
IEntity human;
IEntity otherHuman;
IEntity cuffs;
IEntity secondCuffs;
EntityUid human;
EntityUid otherHuman;
EntityUid cuffs;
EntityUid secondCuffs;
CuffableComponent cuffed;
HandsComponent hands;
@@ -63,16 +63,14 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
cuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(human).WorldPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(otherHuman).WorldPosition;
entityManager.GetComponent<TransformComponent>(human).WorldPosition = entityManager.GetComponent<TransformComponent>(otherHuman).WorldPosition;
// Test for components existing
ref CuffableComponent? comp = ref cuffed!;
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human, out comp), $"Human has no {nameof(CuffableComponent)}");
ref HandsComponent? comp1 = ref hands!;
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human, out comp1), $"Human has no {nameof(HandsComponent)}");
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human, out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}");
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(cuffs, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(secondCuffs, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
Assert.True(entityManager.TryGetComponent(human, out cuffed), $"Human has no {nameof(CuffableComponent)}");
Assert.True(entityManager.TryGetComponent(human, out hands), $"Human has no {nameof(HandsComponent)}");
Assert.True(entityManager.TryGetComponent(human, out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}");
Assert.True(entityManager.TryGetComponent(cuffs, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
Assert.True(entityManager.TryGetComponent(secondCuffs, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
// Test to ensure cuffed players register the handcuffs
cuffed.TryAddNewCuffs(human, cuffs);
@@ -94,7 +92,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
await server.WaitIdleAsync();
}
private void AddHand(IEntity to)
private void AddHand(EntityUid to)
{
var host = IoCManager.Resolve<IServerConsoleHost>();
host.ExecuteCommand(null, $"addhand {to}");

View File

@@ -66,13 +66,16 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitIdleAsync();
await client.WaitIdleAsync();
var cEntities = IoCManager.Resolve<IEntityManager>();
var sEntities = IoCManager.Resolve<IEntityManager>();
var serverPlayerManager = server.ResolveDependency<IPlayerManager>();
var innateActions = new List<ActionType>();
await server.WaitAssertion(() =>
{
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
var actionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerActionsComponent>(playerEnt!);
var actionsComponent = sEntities.GetComponent<ServerActionsComponent>(playerEnt!.Value);
// player should begin with their innate actions granted
innateActions.AddRange(actionsComponent.InnateActions);
@@ -99,7 +102,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
var local = clientPlayerMgr.LocalPlayer;
var controlled = local!.ControlledEntity;
var actionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientActionsComponent>(controlled!);
var actionsComponent = cEntities.GetComponent<ClientActionsComponent>(controlled!);
// we should have our innate actions and debug1.
foreach (var innateAction in innateActions)
@@ -123,14 +126,14 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
if (expectEmpty)
{
Assert.That(slot.HasAssignment, Is.False);
Assert.That(slot.Item, Is.Null);
Assert.That(slot.Item, Is.EqualTo(default));
Assert.That(slot.Action, Is.Null);
Assert.That(slot.ActionEnabled, Is.False);
continue;
}
Assert.That(slot.HasAssignment);
// all the actions we gave so far are not tied to an item
Assert.That(slot.Item, Is.Null);
Assert.That(slot.Item, Is.EqualTo(default));
Assert.That(slot.Action, Is.Not.Null);
Assert.That(slot.ActionEnabled);
var asAction = slot.Action as ActionPrototype;
@@ -154,7 +157,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() =>
{
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
var actionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerActionsComponent>(playerEnt!);
var actionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerActionsComponent>(playerEnt!.Value);
actionsComponent.Revoke(ActionType.DebugInstant);
});
@@ -189,7 +192,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
var expected = expectedOrder[idx++];
Assert.That(slot.HasAssignment);
// all the actions we gave so far are not tied to an item
Assert.That(slot.Item, Is.Null);
Assert.That(slot.Item, Is.EqualTo(default));
Assert.That(slot.Action, Is.Not.Null);
var asAction = slot.Action as ActionPrototype;
Assert.That(asAction, Is.Not.Null);
@@ -207,7 +210,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
else
{
Assert.That(slot.HasAssignment, Is.False);
Assert.That(slot.Item, Is.Null);
Assert.That(slot.Item, Is.EqualTo(default));
Assert.That(slot.Action, Is.Null);
Assert.That(slot.ActionEnabled, Is.False);
}
@@ -232,6 +235,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitIdleAsync();
await client.WaitIdleAsync();
var clientEntities = client.ResolveDependency<IEntityManager>();
var serverPlayerManager = server.ResolveDependency<IPlayerManager>();
var serverEntManager = server.ResolveDependency<IEntityManager>();
var serverGameTiming = server.ResolveDependency<IGameTiming>();
@@ -240,18 +245,18 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
ServerActionsComponent serverActionsComponent = null;
ClientActionsComponent clientActionsComponent = null;
IEntity serverPlayerEnt = null;
IEntity serverFlashlight = null;
EntityUid serverPlayerEnt = default;
EntityUid serverFlashlight = default;
await server.WaitAssertion(() =>
{
serverPlayerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
serverActionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerActionsComponent>(serverPlayerEnt!);
serverPlayerEnt = serverPlayerManager.Sessions.Single().AttachedEntity!.Value;
serverActionsComponent = serverEntManager.GetComponent<ServerActionsComponent>(serverPlayerEnt);
// spawn and give them an item that has actions
serverFlashlight = serverEntManager.SpawnEntity("TestFlashlight",
new EntityCoordinates(serverPlayerEnt, (0, 0)));
Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemActionsComponent?>(serverFlashlight, out var itemActions));
Assert.That(serverEntManager.TryGetComponent<ItemActionsComponent>(serverFlashlight, out var itemActions));
// we expect this only to have a toggle light action initially
var actionConfigs = itemActions.ActionConfigs.ToList();
Assert.That(actionConfigs.Count == 1);
@@ -260,11 +265,11 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
// grant an extra item action, before pickup, initially disabled
itemActions.GrantOrUpdate(ItemActionType.DebugToggle, false);
IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(serverFlashlight), false);
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(serverEntManager.GetComponent<ItemComponent>(serverFlashlight), false);
// grant an extra item action, after pickup, with a cooldown
itemActions.GrantOrUpdate(ItemActionType.DebugInstant, cooldown: cooldown);
Assert.That(serverActionsComponent.TryGetItemActionStates((EntityUid) serverFlashlight, out var state));
Assert.That(serverActionsComponent.TryGetItemActionStates(serverFlashlight, out var state));
// they should have been granted all 3 actions
Assert.That(state.Count == 3);
Assert.That(state.TryGetValue(ItemActionType.ToggleLight, out var toggleLightState));
@@ -286,7 +291,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
var local = clientPlayerMgr.LocalPlayer;
var controlled = local!.ControlledEntity;
clientActionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientActionsComponent>(controlled!);
clientActionsComponent = clientEntities.GetComponent<ClientActionsComponent>(controlled!);
var lightEntry = clientActionsComponent.ItemActionStates()
.Where(entry => entry.Value.ContainsKey(ItemActionType.ToggleLight))
@@ -334,8 +339,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() =>
{
// drop the item, and the item actions should go away
IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(serverPlayerEnt)
.TryDropEntity(serverFlashlight, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(serverPlayerEnt).Coordinates, false);
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt)
.TryDropEntity(serverFlashlight, serverEntManager.GetComponent<TransformComponent>(serverPlayerEnt).Coordinates, false);
Assert.That(serverActionsComponent.ItemActionStates().ContainsKey(serverFlashlight), Is.False);
});
@@ -352,7 +357,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
// pick the item up again, the states should be back to what they were when dropped,
// as the states "stick" with the item
IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(serverFlashlight), false);
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(serverEntManager.GetComponent<ItemComponent>(serverFlashlight), false);
Assert.That(serverActionsComponent.ItemActionStates().TryGetValue(serverFlashlight, out var lightStates));
Assert.That(lightStates.TryGetValue(ItemActionType.ToggleLight, out var lightState));
Assert.That(lightState.Equals(new ActionState(true, toggledOn: true)));

View File

@@ -31,7 +31,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
Assert.NotNull(playerEnt);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt!.Value);
Assert.NotNull(alertsComponent);
// show 2 alerts
@@ -71,7 +71,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
Assert.NotNull(playerEnt);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt!.Value);
Assert.NotNull(alertsComponent);
alertsComponent.ClearAlert(AlertType.Debug1);

View File

@@ -37,8 +37,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
var server = StartServer(options);
IEntity human;
IEntity table;
EntityUid human;
EntityUid table;
ClimbingComponent climbing;
server.Assert(() =>
@@ -54,19 +54,17 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
// Test for climb components existing
// Players and tables should have these in their prototypes.
ref ClimbingComponent? comp = ref climbing!;
Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(human, out comp), "Human has no climbing");
Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(table, out ClimbableComponent? _), "Table has no climbable");
Assert.That(entityManager.TryGetComponent(human, out climbing), "Human has no climbing");
Assert.That(entityManager.TryGetComponent(table, out ClimbableComponent? _), "Table has no climbable");
// Now let's make the player enter a climbing transitioning state.
climbing.IsClimbing = true;
climbing.TryMoveTo(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(human).WorldPosition, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(table).WorldPosition);
var body = IoCManager.Resolve<IEntityManager>().GetComponent<IPhysBody>(human);
var body = entityManager.GetComponent<IPhysBody>(human);
// TODO: Check it's climbing
// Force the player out of climb state. It should immediately remove the ClimbController.
climbing.IsClimbing = false;
});
await server.WaitIdleAsync();