Fix a bunch of warnings (#10886)

* Fix a bunch of warnings

Also made ensnareable not broadcast as they're only used directed.
Mainly just Get<T> and AppearanceSystem

* buckle too

* fix tests

Co-authored-by: wrexbe <wrexbe@protonmail.com>
This commit is contained in:
metalgearsloth
2022-08-28 13:26:35 +10:00
committed by GitHub
parent cf84c20f68
commit d767ce9585
17 changed files with 75 additions and 79 deletions

View File

@@ -56,6 +56,10 @@ namespace Content.IntegrationTests.Tests.Buckle
var testMap = await PoolManager.CreateTestMap(pairTracker);
var coordinates = testMap.GridCoords;
var entityManager = server.ResolveDependency<IEntityManager>();
var actionBlocker = entityManager.EntitySysManager.GetEntitySystem<ActionBlockerSystem>();
var standingState = entityManager.EntitySysManager.GetEntitySystem<StandingStateSystem>();
EntityUid human = default;
EntityUid chair = default;
@@ -64,12 +68,6 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var mapManager = IoCManager.Resolve<IMapManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
var standingState = EntitySystem.Get<StandingStateSystem>();
human = entityManager.SpawnEntity(BuckleDummyId, coordinates);
chair = entityManager.SpawnEntity(StrapDummyId, coordinates);
@@ -119,9 +117,6 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
var standingState = EntitySystem.Get<StandingStateSystem>();
// Still buckled
Assert.True(buckle.Buckled);
@@ -155,10 +150,6 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var entityManager = IoCManager.Resolve<IEntityManager>();
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
var standingState = EntitySystem.Get<StandingStateSystem>();
// Still buckled
Assert.True(buckle.Buckled);
@@ -228,10 +219,11 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitIdleAsync();
var entityManager = server.ResolveDependency<IEntityManager>();
var handsSys = entityManager.EntitySysManager.GetEntitySystem<SharedHandsSystem>();
await server.WaitAssertion(() =>
{
var entityManager = IoCManager.Resolve<IEntityManager>();
human = entityManager.SpawnEntity(BuckleDummyId, coordinates);
var chair = entityManager.SpawnEntity(StrapDummyId, coordinates);
@@ -251,7 +243,7 @@ namespace Content.IntegrationTests.Tests.Buckle
{
var akms = entityManager.SpawnEntity(ItemDummyId, coordinates);
Assert.True(EntitySystem.Get<SharedHandsSystem>().TryPickupAnyHand(human, akms));
Assert.True(handsSys.TryPickupAnyHand(human, akms));
}
});
@@ -265,7 +257,7 @@ namespace Content.IntegrationTests.Tests.Buckle
// With items in all hands
foreach (var hand in hands.Hands.Values)
{
Assert.NotNull(hands.ActiveHandEntity);
Assert.NotNull(hand.HeldEntity);
}
var legs = body.GetPartsOfType(BodyPartType.Leg);
@@ -287,7 +279,7 @@ namespace Content.IntegrationTests.Tests.Buckle
// Now with no item in any hand
foreach (var hand in hands.Hands.Values)
{
Assert.Null(hands.ActiveHandEntity);
Assert.Null(hand.HeldEntity);
}
buckle.TryUnbuckle(human, true);
@@ -304,6 +296,7 @@ namespace Content.IntegrationTests.Tests.Buckle
var testMap = await PoolManager.CreateTestMap(pairTracker);
var coordinates = testMap.GridCoords;
var entityManager = server.ResolveDependency<IEntityManager>();
EntityUid human = default;
EntityUid chair = default;
@@ -311,9 +304,6 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var mapManager = IoCManager.Resolve<IMapManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
human = entityManager.SpawnEntity(BuckleDummyId, coordinates);
chair = entityManager.SpawnEntity(StrapDummyId, coordinates);
@@ -336,8 +326,6 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var entityManager = IoCManager.Resolve<IEntityManager>();
// Move the now unbuckled entity back onto the chair
entityManager.GetComponent<TransformComponent>(human).WorldPosition -= (100, 0);

View File

@@ -32,6 +32,7 @@ public sealed class SolutionSystemTests
var server = pairTracker.Pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var testMap = await PoolManager.CreateTestMap(pairTracker);
var coordinates = testMap.GridCoords;
@@ -46,11 +47,11 @@ public sealed class SolutionSystemTests
var originalWater = new Solution("Water", waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
solution.AddSolution(originalWater);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryAddSolution(beaker, solution, oilAdded));
solution.ContainsReagent("Water", out var water);
@@ -73,6 +74,7 @@ public sealed class SolutionSystemTests
var testMap = await PoolManager.CreateTestMap(pairTracker);
var entityManager = server.ResolveDependency<IEntityManager>();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var coordinates = testMap.GridCoords;
EntityUid beaker;
@@ -86,11 +88,11 @@ public sealed class SolutionSystemTests
var originalWater = new Solution("Water", waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
solution.AddSolution(originalWater);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryAddSolution(beaker, solution, oilAdded), Is.False);
solution.ContainsReagent("Water", out var water);
@@ -112,6 +114,7 @@ public sealed class SolutionSystemTests
var entityManager = server.ResolveDependency<IEntityManager>();
var testMap = await PoolManager.CreateTestMap(pairTracker);
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var coordinates = testMap.GridCoords;
EntityUid beaker;
@@ -127,11 +130,11 @@ public sealed class SolutionSystemTests
var originalWater = new Solution("Water", waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
solution.AddSolution(originalWater);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryMixAndOverflow(beaker, solution, oilAdded, threshold, out var overflowingSolution));
Assert.That(solution.CurrentVolume, Is.EqualTo(FixedPoint2.New(threshold)));
@@ -158,6 +161,7 @@ public sealed class SolutionSystemTests
var server = pairTracker.Pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
var containerSystem = entityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var testMap = await PoolManager.CreateTestMap(pairTracker);
var coordinates = testMap.GridCoords;
@@ -174,11 +178,11 @@ public sealed class SolutionSystemTests
var originalWater = new Solution("Water", waterQuantity);
beaker = entityManager.SpawnEntity("SolutionTarget", coordinates);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryGetSolution(beaker, "beaker", out var solution));
solution.AddSolution(originalWater);
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
Assert.That(containerSystem
.TryMixAndOverflow(beaker, solution, oilAdded, threshold, out _),
Is.False);
});

