Fix some comp dirty / appearance warnings (#13193)

* Fix some comp dirty / appearance warnings

* also dis
This commit is contained in:
metalgearsloth
2022-12-28 03:58:53 +11:00
committed by GitHub
parent d3d8dde42c
commit 007b079330
12 changed files with 43 additions and 45 deletions

View File

@@ -108,7 +108,7 @@ public abstract class AlertsSystem : EntitySystem
AfterClearAlert(alertsComponent); AfterClearAlert(alertsComponent);
alertsComponent.Dirty(); Dirty(alertsComponent);
} }
/// <summary> /// <summary>
@@ -128,7 +128,7 @@ public abstract class AlertsSystem : EntitySystem
AfterClearAlert(alertsComponent); AfterClearAlert(alertsComponent);
alertsComponent.Dirty(); Dirty(alertsComponent);
} }
else else
{ {
@@ -210,7 +210,8 @@ public abstract class AlertsSystem : EntitySystem
private void HandleClickAlert(ClickAlertEvent msg, EntitySessionEventArgs args) private void HandleClickAlert(ClickAlertEvent msg, EntitySessionEventArgs args)
{ {
var player = args.SenderSession.AttachedEntity; var player = args.SenderSession.AttachedEntity;
if (player is null || !EntityManager.TryGetComponent<AlertsComponent>(player, out var alertComp)) return; if (player is null || !EntityManager.HasComponent<AlertsComponent>(player))
return;
if (!IsShowingAlert(player.Value, msg.Type)) if (!IsShowingAlert(player.Value, msg.Type))
{ {

View File

@@ -22,7 +22,7 @@ namespace Content.Shared.Electrocution
return; return;
insulated.SiemensCoefficient = siemensCoefficient; insulated.SiemensCoefficient = siemensCoefficient;
insulated.Dirty(); Dirty(insulated);
} }
private void OnInsulatedElectrocutionAttempt(EntityUid uid, InsulatedComponent insulated, ElectrocutionAttemptEvent args) private void OnInsulatedElectrocutionAttempt(EntityUid uid, InsulatedComponent insulated, ElectrocutionAttemptEvent args)

View File

@@ -82,7 +82,7 @@ namespace Content.Shared.Eye.Blinding
component.IsActive = true; component.IsActive = true;
blur.Magnitude += component.VisionBonus; blur.Magnitude += component.VisionBonus;
blur.Dirty(); Dirty(blur);
} }
private void OnGlassesUnequipped(EntityUid uid, VisionCorrectionComponent component, GotUnequippedEvent args) private void OnGlassesUnequipped(EntityUid uid, VisionCorrectionComponent component, GotUnequippedEvent args)
@@ -91,7 +91,7 @@ namespace Content.Shared.Eye.Blinding
return; return;
component.IsActive = false; component.IsActive = false;
blur.Magnitude -= component.VisionBonus; blur.Magnitude -= component.VisionBonus;
blur.Dirty(); Dirty(blur);
} }
private void OnGetState(EntityUid uid, BlurryVisionComponent component, ref ComponentGetState args) private void OnGetState(EntityUid uid, BlurryVisionComponent component, ref ComponentGetState args)
@@ -129,7 +129,8 @@ namespace Content.Shared.Eye.Blinding
{ {
var ev = new BlindnessChangedEvent(true); var ev = new BlindnessChangedEvent(true);
RaiseLocalEvent(uid, ev, false); RaiseLocalEvent(uid, ev, false);
} else if (blindable.Sources == 0 && oldSources > 0) }
else if (blindable.Sources == 0 && oldSources > 0)
{ {
var ev = new BlindnessChangedEvent(false); var ev = new BlindnessChangedEvent(false);
RaiseLocalEvent(uid, ev, false); RaiseLocalEvent(uid, ev, false);
@@ -149,7 +150,7 @@ namespace Content.Shared.Eye.Blinding
{ {
var blurry = EnsureComp<BlurryVisionComponent>(uid); var blurry = EnsureComp<BlurryVisionComponent>(uid);
blurry.Magnitude = (9 - blindable.EyeDamage); blurry.Magnitude = (9 - blindable.EyeDamage);
blurry.Dirty(); Dirty(blurry);
} }
else else
{ {

View File

@@ -9,6 +9,8 @@ namespace Content.Shared.Follower;
public sealed class FollowerSystem : EntitySystem public sealed class FollowerSystem : EntitySystem
{ {
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -71,7 +73,7 @@ public sealed class FollowerSystem : EntitySystem
followedComp.Following.Add(follower); followedComp.Following.Add(follower);
var xform = Transform(follower); var xform = Transform(follower);
xform.AttachParent(entity); _transform.SetParent(xform, entity);
xform.LocalPosition = Vector2.Zero; xform.LocalPosition = Vector2.Zero;
xform.LocalRotation = Angle.Zero; xform.LocalRotation = Angle.Zero;

View File

@@ -89,7 +89,7 @@ namespace Content.Shared.Jittering
var jitter = EnsureComp<JitteringComponent>(uid); var jitter = EnsureComp<JitteringComponent>(uid);
jitter.Amplitude = amplitude; jitter.Amplitude = amplitude;
jitter.Frequency = frequency; jitter.Frequency = frequency;
jitter.Dirty(); Dirty(jitter);
} }
} }
} }

