Weapons warnings cleanup (#36164)

* Weapons warnings cleanup

* Changes to audio on Reflection stuff
This commit is contained in:
J
2025-04-18 14:28:40 +00:00
committed by GitHub
parent d068075c81
commit a89af44f56
5 changed files with 22 additions and 23 deletions

View File

@@ -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!;

View File

@@ -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);

View File

@@ -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;

View File

@@ -13,20 +13,20 @@ public sealed partial class ReflectComponent : Component
/// <summary>
/// What we reflect.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("reflects")]
[ViewVariables(VVAccess.ReadWrite), DataField]
public ReflectType Reflects = ReflectType.Energy | ReflectType.NonEnergy;
/// <summary>
/// Probability for a projectile to be reflected.
/// </summary>
[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]

View File

@@ -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);