View File

@@ -27,18 +27,21 @@ namespace Content.IntegrationTests.Tests.DoAfter
Task<DoAfterStatus> task = null;
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
var server = pairTracker.Pair.Server;
await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var doAfterSystem = entityManager.EntitySysManager.GetEntitySystem<DoAfterSystem>();
// That it finishes successfully
await server.WaitPost(() =>
{
var tickTime = 1.0f / IoCManager.Resolve<IGameTiming>().TickRate;
var mapManager = IoCManager.Resolve<IMapManager>();
mapManager.CreateNewMapEntity(MapId.Nullspace);
var entityManager = IoCManager.Resolve<IEntityManager>();
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace);
var cancelToken = new CancellationTokenSource();
var args = new DoAfterEventArgs(mob, tickTime / 2, cancelToken.Token);
task = EntitySystem.Get<DoAfterSystem>().WaitDoAfter(args);
task = doAfterSystem.WaitDoAfter(args);
});
await server.WaitRunTicks(1);
@@ -57,17 +60,19 @@ namespace Content.IntegrationTests.Tests.DoAfter
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
var server = pairTracker.Pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
var mapManager = server.ResolveDependency<IMapManager>();
var doAfterSystem = entityManager.EntitySysManager.GetEntitySystem<DoAfterSystem>();
await server.WaitPost(() =>
{
var tickTime = 1.0f / IoCManager.Resolve<IGameTiming>().TickRate;
var mapManager = IoCManager.Resolve<IMapManager>();
mapManager.CreateNewMapEntity(MapId.Nullspace);
var entityManager = IoCManager.Resolve<IEntityManager>();
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace);
var cancelToken = new CancellationTokenSource();
var args = new DoAfterEventArgs(mob, tickTime * 2, cancelToken.Token);
task = EntitySystem.Get<DoAfterSystem>().WaitDoAfter(args);
task = doAfterSystem.WaitDoAfter(args);
cancelToken.Cancel();
});