View File

@@ -5,7 +5,6 @@ namespace Content.Shared.Localizations
public sealed class ContentLocalizationManager public sealed class ContentLocalizationManager
{ {
[Dependency] private readonly ILocalizationManager _loc = default!; [Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IEntityManager _ent = default!;
// If you want to change your codebase's language, do it here. // If you want to change your codebase's language, do it here.
private const string Culture = "en-US"; private const string Culture = "en-US";

View File

@@ -12,20 +12,9 @@ namespace Content.Shared.Projectiles
[ViewVariables(VVAccess.ReadWrite), DataField("impactEffect", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))] [ViewVariables(VVAccess.ReadWrite), DataField("impactEffect", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? ImpactEffect; public string? ImpactEffect;
private bool _ignoreShooter = true;
public EntityUid Shooter { get; set; } public EntityUid Shooter { get; set; }
public bool IgnoreShooter public bool IgnoreShooter = true;
{
get => _ignoreShooter;
set
{
if (_ignoreShooter == value) return;
_ignoreShooter = value;
Dirty();
}
}
[DataField("damage", required: true)] [DataField("damage", required: true)]
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]

View File

@@ -15,7 +15,6 @@ namespace Content.Shared.Standing
{ {
public sealed class StandingStateSystem : EntitySystem public sealed class StandingStateSystem : EntitySystem
{ {
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;

View File

@@ -11,10 +11,12 @@ namespace Content.Shared.SubFloor;
public sealed class TrayScannerSystem : EntitySystem public sealed class TrayScannerSystem : EntitySystem
{ {
[Dependency] private IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private SharedSubFloorHideSystem _subfloorSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedSubFloorHideSystem _subfloorSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private HashSet<EntityUid> _activeScanners = new(); private HashSet<EntityUid> _activeScanners = new();
private RemQueue<EntityUid> _invalidScanners = new(); private RemQueue<EntityUid> _invalidScanners = new();
@@ -50,7 +52,7 @@ public sealed class TrayScannerSystem : EntitySystem
if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance)) if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
{ {
appearance.SetData(TrayScannerVisual.Visual, scanner.Enabled == true ? TrayScannerVisual.On : TrayScannerVisual.Off); _appearance.SetData(uid, TrayScannerVisual.Visual, scanner.Enabled ? TrayScannerVisual.On : TrayScannerVisual.Off, appearance);
} }
} }
@@ -83,7 +85,8 @@ public sealed class TrayScannerSystem : EntitySystem
if (!_gameTiming.IsFirstTimePredicted) if (!_gameTiming.IsFirstTimePredicted)
return; return;
if (!_activeScanners.Any()) return; if (!_activeScanners.Any())
return;
foreach (var scanner in _activeScanners) foreach (var scanner in _activeScanners)
{ {
@@ -96,7 +99,9 @@ public sealed class TrayScannerSystem : EntitySystem
} }
foreach (var invalidScanner in _invalidScanners) foreach (var invalidScanner in _invalidScanners)
{
_activeScanners.Remove(invalidScanner); _activeScanners.Remove(invalidScanner);
}
_invalidScanners.List?.Clear(); _invalidScanners.List?.Clear();
} }
@@ -148,15 +153,16 @@ public sealed class TrayScannerSystem : EntitySystem
} }
var pos = transform.LocalPosition; var pos = transform.LocalPosition;
var parent = _transform.GetParent(transform);
// zero vector implies container // zero vector implies container
// //
// this means we should get the entity transform's parent // this means we should get the entity transform's parent
if (pos == Vector2.Zero if (pos == Vector2.Zero
&& transform.Parent != null && parent != null
&& _containerSystem.ContainsEntity(transform.ParentUid, uid)) && _containerSystem.ContainsEntity(transform.ParentUid, uid))
{ {
pos = transform.Parent.LocalPosition; pos = parent.LocalPosition;
// if this is also zero, we can check one more time // if this is also zero, we can check one more time
// //
@@ -165,7 +171,7 @@ public sealed class TrayScannerSystem : EntitySystem
// that doesn't work, just don't bother any further // that doesn't work, just don't bother any further
if (pos == Vector2.Zero) if (pos == Vector2.Zero)
{ {
var gpTransform = transform.Parent.Parent; var gpTransform = _transform.GetParent(parent);
if (gpTransform != null if (gpTransform != null
&& _containerSystem.ContainsEntity(gpTransform.Owner, transform.ParentUid)) && _containerSystem.ContainsEntity(gpTransform.Owner, transform.ParentUid))
{ {

View File

@@ -4,6 +4,7 @@ using Content.Shared.Movement.Components;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Shared.Throwing; namespace Content.Shared.Throwing;
@@ -20,6 +21,7 @@ public sealed class ThrowingSystem : EntitySystem
[Dependency] private readonly SharedGravitySystem _gravity = default!; [Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ThrownItemSystem _thrownSystem = default!; [Dependency] private readonly ThrownItemSystem _thrownSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!;
@@ -58,7 +60,7 @@ public sealed class ThrowingSystem : EntitySystem
comp.Thrower = user; comp.Thrower = user;
// Give it a l'il spin. // Give it a l'il spin.
if (!_tagSystem.HasTag(uid, "NoSpinOnThrow")) if (!_tagSystem.HasTag(uid, "NoSpinOnThrow"))
physics.ApplyAngularImpulse(ThrowAngularImpulse); _physics.ApplyAngularImpulse(physics, ThrowAngularImpulse);
else else
{ {
if (transform == null) if (transform == null)
@@ -73,24 +75,26 @@ public sealed class ThrowingSystem : EntitySystem
_interactionSystem.ThrownInteraction(user.Value, uid); _interactionSystem.ThrownInteraction(user.Value, uid);
var impulseVector = direction.Normalized * strength * physics.Mass; var impulseVector = direction.Normalized * strength * physics.Mass;
physics.ApplyLinearImpulse(impulseVector); _physics.ApplyLinearImpulse(physics, impulseVector);
// Estimate time to arrival so we can apply OnGround status and slow it much faster. // Estimate time to arrival so we can apply OnGround status and slow it much faster.
var time = (direction / strength).Length; var time = (direction / strength).Length;
if (time < FlyTime) if (time < FlyTime)
{ {
physics.BodyStatus = BodyStatus.OnGround; _physics.SetBodyStatus(physics, BodyStatus.OnGround);
_thrownSystem.LandComponent(comp); _thrownSystem.LandComponent(comp);
} }
else else
{ {
physics.BodyStatus = BodyStatus.InAir; _physics.SetBodyStatus(physics, BodyStatus.InAir);
Timer.Spawn(TimeSpan.FromSeconds(time - FlyTime), () => Timer.Spawn(TimeSpan.FromSeconds(time - FlyTime), () =>
{ {
if (physics.Deleted) return; if (physics.Deleted)
physics.BodyStatus = BodyStatus.OnGround; return;
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
_thrownSystem.LandComponent(comp); _thrownSystem.LandComponent(comp);
}); });
} }
@@ -105,7 +109,7 @@ public sealed class ThrowingSystem : EntitySystem
RaiseLocalEvent(physics.Owner, msg); RaiseLocalEvent(physics.Owner, msg);
if (!msg.Cancelled) if (!msg.Cancelled)
userPhysics.ApplyLinearImpulse(-impulseVector * pushbackRatio); _physics.ApplyLinearImpulse(userPhysics, -impulseVector * pushbackRatio);
} }
} }
} }

View File

@@ -10,9 +10,6 @@ namespace Content.Shared.Traits
[Prototype("trait")] [Prototype("trait")]
public sealed class TraitPrototype : IPrototype public sealed class TraitPrototype : IPrototype
{ {
private string _name = string.Empty;
private string? _description;
[ViewVariables] [ViewVariables]
[IdDataField] [IdDataField]
public string ID { get; } = default!; public string ID { get; } = default!;

View File

@@ -137,8 +137,8 @@ public abstract partial class SharedGunSystem
if (TryComp<AppearanceComponent>(magEnt, out var magAppearance)) if (TryComp<AppearanceComponent>(magEnt, out var magAppearance))
{ {
magAppearance.TryGetData<int>(AmmoVisuals.AmmoCount, out var addCount); Appearance.TryGetData<int>(magEnt, AmmoVisuals.AmmoCount, out var addCount, magAppearance);
magAppearance.TryGetData<int>(AmmoVisuals.AmmoMax, out var addCapacity); Appearance.TryGetData<int>(magEnt, AmmoVisuals.AmmoMax, out var addCapacity, magAppearance);
count += addCount; count += addCount;
capacity += addCapacity; capacity += addCapacity;
} }