From a89af44f5691baa89f43571d996ea110667db174 Mon Sep 17 00:00:00 2001 From: J Date: Fri, 18 Apr 2025 14:28:40 +0000 Subject: [PATCH] Weapons warnings cleanup (#36164) * Weapons warnings cleanup * Changes to audio on Reflection stuff --- .../Weapons/Melee/MeleeThrowOnHitSystem.cs | 4 ---- .../SharedGunSystem.ChamberMagazine.cs | 2 +- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 7 +++--- .../Weapons/Reflect/ReflectComponent.cs | 10 ++++----- .../Weapons/Reflect/ReflectSystem.cs | 22 ++++++++++--------- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs b/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs index bc95be926a..035432ef85 100644 --- a/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs +++ b/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs @@ -1,12 +1,9 @@ -using Content.Shared.Construction.Components; using Content.Shared.Stunnable; using Content.Shared.Throwing; using Content.Shared.Timing; using Content.Shared.Weapons.Melee.Components; using Content.Shared.Weapons.Melee.Events; -using Robust.Shared.Physics; using Robust.Shared.Physics.Components; -using Robust.Shared.Physics.Systems; using System.Numerics; namespace Content.Shared.Weapons.Melee; @@ -17,7 +14,6 @@ namespace Content.Shared.Weapons.Melee; public sealed class MeleeThrowOnHitSystem : EntitySystem { [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly UseDelaySystem _delay = default!; [Dependency] private readonly SharedStunSystem _stun = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs index 3060e2c1a9..39014d8248 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs @@ -184,7 +184,7 @@ public abstract partial class SharedGunSystem // The problem is client will dump the cartridge on the ground and the new server state // won't correspond due to randomness so looks weird // but we also need to always take it from the chamber or else ammocount won't be correct. - TransformSystem.DetachParentToNull(chambered.Value, Transform(chambered.Value)); + TransformSystem.DetachEntity(chambered.Value, Transform(chambered.Value)); } UpdateAmmoCount(uid); diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index ac6f27f7e9..8ed9e4949e 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -27,6 +27,7 @@ using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Network; +using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; using Robust.Shared.Prototypes; @@ -462,7 +463,7 @@ public abstract partial class SharedGunSystem : EntitySystem var coordinates = xform.Coordinates; coordinates = coordinates.Offset(offsetPos); - TransformSystem.SetLocalRotation(xform, Random.NextAngle()); + TransformSystem.SetLocalRotation(entity, Random.NextAngle(), xform); TransformSystem.SetCoordinates(entity, xform, coordinates); // decides direction the casing ejects and only when not cycling @@ -510,8 +511,8 @@ public abstract partial class SharedGunSystem : EntitySystem public void CauseImpulse(EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, EntityUid user, PhysicsComponent userPhysics) { - var fromMap = fromCoordinates.ToMapPos(EntityManager, TransformSystem); - var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem); + var fromMap = TransformSystem.ToMapCoordinates(fromCoordinates).Position; + var toMap = TransformSystem.ToMapCoordinates(toCoordinates).Position; var shotDirection = (toMap - fromMap).Normalized(); const float impulseStrength = 25.0f; diff --git a/Content.Shared/Weapons/Reflect/ReflectComponent.cs b/Content.Shared/Weapons/Reflect/ReflectComponent.cs index 8418c1f3ef..703d8904dc 100644 --- a/Content.Shared/Weapons/Reflect/ReflectComponent.cs +++ b/Content.Shared/Weapons/Reflect/ReflectComponent.cs @@ -13,20 +13,20 @@ public sealed partial class ReflectComponent : Component /// /// What we reflect. /// - [ViewVariables(VVAccess.ReadWrite), DataField("reflects")] + [ViewVariables(VVAccess.ReadWrite), DataField] public ReflectType Reflects = ReflectType.Energy | ReflectType.NonEnergy; /// /// Probability for a projectile to be reflected. /// - [DataField("reflectProb"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] + [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float ReflectProb = 0.25f; - [DataField("spread"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] + [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Angle Spread = Angle.FromDegrees(45); - [DataField("soundOnReflect")] - public SoundSpecifier? SoundOnReflect = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg"); + [DataField] + public SoundSpecifier? SoundOnReflect = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg", AudioParams.Default.WithVariation(0.05f)); } [Flags] diff --git a/Content.Shared/Weapons/Reflect/ReflectSystem.cs b/Content.Shared/Weapons/Reflect/ReflectSystem.cs index 8be5f1be1f..3d3ded99ce 100644 --- a/Content.Shared/Weapons/Reflect/ReflectSystem.cs +++ b/Content.Shared/Weapons/Reflect/ReflectSystem.cs @@ -118,11 +118,7 @@ public sealed class ReflectSystem : EntitySystem var newRot = rotation.RotateVec(locRot.ToVec()); _transform.SetLocalRotation(projectile, newRot.ToAngle()); - if (_netManager.IsServer) - { - _popup.PopupEntity(Loc.GetString("reflect-shot"), user); - _audio.PlayPvs(reflect.SoundOnReflect, user, AudioHelpers.WithVariation(0.05f, _random)); - } + PlayAudioAndPopup(reflect, user); if (Resolve(projectile, ref projectileComp, false)) { @@ -154,6 +150,16 @@ public sealed class ReflectSystem : EntitySystem } } + private void PlayAudioAndPopup(ReflectComponent reflect, EntityUid user) + { + // Can probably be changed for prediction + if (_netManager.IsServer) + { + _popup.PopupEntity(Loc.GetString("reflect-shot"), user); + _audio.PlayPvs(reflect.SoundOnReflect, user); + } + } + private bool TryReflectHitscan( EntityUid user, EntityUid reflector, @@ -172,11 +178,7 @@ public sealed class ReflectSystem : EntitySystem return false; } - if (_netManager.IsServer) - { - _popup.PopupEntity(Loc.GetString("reflect-shot"), user); - _audio.PlayPvs(reflect.SoundOnReflect, user, AudioHelpers.WithVariation(0.05f, _random)); - } + PlayAudioAndPopup(reflect, user); var spread = _random.NextAngle(-reflect.Spread / 2, reflect.Spread / 2); newDirection = -spread.RotateVec(direction); -- 2.51.2