View File

@@ -53,6 +53,7 @@ namespace Content.IntegrationTests.Tests.Doors
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var doors = entityManager.EntitySysManager.GetEntitySystem<DoorSystem>();
EntityUid airlock = default;
DoorComponent doorComponent = null;
@@ -71,7 +72,7 @@ namespace Content.IntegrationTests.Tests.Doors
await server.WaitAssertion(() =>
{
EntitySystem.Get<DoorSystem>().StartOpening(airlock);
doors.StartOpening(airlock);
Assert.That(doorComponent.State, Is.EqualTo(DoorState.Opening));
});
@@ -83,7 +84,7 @@ namespace Content.IntegrationTests.Tests.Doors
await server.WaitAssertion(() =>
{
EntitySystem.Get<DoorSystem>().TryClose((EntityUid) airlock);
doors.TryClose(airlock);
Assert.That(doorComponent.State, Is.EqualTo(DoorState.Closing));
});

View File

@@ -39,7 +39,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
alertsSystem.ShowAlert(playerUid, AlertType.Debug1);
alertsSystem.ShowAlert(playerUid, AlertType.Debug2);
Assert.AreEqual(alertCount + 2, alerts.Count);
Assert.That(alerts, Has.Count.EqualTo(alertCount + 2));
});
await PoolManager.RunTicksSync(pairTracker.Pair, 5);

View File

@@ -8,7 +8,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Network;
namespace Content.IntegrationTests.Tests.Lobby;
public class ServerReloginTest
public sealed class ServerReloginTest
{
[Test]
public async Task Relogin()

View File

@@ -122,7 +122,7 @@ namespace Content.IntegrationTests.Tests
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMinutes(4);
roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMinutes(1);
EntitySystem.Get<GameTicker>().RestartRound();
ticker.RestartRound();
});
await PoolManager.ReallyBeIdle(pairTracker.Pair, 10);

View File

@@ -53,7 +53,6 @@ public sealed partial class EnsnareableSystem
/// <summary>
/// Used where you want to try to ensnare an entity with the <see cref="EnsnareableComponent"/>
/// </summary>
/// <param name="ensnaringEntity">The entity that will be used to ensnare</param>
/// <param name="target">The entity that will be ensnared</param>
/// <param name="component">The ensnaring component</param>
public void TryEnsnare(EntityUid target, EnsnaringComponent component)
@@ -68,7 +67,7 @@ public sealed partial class EnsnareableSystem
UpdateAlert(ensnareable);
var ev = new EnsnareEvent(component.WalkSpeed, component.SprintSpeed);
RaiseLocalEvent(target, ev, false);
RaiseLocalEvent(target, ev);
}
/// <summary>
@@ -79,7 +78,7 @@ public sealed partial class EnsnareableSystem
public void TryFree(EntityUid target, EnsnaringComponent component, EntityUid? user = null)
{
//Don't do anything if they don't have the ensnareable component.
if (!TryComp<EnsnareableComponent>(target, out var ensnareable))
if (!HasComp<EnsnareableComponent>(target))
return;
if (component.CancelToken != null)
@@ -132,7 +131,7 @@ public sealed partial class EnsnareableSystem
UpdateAlert(ensnareable);
var ev = new EnsnareRemoveEvent();
RaiseLocalEvent(component.Owner, ev, false);
RaiseLocalEvent(component.Owner, ev);
}
public void UpdateAlert(EnsnareableComponent component)

View File

