Fix even more warnings (#11968)

Also more instances of someone using TryComp instead of HasComp

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2022-10-17 02:49:22 +11:00
committed by GitHub
parent 214d0c1774
commit 1782eb6ad7
22 changed files with 86 additions and 58 deletions

View File

@@ -54,7 +54,8 @@ namespace Content.Server.AME.Components
_injecting = false;
InjectionAmount = 2;
JarSlot = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-fuelJarContainer");
// TODO: Fix this bad name. I'd update maps but then people get mad.
JarSlot = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"AMEController-fuelJarContainer");
}
internal void OnUpdate(float frameTime)

View File

@@ -27,10 +27,10 @@ namespace Content.Server.Access.Systems
private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args)
{
if (!TryComp<AccessComponent>(args.Target, out var targetAccess) || !TryComp<IdCardComponent>(args.Target, out var targetIDCard) || args.Target == null)
if (!TryComp<AccessComponent>(args.Target, out var targetAccess) || !HasComp<IdCardComponent>(args.Target) || args.Target == null)
return;
if (!TryComp<AccessComponent>(uid, out var access) || !TryComp<IdCardComponent>(uid, out var idCard))
if (!TryComp<AccessComponent>(uid, out var access) || !HasComp<IdCardComponent>(uid))
return;
var beforeLength = access.Tags.Count;

View File

@@ -11,9 +11,11 @@ namespace Content.Server.Alert.Click
{
public void AlertClicked(EntityUid player)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MimePowersComponent?>(player, out var mimePowers))
var entManager = IoCManager.Resolve<IEntityManager>();
if (entManager.TryGetComponent<MimePowersComponent?>(player, out var mimePowers))
{
EntitySystem.Get<MimePowersSystem>().BreakVow(player, mimePowers);
entManager.System<MimePowersSystem>().BreakVow(player, mimePowers);
}
}
}

View File

@@ -14,9 +14,11 @@ namespace Content.Server.Alert.Click
{
public void AlertClicked(EntityUid player)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player, out FlammableComponent? flammable))
var entManager = IoCManager.Resolve<IEntityManager>();
if (entManager.TryGetComponent(player, out FlammableComponent? flammable))
{
EntitySystem.Get<FlammableSystem>().Resist(player, flammable);
entManager.System<FlammableSystem>().Resist(player, flammable);
}
}
}

View File

@@ -11,9 +11,11 @@ namespace Content.Server.Alert.Click
{
public void AlertClicked(EntityUid player)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MimePowersComponent?>(player, out var mimePowers))
var entManager = IoCManager.Resolve<IEntityManager>();
if (entManager.TryGetComponent<MimePowersComponent?>(player, out var mimePowers))
{
EntitySystem.Get<MimePowersSystem>().RetakeVow(player, mimePowers);
entManager.System<MimePowersSystem>().RetakeVow(player, mimePowers);
}
}
}

View File

@@ -15,12 +15,14 @@ namespace Content.Server.Alert.Click
{
public void AlertClicked(EntityUid player)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(player, null))
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.System<ActionBlockerSystem>().CanInteract(player, null))
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullableComponent?>(player, out var playerPullable))
if (entityManager.TryGetComponent<SharedPullableComponent?>(player, out var playerPullable))
{
EntitySystem.Get<SharedPullingSystem>().TryStopPull(playerPullable);
entityManager.System<SharedPullingSystem>().TryStopPull(playerPullable);
}
}
}

View File

@@ -14,10 +14,12 @@ namespace Content.Server.Alert.Click
{
public void AlertClicked(EntityUid player)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player, out PilotComponent? pilotComponent) &&
var entManager = IoCManager.Resolve<IEntityManager>();
if (entManager.TryGetComponent(player, out PilotComponent? pilotComponent) &&
pilotComponent.Console != null)
{
EntitySystem.Get<ShuttleConsoleSystem>().RemovePilot(pilotComponent);
entManager.System<ShuttleConsoleSystem>().RemovePilot(pilotComponent);
}
}
}

View File

