Grappling fixes (#23709)
This commit is contained in:
@@ -16,7 +16,6 @@ using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Weapons.Misc;
|
||||
|
||||
@@ -27,6 +26,7 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedJointSystem _joints = default!;
|
||||
[Dependency] private readonly SharedGunSystem _gun = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
|
||||
public const string GrapplingJoint = "grappling";
|
||||
@@ -48,7 +48,8 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
||||
|
||||
private void OnGrappleJointRemoved(EntityUid uid, GrapplingProjectileComponent component, JointRemovedEvent args)
|
||||
{
|
||||
QueueDel(uid);
|
||||
if (_netManager.IsServer)
|
||||
QueueDel(uid);
|
||||
}
|
||||
|
||||
private void OnGrapplingShot(EntityUid uid, GrapplingGunComponent component, ref GunShotEvent args)
|
||||
@@ -58,12 +59,12 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
||||
if (!HasComp<GrapplingProjectileComponent>(shotUid))
|
||||
continue;
|
||||
|
||||
//todo: this doesn't actually support multigrapple
|
||||
// At least show the visuals.
|
||||
component.Projectile = shotUid.Value;
|
||||
Dirty(uid, component);
|
||||
var visuals = EnsureComp<JointVisualsComponent>(shotUid.Value);
|
||||
visuals.Sprite =
|
||||
new SpriteSpecifier.Rsi(new ResPath("Objects/Weapons/Guns/Launchers/grappling_gun.rsi"), "rope");
|
||||
visuals.Sprite = component.RopeSprite;
|
||||
visuals.OffsetA = new Vector2(0f, 0.5f);
|
||||
visuals.Target = uid;
|
||||
Dirty(shotUid.Value, visuals);
|
||||
@@ -71,6 +72,7 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
||||
|
||||
TryComp<AppearanceComponent>(uid, out var appearance);
|
||||
_appearance.SetData(uid, SharedTetherGunSystem.TetherVisualsStatus.Key, false, appearance);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnGrapplingDeselected(EntityUid uid, GrapplingGunComponent component, HandDeselectedEvent args)
|
||||
@@ -117,23 +119,21 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
||||
if (!Timing.IsFirstTimePredicted || args.Handled)
|
||||
return;
|
||||
|
||||
if (Deleted(component.Projectile))
|
||||
return;
|
||||
|
||||
_audio.PlayPredicted(component.CycleSound, uid, args.User);
|
||||
_appearance.SetData(uid, SharedTetherGunSystem.TetherVisualsStatus.Key, true);
|
||||
|
||||
TryComp<AppearanceComponent>(uid, out var appearance);
|
||||
_appearance.SetData(uid, SharedTetherGunSystem.TetherVisualsStatus.Key, true, appearance);
|
||||
SetReeling(uid, component, false, args.User);
|
||||
|
||||
if (!Deleted(component.Projectile))
|
||||
if (_netManager.IsServer)
|
||||
{
|
||||
if (_netManager.IsServer)
|
||||
{
|
||||
QueueDel(component.Projectile.Value);
|
||||
}
|
||||
|
||||
component.Projectile = null;
|
||||
Dirty(uid, component);
|
||||
QueueDel(component.Projectile.Value);
|
||||
}
|
||||
|
||||
component.Projectile = null;
|
||||
SetReeling(uid, component, false, args.User);
|
||||
_gun.ChangeBasicEntityAmmoCount(uid, 1);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user