@@ -44,7 +44,7 @@ public sealed partial class EnsnareableSystem : SharedEnsnareableSystem
UpdateAlert(component);
var ev = new EnsnareRemoveEvent();
RaiseLocalEvent(uid, ev, false);
RaiseLocalEvent(uid, ev);
ensnaring.CancelToken = null;
}

View File

@@ -6,6 +6,7 @@ namespace Content.Shared.Ensnaring;
public abstract class SharedEnsnareableSystem : EntitySystem
{
[Dependency] private readonly MovementSpeedModifierSystem _speedModifier = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
public override void Initialize()
{
@@ -25,7 +26,7 @@ public abstract class SharedEnsnareableSystem : EntitySystem
_speedModifier.RefreshMovementSpeedModifiers(uid);
var ev = new EnsnaredChangedEvent(component.IsEnsnared);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
}
private void OnEnsnareRemove(EntityUid uid, SharedEnsnareableComponent component, EnsnareRemoveEvent args)
@@ -33,7 +34,7 @@ public abstract class SharedEnsnareableSystem : EntitySystem
_speedModifier.RefreshMovementSpeedModifiers(uid);
var ev = new EnsnaredChangedEvent(component.IsEnsnared);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
}
private void OnEnsnareChange(EntityUid uid, SharedEnsnareableComponent component, EnsnaredChangedEvent args)
@@ -41,12 +42,9 @@ public abstract class SharedEnsnareableSystem : EntitySystem
UpdateAppearance(uid, component);
}
private void UpdateAppearance(EntityUid uid, SharedEnsnareableComponent? component, AppearanceComponent? appearance = null)
private void UpdateAppearance(EntityUid uid, SharedEnsnareableComponent component, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref component, ref appearance, false))
return;
appearance.SetData(EnsnareableVisuals.IsEnsnared, component.IsEnsnared);
Appearance.SetData(uid, EnsnareableVisuals.IsEnsnared, component.IsEnsnared, appearance);
}
private void MovementSpeedModify(EntityUid uid, SharedEnsnareableComponent component, RefreshMovementSpeedModifiersEvent args)

View File

@@ -8,6 +8,8 @@ namespace Content.Shared.Foldable;
[UsedImplicitly]
public abstract class SharedFoldableSystem : EntitySystem
{
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
public override void Initialize()
{
base.Initialize();
@@ -47,9 +49,7 @@ public abstract class SharedFoldableSystem : EntitySystem
{
component.IsFolded = folded;
Dirty(component);
if (TryComp(component.Owner, out AppearanceComponent? appearance))
appearance.SetData(FoldedVisuals.State, folded);
Appearance.SetData(component.Owner, FoldedVisuals.State, folded);
}
private void OnInsertEvent(EntityUid uid, FoldableComponent component, ContainerGettingInsertedAttemptEvent args)

View File

@@ -16,11 +16,11 @@ namespace Content.Shared.Movement.Systems;
public abstract class SharedJetpackSystem : EntitySystem
{
[Dependency] protected readonly IMapManager MapManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly INetManager _network = default!;
[Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] protected readonly MovementSpeedModifierSystem MovementSpeedModifier = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] private readonly SharedPopupSystem _popups = default!;
public override void Initialize()
@@ -181,8 +181,7 @@ public abstract class SharedJetpackSystem : EntitySystem
MovementSpeedModifier.RefreshMovementSpeedModifiers(user.Value);
}
TryComp<AppearanceComponent>(component.Owner, out var appearance);
appearance?.SetData(JetpackVisuals.Enabled, enabled);
Appearance.SetData(component.Owner, JetpackVisuals.Enabled, enabled);
Dirty(component);
}

View File