@@ -14,9 +14,11 @@ namespace Content.Server.Alert.Click
{
public void AlertClicked(EntityUid player)
{
var ps = EntitySystem.Get<SharedPullingSystem>();
var entManager = IoCManager.Resolve<IEntityManager>();
var ps = entManager.System<SharedPullingSystem>();
var playerTarget = ps.GetPulled(player);
if (playerTarget != default && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerTarget, out SharedPullableComponent? playerPullable))
if (playerTarget != default && entManager.TryGetComponent(playerTarget, out SharedPullableComponent? playerPullable))
{
ps.TryStopPull(playerPullable);
}

View File

@@ -2,16 +2,17 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Access.Systems
{
public class SharedAgentIdCardSystem : EntitySystem
public abstract class SharedAgentIdCardSystem : EntitySystem
{
/// Just for friending for now
// Just for friending for now
}
/// <summary>
/// Key representing which <see cref="BoundUserInterface"/> is currently open.
/// Useful when there are multiple UI for an object. Here it's future-proofing only.
/// </summary>
[Serializable, NetSerializable]
public enum AgentIDCardUiKey
public enum AgentIDCardUiKey : byte
{
Key,
}

View File

@@ -6,10 +6,7 @@ namespace Content.Shared.Alert;
public abstract class AlertsSystem : EntitySystem
{
[Dependency]
private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly Dictionary<AlertType, AlertPrototype> _typeToAlert = new();

View File

@@ -14,6 +14,8 @@ public abstract class SharedHandheldLightSystem : EntitySystem
[Dependency] private readonly SharedItemSystem _itemSys = default!;
[Dependency] private readonly ClothingSystem _clothingSys = default!;
[Dependency] private readonly SharedActionsSystem _actionSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
@@ -52,7 +54,7 @@ public abstract class SharedHandheldLightSystem : EntitySystem
if (makeNoise)
{
var sound = component.Activated ? component.TurnOnSound : component.TurnOffSound;
SoundSystem.Play(sound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner);
_audio.PlayPvs(sound, component.Owner);
}
Dirty(component);
@@ -74,6 +76,6 @@ public abstract class SharedHandheldLightSystem : EntitySystem
if (component.ToggleAction != null)
_actionSystem.SetToggled(component.ToggleAction, component.Activated);
appearance.SetData(ToggleableLightVisuals.Enabled, component.Activated);
_appearance.SetData(uid, ToggleableLightVisuals.Enabled, component.Activated, appearance);
}
}

View File

@@ -43,14 +43,17 @@ public abstract partial class SharedMoverController
/// </summary>
private void OnMobCollision(Fixture ourFixture, Fixture otherFixture, float frameTime, Vector2 worldNormal)
{
if (!_pushingEnabled) return;
if (!_pushingEnabled)
return;
var otherBody = otherFixture.Body;
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard)
return;
if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out MobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out MobMoverComponent? mobMover) || worldNormal == Vector2.Zero)
return;
otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrengthVV * frameTime);
PhysicsSystem.ApplyLinearImpulse(otherBody, -worldNormal * mobMover.PushStrengthVV * frameTime);
}
}

View File

