-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;
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!;
// 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);
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;
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
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;
/// <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]
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))
{
}
}
+ 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,
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);