@@ -17,6 +17,7 @@ namespace Content.Shared.SubFloor
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly TrayScannerSystem _trayScannerSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
public override void Initialize()
{
@@ -166,15 +167,19 @@ namespace Content.Shared.SubFloor
SubFloorHideComponent? hideComp = null,
AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref hideComp, ref appearance, false))
if (!Resolve(uid, ref hideComp, false))
return;
appearance.SetData(SubFloorVisuals.Covered, hideComp.IsUnderCover);
appearance.SetData(SubFloorVisuals.ScannerRevealed, hideComp.RevealedBy.Count != 0);
if (hideComp.BlockAmbience && hideComp.IsUnderCover)
_ambientSoundSystem.SetAmbience(uid, false);
else if (hideComp.BlockAmbience && !hideComp.IsUnderCover)
_ambientSoundSystem.SetAmbience(uid, true);
if (Resolve(uid, ref appearance, false))
{
Appearance.SetData(uid, SubFloorVisuals.Covered, hideComp.IsUnderCover, appearance);
Appearance.SetData(uid, SubFloorVisuals.ScannerRevealed, hideComp.RevealedBy.Count != 0, appearance);
}
}
}

View File

@@ -17,6 +17,7 @@ namespace Content.Shared.Vehicle;
/// </summary>
public abstract partial class SharedVehicleSystem : EntitySystem
{
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] private readonly MovementSpeedModifierSystem _modifier = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
@@ -134,10 +135,7 @@ public abstract partial class SharedVehicleSystem : EntitySystem
/// </summary>
protected void UpdateDrawDepth(EntityUid uid, int drawDepth)
{
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
appearance.SetData(VehicleVisuals.DrawDepth, drawDepth);
Appearance.SetData(uid, VehicleVisuals.DrawDepth, drawDepth);
}
/// <summary>
@@ -145,10 +143,7 @@ public abstract partial class SharedVehicleSystem : EntitySystem
/// </summary>
protected void UpdateAutoAnimate(EntityUid uid, bool autoAnimate)
{
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
appearance.SetData(VehicleVisuals.AutoAnimate, autoAnimate);
Appearance.SetData(uid, VehicleVisuals.AutoAnimate, autoAnimate);
}
}

View File

@@ -82,10 +82,12 @@ public abstract partial class SharedGunSystem
protected void UpdateBatteryAppearance(EntityUid uid, BatteryAmmoProviderComponent component)
{
if (!TryComp<AppearanceComponent>(uid, out var appearance)) return;
appearance.SetData(AmmoVisuals.HasAmmo, component.Shots != 0);
appearance.SetData(AmmoVisuals.AmmoCount, component.Shots);
appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity);
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
Appearance.SetData(uid, AmmoVisuals.HasAmmo, component.Shots != 0, appearance);
Appearance.SetData(uid, AmmoVisuals.AmmoCount, component.Shots, appearance);
Appearance.SetData(uid, AmmoVisuals.AmmoMax, component.Capacity, appearance);
}
private IShootable GetShootable(BatteryAmmoProviderComponent component, EntityCoordinates coordinates)

View File

@@ -110,7 +110,7 @@ public abstract partial class SharedGunSystem
}
else
{
appearance?.SetData(AmmoVisuals.MagLoaded, false);
Appearance.SetData(uid, AmmoVisuals.MagLoaded, false, appearance);
return;
}

View File

@@ -39,6 +39,7 @@ public abstract partial class SharedGunSystem : EntitySystem
[Dependency] protected readonly DamageableSystem Damageable = default!;
[Dependency] private readonly ItemSlotsSystem _slots = default!;
[Dependency] protected readonly SharedActionsSystem Actions = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
[Dependency] protected readonly SharedContainerSystem Containers = default!;
[Dependency] protected readonly SharedPhysicsSystem Physics = default!;
@@ -310,8 +311,7 @@ public abstract partial class SharedGunSystem : EntitySystem
Dirty(cartridge);
cartridge.Spent = spent;
if (!TryComp<AppearanceComponent>(cartridge.Owner, out var appearance)) return;
appearance.SetData(AmmoVisuals.Spent, spent);
Appearance.SetData(cartridge.Owner, AmmoVisuals.Spent, spent);
}
/// <summary>