@@ -1,7 +1,7 @@
namespace Content.Shared.Paper
{
[RegisterComponent]
public class StampComponent : Component
public sealed class StampComponent : Component
{
/// <summary>
/// The loc string name that will be stamped to the piece of paper on examine.

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Alert;
using Content.Shared.GameTicking;
using Content.Shared.Gravity;
using Content.Shared.Input;
using Content.Shared.Movement.Components;
using Content.Shared.Physics.Pull;
@@ -19,6 +20,7 @@ namespace Content.Shared.Pulling
public abstract partial class SharedPullingSystem : EntitySystem
{
[Dependency] private readonly SharedPullingStateManagementSystem _pullSm = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
/// <summary>
@@ -197,7 +199,7 @@ namespace Content.Shared.Pulling
}
if (_containerSystem.IsEntityInContainer(player) ||
player.IsWeightless(entityManager: EntityManager))
_gravity.IsWeightless(player))
return false;
TryMoveTo(pullable, coords);

View File

@@ -3,6 +3,7 @@ using Robust.Shared.Physics;
using System.Linq;
using Content.Shared.Movement.Systems;
using Content.Shared.Revenant.Components;
using Robust.Shared.Physics.Systems;
namespace Content.Shared.Revenant.EntitySystems;
@@ -15,6 +16,7 @@ public abstract class SharedCorporealSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize()
{
@@ -38,8 +40,8 @@ public abstract class SharedCorporealSystem : EntitySystem
{
var fixture = fixtures.Fixtures.Values.First();
fixture.CollisionMask = (int) (CollisionGroup.SmallMobMask | CollisionGroup.GhostImpassable);
fixture.CollisionLayer = (int) CollisionGroup.SmallMobLayer;
_physics.SetCollisionMask(fixture, (int) (CollisionGroup.SmallMobMask | CollisionGroup.GhostImpassable));
_physics.SetCollisionLayer(fixture, (int) CollisionGroup.SmallMobLayer);
}
_movement.RefreshMovementSpeedModifiers(uid);
}
@@ -52,8 +54,8 @@ public abstract class SharedCorporealSystem : EntitySystem
{
var fixture = fixtures.Fixtures.Values.First();
fixture.CollisionMask = (int) CollisionGroup.GhostImpassable;
fixture.CollisionLayer = 0;
_physics.SetCollisionMask(fixture, (int) CollisionGroup.GhostImpassable);
_physics.SetCollisionLayer(fixture, 0);
}
component.MovementSpeedDebuff = 1; //just so we can avoid annoying code elsewhere
_movement.RefreshMovementSpeedModifiers(uid);

View File

@@ -14,6 +14,8 @@ namespace Content.Shared.Singularity
public abstract class SharedSingularitySystem : EntitySystem
{
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
public const string DeleteFixture = "DeleteCircle";
@@ -102,7 +104,7 @@ namespace Content.Shared.Singularity
// Prevents it getting stuck (see SingularityController.MoveSingulo)
if (physics != null)
{
physics.LinearVelocity = Vector2.Zero;
_physics.SetLinearVelocity(physics, Vector2.Zero);
}
}
@@ -113,10 +115,7 @@ namespace Content.Shared.Singularity
source.Intensity = singularity.RadsPerLevel * value;
}
if (EntityManager.TryGetComponent(singularity.Owner, out AppearanceComponent? appearance))
{
appearance.SetData(SingularityVisuals.Level, value);
}
_appearance.SetData(singularity.Owner, SingularityVisuals.Level, value);
if (physics != null)
{

View File

@@ -9,6 +9,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
namespace Content.Shared.Slippery
{
@@ -20,6 +21,7 @@ namespace Content.Shared.Slippery
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize()
{
@@ -43,7 +45,7 @@ namespace Content.Shared.Slippery
private void OnSlipperyGetState(EntityUid uid, SlipperyComponent component, ref ComponentGetState args)
{
args.State = new SlipperyComponentState(component.ParalyzeTime, component.LaunchForwardsMultiplier, component.SlipSound.GetSound());
args.State = new SlipperyComponentState(component.ParalyzeTime, component.LaunchForwardsMultiplier, _audio.GetSound(component.SlipSound));
}
private void HandleStepTrigger(EntityUid uid, SlipperyComponent component, ref StepTriggeredEvent args)
@@ -81,7 +83,7 @@ namespace Content.Shared.Slippery
return;
if (TryComp(other, out PhysicsComponent? physics))
physics.LinearVelocity *= component.LaunchForwardsMultiplier;
_physics.SetLinearVelocity(physics, physics.LinearVelocity * component.LaunchForwardsMultiplier);
var playSound = !_statusEffectsSystem.HasStatusEffect(other, "KnockedDown");

View File

@@ -15,7 +15,7 @@ namespace Content.Shared.Spawning
in Box2? box = null,
SharedPhysicsSystem? physicsManager = null)
{
physicsManager ??= EntitySystem.Get<SharedPhysicsSystem>();
physicsManager ??= entityManager.System<SharedPhysicsSystem>();
var mapCoordinates = coordinates.ToMap(entityManager);
return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager);
@@ -30,7 +30,7 @@ namespace Content.Shared.Spawning
SharedPhysicsSystem? collision = null)
{
var boxOrDefault = box.GetValueOrDefault(Box2.UnitCentered).Translated(coordinates.Position);
collision ??= EntitySystem.Get<SharedPhysicsSystem>();
collision ??= entityManager.System<SharedPhysicsSystem>();
foreach (var body in collision.GetCollidingEntities(coordinates.MapId, in boxOrDefault))
{

View File

@@ -9,15 +9,16 @@ using Content.Shared.Physics;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Network;
using Robust.Shared.Physics.Systems;
namespace Content.Shared.Standing
{
public sealed class StandingStateSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
@@ -96,7 +97,7 @@ namespace Content.Shared.Standing
continue;
standingState.ChangedFixtures.Add(key);
fixture.CollisionMask &= ~StandingCollisionLayer;
_physics.SetCollisionMask(fixture, fixture.CollisionMask & ~StandingCollisionLayer);
}
}
@@ -142,7 +143,7 @@ namespace Content.Shared.Standing
foreach (var key in standingState.ChangedFixtures)
{
if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture))
fixture.CollisionMask |= StandingCollisionLayer;
_physics.SetCollisionMask(fixture, fixture.CollisionMask | StandingCollisionLayer);
}
}
standingState.ChangedFixtures.Clear();

View File

@@ -8,6 +8,8 @@ namespace Content.Shared.Storage.EntitySystems
[UsedImplicitly]
public abstract class SharedItemCounterSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
/// <inheritdoc />
public override void Initialize()
{
@@ -19,30 +21,32 @@ namespace Content.Shared.Storage.EntitySystems
private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter,
EntInsertedIntoContainerMessage args)
{
if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) return;
if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent))
return;
var count = GetCount(args, itemCounter);
if (count == null)
return;
appearanceComponent.SetData(StackVisuals.Actual, count);
if (itemCounter.MaxAmount != null)
appearanceComponent.SetData(StackVisuals.MaxCount, itemCounter.MaxAmount);
_appearance.SetData(itemCounter.Owner, StackVisuals.Actual, count, appearanceComponent);
if (itemCounter.MaxAmount != null)
_appearance.SetData(itemCounter.Owner, StackVisuals.MaxCount, itemCounter.MaxAmount, appearanceComponent);
}
private void CounterEntityRemoved(EntityUid uid, ItemCounterComponent itemCounter,
EntRemovedFromContainerMessage args)
{
if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) return;
if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent))
return;
var count = GetCount(args, itemCounter);
if (count == null)
return;
appearanceComponent.SetData(StackVisuals.Actual, count);
_appearance.SetData(itemCounter.Owner, StackVisuals.Actual, count, appearanceComponent);
if (itemCounter.MaxAmount != null)
appearanceComponent.SetData(StackVisuals.MaxCount, itemCounter.MaxAmount);
_appearance.SetData(itemCounter.Owner, StackVisuals.MaxCount, itemCounter.MaxAmount, appearanceComponent);
}
protected abstract int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter);

View File

@@ -25,6 +25,7 @@ namespace Content.Shared.Stunnable
[Dependency] private readonly StandingStateSystem _standingStateSystem = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
/// <summary>
/// Friction modifier for knocked down players.
@@ -221,9 +222,7 @@ namespace Content.Shared.Stunnable
knocked.HelpTimer = knocked.HelpInterval/2f;
_statusEffectSystem.TryRemoveTime(uid, "KnockedDown", TimeSpan.FromSeconds(knocked.HelpInterval));
SoundSystem.Play(knocked.StunAttemptSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.05f));
_audio.PlayPredicted(knocked.StunAttemptSound, uid, args.User);
Dirty(knocked);
args.Handled = true;

View File

@@ -70,6 +70,9 @@
# - type: ExtensionCableReceiver
- type: PowerSupplier
supplyRate: 0
- type: ContainerContainer
containers:
AMEController-fuelJarContainer: !type:ContainerSlot {}
- type: entity
noSpawn: true