Adds grappling gun (#16662)
74
Content.Client/Physics/JointVisualsOverlay.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using Content.Shared.Physics;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.Graphics;
|
||||||
|
using Robust.Shared.Enums;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Physics.Dynamics.Joints;
|
||||||
|
|
||||||
|
namespace Content.Client.Physics;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture on top of a joint.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class JointVisualsOverlay : Overlay
|
||||||
|
{
|
||||||
|
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
|
||||||
|
|
||||||
|
private IEntityManager _entManager;
|
||||||
|
|
||||||
|
private HashSet<Joint> _drawn = new();
|
||||||
|
|
||||||
|
public JointVisualsOverlay(IEntityManager entManager)
|
||||||
|
{
|
||||||
|
_entManager = entManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
|
{
|
||||||
|
_drawn.Clear();
|
||||||
|
var worldHandle = args.WorldHandle;
|
||||||
|
|
||||||
|
var spriteSystem = _entManager.System<SpriteSystem>();
|
||||||
|
var xformSystem = _entManager.System<SharedTransformSystem>();
|
||||||
|
var joints = _entManager.EntityQueryEnumerator<JointVisualsComponent, TransformComponent>();
|
||||||
|
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
|
while (joints.MoveNext(out var visuals, out var xform))
|
||||||
|
{
|
||||||
|
if (xform.MapID != args.MapId)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var other = visuals.Target;
|
||||||
|
|
||||||
|
if (!xformQuery.TryGetComponent(other, out var otherXform))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (xform.MapID != otherXform.MapID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var texture = spriteSystem.Frame0(visuals.Sprite);
|
||||||
|
var width = texture.Width / (float) EyeManager.PixelsPerMeter;
|
||||||
|
|
||||||
|
var coordsA = xform.Coordinates;
|
||||||
|
var coordsB = otherXform.Coordinates;
|
||||||
|
|
||||||
|
var rotA = xform.LocalRotation;
|
||||||
|
var rotB = otherXform.LocalRotation;
|
||||||
|
|
||||||
|
coordsA = coordsA.Offset(rotA.RotateVec(visuals.OffsetA));
|
||||||
|
coordsB = coordsB.Offset(rotB.RotateVec(visuals.OffsetB));
|
||||||
|
|
||||||
|
var posA = coordsA.ToMapPos(_entManager, xformSystem);
|
||||||
|
var posB = coordsB.ToMapPos(_entManager, xformSystem);
|
||||||
|
var diff = (posB - posA);
|
||||||
|
var length = diff.Length;
|
||||||
|
|
||||||
|
var midPoint = diff / 2f + posA;
|
||||||
|
var angle = (posB - posA).ToWorldAngle();
|
||||||
|
var box = new Box2(-width / 2f, -length / 2f, width / 2f, length / 2f);
|
||||||
|
var rotate = new Box2Rotated(box.Translated(midPoint), angle, midPoint);
|
||||||
|
|
||||||
|
worldHandle.DrawTextureRect(texture, rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Content.Client/Physics/JointVisualsSystem.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Robust.Client.Graphics;
|
||||||
|
|
||||||
|
namespace Content.Client.Physics;
|
||||||
|
|
||||||
|
public sealed class JointVisualsSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IOverlayManager _overlay = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
_overlay.AddOverlay(new JointVisualsOverlay(EntityManager));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Shutdown()
|
||||||
|
{
|
||||||
|
base.Shutdown();
|
||||||
|
_overlay.RemoveOverlay<JointVisualsOverlay>();
|
||||||
|
}
|
||||||
|
}
|
||||||
58
Content.Client/Weapons/Misc/GrapplingGunSystem.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System.Net;
|
||||||
|
using Content.Client.Hands.Systems;
|
||||||
|
using Content.Shared.CombatMode;
|
||||||
|
using Content.Shared.Weapons.Misc;
|
||||||
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.Player;
|
||||||
|
using Robust.Shared.Input;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Physics.Dynamics.Joints;
|
||||||
|
|
||||||
|
namespace Content.Client.Weapons.Misc;
|
||||||
|
|
||||||
|
public sealed class GrapplingGunSystem : SharedGrapplingGunSystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly HandsSystem _hands = default!;
|
||||||
|
[Dependency] private readonly InputSystem _input = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _player = default!;
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
base.Update(frameTime);
|
||||||
|
|
||||||
|
// Oh boy another input handler.
|
||||||
|
// If someone thinks of a better way to unify this please tell me.
|
||||||
|
if (!Timing.IsFirstTimePredicted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var local = _player.LocalPlayer?.ControlledEntity;
|
||||||
|
var handUid = _hands.GetActiveHandEntity();
|
||||||
|
|
||||||
|
if (!TryComp<GrapplingGunComponent>(handUid, out var grappling))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryComp<JointComponent>(handUid, out var jointComp) ||
|
||||||
|
!jointComp.GetJoints.TryGetValue(GrapplingJoint, out var joint) ||
|
||||||
|
joint is not DistanceJoint distance)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance.MaxLength <= distance.MinLength)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var reelKey = _input.CmdStates.GetState(EngineKeyFunctions.UseSecondary) == BoundKeyState.Down;
|
||||||
|
|
||||||
|
if (!TryComp<CombatModeComponent>(local, out var combatMode) ||
|
||||||
|
!combatMode.IsInCombatMode)
|
||||||
|
{
|
||||||
|
reelKey = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grappling.Reeling == reelKey)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RaisePredictiveEvent(new RequestGrapplingReelMessage(reelKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
|
using Content.Shared.Weapons.Ranged.Events;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Client.Weapons.Ranged.Systems;
|
namespace Content.Client.Weapons.Ranged.Systems;
|
||||||
@@ -19,9 +20,10 @@ public sealed partial class GunSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Cycle(BallisticAmmoProviderComponent component, MapCoordinates coordinates)
|
protected override void Cycle(EntityUid uid, BallisticAmmoProviderComponent component, MapCoordinates coordinates)
|
||||||
{
|
{
|
||||||
if (!Timing.IsFirstTimePredicted) return;
|
if (!Timing.IsFirstTimePredicted)
|
||||||
|
return;
|
||||||
|
|
||||||
EntityUid? ent = null;
|
EntityUid? ent = null;
|
||||||
|
|
||||||
@@ -43,5 +45,8 @@ public sealed partial class GunSystem
|
|||||||
|
|
||||||
if (ent != null && ent.Value.IsClientSide())
|
if (ent != null && ent.Value.IsClientSide())
|
||||||
Del(ent.Value);
|
Del(ent.Value);
|
||||||
|
|
||||||
|
var cycledEvent = new GunCycledEvent();
|
||||||
|
RaiseLocalEvent(uid, ref cycledEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,8 +173,10 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
||||||
EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, EntityUid? user = null, bool throwItems = false)
|
EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, out bool userImpulse, EntityUid? user = null, bool throwItems = false)
|
||||||
{
|
{
|
||||||
|
userImpulse = true;
|
||||||
|
|
||||||
// Rather than splitting client / server for every ammo provider it's easier
|
// Rather than splitting client / server for every ammo provider it's easier
|
||||||
// to just delete the spawned entities. This is for programmer sanity despite the wasted perf.
|
// to just delete the spawned entities. This is for programmer sanity despite the wasted perf.
|
||||||
// This also means any ammo specific stuff can be grabbed as necessary.
|
// This also means any ammo specific stuff can be grabbed as necessary.
|
||||||
@@ -207,6 +209,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
userImpulse = false;
|
||||||
Audio.PlayPredicted(gun.SoundEmpty, gunUid, user);
|
Audio.PlayPredicted(gun.SoundEmpty, gunUid, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ namespace Content.Server.Singularity.EntitySystems
|
|||||||
_projectile.SetShooter(proj, uid);
|
_projectile.SetShooter(proj, uid);
|
||||||
|
|
||||||
var targetPos = new EntityCoordinates(uid, (0, -1));
|
var targetPos = new EntityCoordinates(uid, (0, -1));
|
||||||
_gun.Shoot(uid, guncomp, ent, xform.Coordinates, targetPos);
|
_gun.Shoot(uid, guncomp, ent, xform.Coordinates, targetPos, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAppearance(EmitterComponent component)
|
private void UpdateAppearance(EmitterComponent component)
|
||||||
|
|||||||
8
Content.Server/Weapons/Misc/GrapplingGunSystem.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Content.Shared.Weapons.Misc;
|
||||||
|
|
||||||
|
namespace Content.Server.Weapons.Misc;
|
||||||
|
|
||||||
|
public sealed class GrapplingGunSystem : SharedGrapplingGunSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
|
using Content.Shared.Weapons.Ranged.Events;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Server.Weapons.Ranged.Systems;
|
namespace Content.Server.Weapons.Ranged.Systems;
|
||||||
|
|
||||||
public sealed partial class GunSystem
|
public sealed partial class GunSystem
|
||||||
{
|
{
|
||||||
protected override void Cycle(BallisticAmmoProviderComponent component, MapCoordinates coordinates)
|
protected override void Cycle(EntityUid uid, BallisticAmmoProviderComponent component, MapCoordinates coordinates)
|
||||||
{
|
{
|
||||||
EntityUid? ent = null;
|
EntityUid? ent = null;
|
||||||
|
|
||||||
@@ -27,5 +28,8 @@ public sealed partial class GunSystem
|
|||||||
|
|
||||||
if (ent != null)
|
if (ent != null)
|
||||||
EjectCartridge(ent.Value);
|
EjectCartridge(ent.Value);
|
||||||
|
|
||||||
|
var cycledEvent = new GunCycledEvent();
|
||||||
|
RaiseLocalEvent(uid, ref cycledEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,10 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
||||||
EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, EntityUid? user = null, bool throwItems = false)
|
EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, out bool userImpulse, EntityUid? user = null, bool throwItems = false)
|
||||||
{
|
{
|
||||||
|
userImpulse = true;
|
||||||
|
|
||||||
// Try a clumsy roll
|
// Try a clumsy roll
|
||||||
// TODO: Who put this here
|
// TODO: Who put this here
|
||||||
if (TryComp<ClumsyComponent>(user, out var clumsy))
|
if (TryComp<ClumsyComponent>(user, out var clumsy))
|
||||||
@@ -88,6 +90,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
PopupSystem.PopupEntity(Loc.GetString("gun-clumsy"), user.Value);
|
PopupSystem.PopupEntity(Loc.GetString("gun-clumsy"), user.Value);
|
||||||
_adminLogger.Add(LogType.EntityDelete, LogImpact.Medium, $"Clumsy fire by {ToPrettyString(user.Value)} deleted {ToPrettyString(gunUid)}");
|
_adminLogger.Add(LogType.EntityDelete, LogImpact.Medium, $"Clumsy fire by {ToPrettyString(user.Value)} deleted {ToPrettyString(gunUid)}");
|
||||||
Del(gunUid);
|
Del(gunUid);
|
||||||
|
userImpulse = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,6 +164,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
userImpulse = false;
|
||||||
Audio.PlayPredicted(gun.SoundEmpty, gunUid, user);
|
Audio.PlayPredicted(gun.SoundEmpty, gunUid, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,7 @@ namespace Content.Shared.Movement.Events;
|
|||||||
/// Raised on an entity to check if it can move while weightless.
|
/// Raised on an entity to check if it can move while weightless.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public struct CanWeightlessMoveEvent
|
public record struct CanWeightlessMoveEvent(EntityUid Uid)
|
||||||
{
|
{
|
||||||
public bool CanMove = false;
|
public bool CanMove = false;
|
||||||
|
|
||||||
public CanWeightlessMoveEvent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ namespace Content.Shared.Movement.Systems
|
|||||||
|
|
||||||
if (!touching)
|
if (!touching)
|
||||||
{
|
{
|
||||||
var ev = new CanWeightlessMoveEvent();
|
var ev = new CanWeightlessMoveEvent(uid);
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev, true);
|
||||||
// No gravity: is our entity touching anything?
|
// No gravity: is our entity touching anything?
|
||||||
touching = ev.CanMove;
|
touching = ev.CanMove;
|
||||||
|
|
||||||
|
|||||||
29
Content.Shared/Physics/JointVisualsComponent.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
|
namespace Content.Shared.Physics;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Just draws a generic line between this entity and the target.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
|
public sealed partial class JointVisualsComponent : Component
|
||||||
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("sprite", required: true), AutoNetworkedField]
|
||||||
|
public SpriteSpecifier Sprite = default!;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("target"), AutoNetworkedField]
|
||||||
|
public EntityUid? Target;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Offset from Body A.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("offsetA"), AutoNetworkedField]
|
||||||
|
public Vector2 OffsetA;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Offset from Body B.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("offsetB"), AutoNetworkedField]
|
||||||
|
public Vector2 OffsetB;
|
||||||
|
}
|
||||||
12
Content.Shared/Projectiles/EmbeddableProjectileComponent.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Weapons.Ranged.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embeds this entity inside of the hit target.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed class EmbeddableProjectileComponent : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
7
Content.Shared/Projectiles/ProjectileEmbedEvent.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Content.Shared.Projectiles;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised directed on an entity when it embeds into something.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public readonly record struct ProjectileEmbedEvent(EntityUid Shooter, EntityUid Weapon, EntityUid Embedded);
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
using Content.Shared.Projectiles;
|
using Content.Shared.Projectiles;
|
||||||
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Events;
|
using Robust.Shared.Physics.Events;
|
||||||
|
using Robust.Shared.Physics.Systems;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Projectiles
|
namespace Content.Shared.Projectiles
|
||||||
@@ -9,10 +12,26 @@ namespace Content.Shared.Projectiles
|
|||||||
{
|
{
|
||||||
public const string ProjectileFixture = "projectile";
|
public const string ProjectileFixture = "projectile";
|
||||||
|
|
||||||
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<ProjectileComponent, PreventCollideEvent>(PreventCollision);
|
SubscribeLocalEvent<ProjectileComponent, PreventCollideEvent>(PreventCollision);
|
||||||
|
SubscribeLocalEvent<EmbeddableProjectileComponent, StartCollideEvent>(OnEmbedCollide);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEmbedCollide(EntityUid uid, EmbeddableProjectileComponent component, ref StartCollideEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<ProjectileComponent>(uid, out var projectile))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_physics.SetLinearVelocity(uid, Vector2.Zero, body: args.OurBody);
|
||||||
|
_physics.SetBodyType(uid, BodyType.Static, body: args.OurBody);
|
||||||
|
_transform.SetParent(uid, args.OtherEntity);
|
||||||
|
var ev = new ProjectileEmbedEvent(projectile.Shooter, projectile.Weapon, args.OtherEntity);
|
||||||
|
RaiseLocalEvent(uid, ref ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PreventCollision(EntityUid uid, ProjectileComponent component, ref PreventCollideEvent args)
|
private void PreventCollision(EntityUid uid, ProjectileComponent component, ref PreventCollideEvent args)
|
||||||
@@ -25,7 +44,8 @@ namespace Content.Shared.Projectiles
|
|||||||
|
|
||||||
public void SetShooter(ProjectileComponent component, EntityUid uid)
|
public void SetShooter(ProjectileComponent component, EntityUid uid)
|
||||||
{
|
{
|
||||||
if (component.Shooter == uid) return;
|
if (component.Shooter == uid)
|
||||||
|
return;
|
||||||
|
|
||||||
component.Shooter = uid;
|
component.Shooter = uid;
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ using Robust.Shared.Containers;
|
|||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Physics.Events;
|
||||||
|
using Robust.Shared.Physics.Systems;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
|
|
||||||
namespace Content.Shared.Pulling
|
namespace Content.Shared.Pulling
|
||||||
@@ -22,6 +24,7 @@ namespace Content.Shared.Pulling
|
|||||||
[Dependency] private readonly SharedPullingStateManagementSystem _pullSm = default!;
|
[Dependency] private readonly SharedPullingStateManagementSystem _pullSm = default!;
|
||||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||||
|
[Dependency] private readonly SharedJointSystem _joints = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A mapping of pullers to the entity that they are pulling.
|
/// A mapping of pullers to the entity that they are pulling.
|
||||||
@@ -45,6 +48,7 @@ namespace Content.Shared.Pulling
|
|||||||
SubscribeLocalEvent<PullStoppedMessage>(OnPullStopped);
|
SubscribeLocalEvent<PullStoppedMessage>(OnPullStopped);
|
||||||
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerInsert);
|
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerInsert);
|
||||||
SubscribeLocalEvent<SharedPullableComponent, JointRemovedEvent>(OnJointRemoved);
|
SubscribeLocalEvent<SharedPullableComponent, JointRemovedEvent>(OnJointRemoved);
|
||||||
|
SubscribeLocalEvent<SharedPullableComponent, CollisionChangeEvent>(OnPullableCollisionChange);
|
||||||
|
|
||||||
SubscribeLocalEvent<SharedPullableComponent, PullStartedMessage>(PullableHandlePullStarted);
|
SubscribeLocalEvent<SharedPullableComponent, PullStartedMessage>(PullableHandlePullStarted);
|
||||||
SubscribeLocalEvent<SharedPullableComponent, PullStoppedMessage>(PullableHandlePullStopped);
|
SubscribeLocalEvent<SharedPullableComponent, PullStoppedMessage>(PullableHandlePullStopped);
|
||||||
@@ -56,6 +60,14 @@ namespace Content.Shared.Pulling
|
|||||||
.Register<SharedPullingSystem>();
|
.Register<SharedPullingSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPullableCollisionChange(EntityUid uid, SharedPullableComponent component, ref CollisionChangeEvent args)
|
||||||
|
{
|
||||||
|
if (component.PullJointId != null && !args.CanCollide)
|
||||||
|
{
|
||||||
|
_joints.RemoveJoint(uid, component.PullJointId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnJointRemoved(EntityUid uid, SharedPullableComponent component, JointRemovedEvent args)
|
private void OnJointRemoved(EntityUid uid, SharedPullableComponent component, JointRemovedEvent args)
|
||||||
{
|
{
|
||||||
if (component.Puller != args.OtherBody.Owner)
|
if (component.Puller != args.OtherBody.Owner)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Weapons.Misc;
|
||||||
|
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed class GrapplingProjectileComponent : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
230
Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
using Content.Shared.CombatMode;
|
||||||
|
using Content.Shared.Hands;
|
||||||
|
using Content.Shared.Hands.Components;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Movement.Events;
|
||||||
|
using Content.Shared.Physics;
|
||||||
|
using Content.Shared.Projectiles;
|
||||||
|
using Content.Shared.Timing;
|
||||||
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
|
using Content.Shared.Weapons.Ranged.Systems;
|
||||||
|
using Robust.Shared.Network;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Physics.Components;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public abstract class SharedGrapplingGunSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||||
|
[Dependency] private readonly INetManager _netManager = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedJointSystem _joints = default!;
|
||||||
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
|
[Dependency] private readonly UseDelaySystem _delay = default!;
|
||||||
|
|
||||||
|
public const string GrapplingJoint = "grappling";
|
||||||
|
|
||||||
|
public const float ReelRate = 2.5f;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<GrapplingProjectileComponent, ProjectileEmbedEvent>(OnGrappleCollide);
|
||||||
|
SubscribeLocalEvent<CanWeightlessMoveEvent>(OnWeightlessMove);
|
||||||
|
SubscribeAllEvent<RequestGrapplingReelMessage>(OnGrapplingReel);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<GrapplingGunComponent, GunShotEvent>(OnGrapplingShot);
|
||||||
|
SubscribeLocalEvent<GrapplingGunComponent, ActivateInWorldEvent>(OnGunActivate);
|
||||||
|
SubscribeLocalEvent<GrapplingGunComponent, HandDeselectedEvent>(OnGrapplingDeselected);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGrapplingShot(EntityUid uid, GrapplingGunComponent component, ref GunShotEvent args)
|
||||||
|
{
|
||||||
|
foreach (var (shotUid, _) in args.Ammo)
|
||||||
|
{
|
||||||
|
if (!HasComp<GrapplingProjectileComponent>(shotUid))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// At least show the visuals.
|
||||||
|
component.Projectile = shotUid.Value;
|
||||||
|
Dirty(component);
|
||||||
|
var visuals = EnsureComp<JointVisualsComponent>(shotUid.Value);
|
||||||
|
visuals.Sprite =
|
||||||
|
new SpriteSpecifier.Rsi(new ResPath("Objects/Weapons/Guns/Launchers/grappling_gun.rsi"), "rope");
|
||||||
|
visuals.OffsetA = new Vector2(0f, 0.5f);
|
||||||
|
visuals.Target = uid;
|
||||||
|
Dirty(visuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
TryComp<AppearanceComponent>(uid, out var appearance);
|
||||||
|
_appearance.SetData(uid, SharedTetherGunSystem.TetherVisualsStatus.Key, false, appearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGrapplingDeselected(EntityUid uid, GrapplingGunComponent component, HandDeselectedEvent args)
|
||||||
|
{
|
||||||
|
SetReeling(uid, component, false, args.User);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGrapplingReel(RequestGrapplingReelMessage msg, EntitySessionEventArgs args)
|
||||||
|
{
|
||||||
|
var player = args.SenderSession.AttachedEntity;
|
||||||
|
if (!TryComp<HandsComponent>(player, out var hands) ||
|
||||||
|
!TryComp<GrapplingGunComponent>(hands.ActiveHandEntity, out var grappling))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.Reeling &&
|
||||||
|
(!TryComp<CombatModeComponent>(player, out var combatMode) ||
|
||||||
|
!combatMode.IsInCombatMode))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetReeling(hands.ActiveHandEntity.Value, grappling, msg.Reeling, player.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnWeightlessMove(ref CanWeightlessMoveEvent ev)
|
||||||
|
{
|
||||||
|
if (ev.CanMove || !TryComp<JointRelayTargetComponent>(ev.Uid, out var relayComp))
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var relay in relayComp.Relayed)
|
||||||
|
{
|
||||||
|
if (TryComp<JointComponent>(relay, out var jointRelay) && jointRelay.GetJoints.ContainsKey(GrapplingJoint))
|
||||||
|
{
|
||||||
|
ev.CanMove = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGunActivate(EntityUid uid, GrapplingGunComponent component, ActivateInWorldEvent args)
|
||||||
|
{
|
||||||
|
if (!Timing.IsFirstTimePredicted || _delay.ActiveDelay(uid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_delay.BeginDelay(uid);
|
||||||
|
_audio.PlayPredicted(component.CycleSound, uid, args.User);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
QueueDel(component.Projectile.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
component.Projectile = null;
|
||||||
|
Dirty(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetReeling(EntityUid uid, GrapplingGunComponent component, bool value, EntityUid? user)
|
||||||
|
{
|
||||||
|
if (component.Reeling == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
if (Timing.IsFirstTimePredicted)
|
||||||
|
component.Stream = _audio.PlayPredicted(component.ReelSound, uid, user);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Timing.IsFirstTimePredicted)
|
||||||
|
{
|
||||||
|
component.Stream?.Stop();
|
||||||
|
component.Stream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component.Reeling = value;
|
||||||
|
Dirty(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
base.Update(frameTime);
|
||||||
|
|
||||||
|
var query = EntityQueryEnumerator<GrapplingGunComponent>();
|
||||||
|
|
||||||
|
while (query.MoveNext(out var uid, out var grappling))
|
||||||
|
{
|
||||||
|
if (!grappling.Reeling)
|
||||||
|
{
|
||||||
|
if (Timing.IsFirstTimePredicted)
|
||||||
|
{
|
||||||
|
// Just in case.
|
||||||
|
grappling.Stream?.Stop();
|
||||||
|
grappling.Stream = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TryComp<JointComponent>(uid, out var jointComp) ||
|
||||||
|
!jointComp.GetJoints.TryGetValue(GrapplingJoint, out var joint) ||
|
||||||
|
joint is not DistanceJoint distance)
|
||||||
|
{
|
||||||
|
SetReeling(uid, grappling, false, null);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This should be on engine.
|
||||||
|
distance.MaxLength = MathF.Max(distance.MinLength, distance.MaxLength - ReelRate * frameTime);
|
||||||
|
distance.Length = MathF.Min(distance.MaxLength, distance.Length);
|
||||||
|
|
||||||
|
_physics.WakeBody(joint.BodyAUid);
|
||||||
|
_physics.WakeBody(joint.BodyBUid);
|
||||||
|
|
||||||
|
if (jointComp.Relay != null)
|
||||||
|
{
|
||||||
|
_physics.WakeBody(jointComp.Relay.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dirty(jointComp);
|
||||||
|
|
||||||
|
if (distance.MaxLength.Equals(distance.MinLength))
|
||||||
|
{
|
||||||
|
SetReeling(uid, grappling, false, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGrappleCollide(EntityUid uid, GrapplingProjectileComponent component, ref ProjectileEmbedEvent args)
|
||||||
|
{
|
||||||
|
if (!Timing.IsFirstTimePredicted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var jointComp = EnsureComp<JointComponent>(uid);
|
||||||
|
var joint = _joints.CreateDistanceJoint(uid, args.Weapon, anchorA: new Vector2(0f, 0.5f), id: GrapplingJoint);
|
||||||
|
joint.MaxLength = joint.Length + 0.2f;
|
||||||
|
joint.Stiffness = 1f;
|
||||||
|
joint.MinLength = 0.35f;
|
||||||
|
// Setting velocity directly for mob movement fucks this so need to make them aware of it.
|
||||||
|
// joint.Breakpoint = 4000f;
|
||||||
|
Dirty(jointComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
protected sealed class RequestGrapplingReelMessage : EntityEventArgs
|
||||||
|
{
|
||||||
|
public bool Reeling;
|
||||||
|
|
||||||
|
public RequestGrapplingReelMessage(bool reeling)
|
||||||
|
{
|
||||||
|
Reeling = reeling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ public abstract partial class SharedTetherGunSystem
|
|||||||
{
|
{
|
||||||
// Pickup
|
// Pickup
|
||||||
if (TryTether(uid, args.Target.Value, args.User, component))
|
if (TryTether(uid, args.Target.Value, args.User, component))
|
||||||
TransformSystem.SetCoordinates(component.TetherEntity!.Value, new EntityCoordinates(uid, new Vector2(0.0f, -0.8f)));
|
TransformSystem.SetCoordinates(component.TetherEntity!.Value, new EntityCoordinates(uid, new Vector2(0f, 0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public sealed partial class BallisticAmmoProviderComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite), DataField("capacity")]
|
[ViewVariables(VVAccess.ReadWrite), DataField("capacity")]
|
||||||
public int Capacity = 30;
|
public int Capacity = 30;
|
||||||
|
|
||||||
|
public int Count => UnspawnedCount + Container.ContainedEntities.Count;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("unspawnedCount")]
|
[ViewVariables(VVAccess.ReadWrite), DataField("unspawnedCount")]
|
||||||
[AutoNetworkedField]
|
[AutoNetworkedField]
|
||||||
public int UnspawnedCount;
|
public int UnspawnedCount;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Weapons.Ranged.Components;
|
||||||
|
|
||||||
|
// I have tried to make this as generic as possible but "delete joint on cycle / right-click reels in" is very specific behavior.
|
||||||
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
|
public sealed partial class GrapplingGunComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("jointId"), AutoNetworkedField]
|
||||||
|
public string Joint = string.Empty;
|
||||||
|
|
||||||
|
[DataField("projectile")] public EntityUid? Projectile;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("reeling"), AutoNetworkedField]
|
||||||
|
public bool Reeling;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("reelSound"), AutoNetworkedField]
|
||||||
|
public SoundSpecifier? ReelSound = new SoundPathSpecifier("/Audio/Weapons/reel.ogg")
|
||||||
|
{
|
||||||
|
Params = AudioParams.Default.WithLoop(true)
|
||||||
|
};
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("cycleSound"), AutoNetworkedField]
|
||||||
|
public SoundSpecifier? CycleSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/kinetic_reload.ogg");
|
||||||
|
|
||||||
|
public IPlayingAudioStream? Stream;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Weapons.Ranged.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recharges ammo upon the gun being cycled.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed class RechargeCycleAmmoComponent : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
7
Content.Shared/Weapons/Ranged/Events/GunCycledEvent.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Content.Shared.Weapons.Ranged.Events;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised directed on a gun when it cycles.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public readonly record struct GunCycledEvent;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
|
|
||||||
|
namespace Content.Shared.Weapons.Ranged.Systems;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recharges ammo whenever the gun is cycled.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class RechargeCycleAmmoSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly SharedGunSystem _gun = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<RechargeCycleAmmoComponent, ActivateInWorldEvent>(OnRechargeCycled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRechargeCycled(EntityUid uid, RechargeCycleAmmoComponent component, ActivateInWorldEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<BasicEntityAmmoProviderComponent>(uid, out var basic) || args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (basic.Count >= basic.Capacity || basic.Count == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_gun.UpdateBasicEntityAmmoCount(uid, basic.Count.Value + 1, basic);
|
||||||
|
Dirty(basic);
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -162,7 +162,7 @@ public abstract partial class SharedGunSystem
|
|||||||
var shots = GetBallisticShots(component);
|
var shots = GetBallisticShots(component);
|
||||||
component.Cycled = true;
|
component.Cycled = true;
|
||||||
|
|
||||||
Cycle(component, coordinates);
|
Cycle(uid, component, coordinates);
|
||||||
|
|
||||||
var text = Loc.GetString(shots == 0 ? "gun-ballistic-cycled-empty" : "gun-ballistic-cycled");
|
var text = Loc.GetString(shots == 0 ? "gun-ballistic-cycled-empty" : "gun-ballistic-cycled");
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ public abstract partial class SharedGunSystem
|
|||||||
UpdateAmmoCount(uid);
|
UpdateAmmoCount(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void Cycle(BallisticAmmoProviderComponent component, MapCoordinates coordinates);
|
protected abstract void Cycle(EntityUid uid, BallisticAmmoProviderComponent component, MapCoordinates coordinates);
|
||||||
|
|
||||||
private void OnBallisticInit(EntityUid uid, BallisticAmmoProviderComponent component, ComponentInit args)
|
private void OnBallisticInit(EntityUid uid, BallisticAmmoProviderComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -313,15 +313,16 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shoot confirmed - sounds also played here in case it's invalid (e.g. cartridge already spent).
|
// Shoot confirmed - sounds also played here in case it's invalid (e.g. cartridge already spent).
|
||||||
Shoot(gunUid, gun, ev.Ammo, fromCoordinates, toCoordinates.Value, user, throwItems: attemptEv.ThrowItems);
|
Shoot(gunUid, gun, ev.Ammo, fromCoordinates, toCoordinates.Value, out var userImpulse, user, throwItems: attemptEv.ThrowItems);
|
||||||
var shotEv = new GunShotEvent(user);
|
var shotEv = new GunShotEvent(user, ev.Ammo);
|
||||||
RaiseLocalEvent(gunUid, ref shotEv);
|
RaiseLocalEvent(gunUid, ref shotEv);
|
||||||
// Projectiles cause impulses especially important in non gravity environments
|
|
||||||
if (TryComp<PhysicsComponent>(user, out var userPhysics))
|
if (userImpulse && TryComp<PhysicsComponent>(user, out var userPhysics))
|
||||||
{
|
{
|
||||||
if (_gravity.IsWeightless(user, userPhysics))
|
if (_gravity.IsWeightless(user, userPhysics))
|
||||||
CauseImpulse(fromCoordinates, toCoordinates.Value, user, userPhysics);
|
CauseImpulse(fromCoordinates, toCoordinates.Value, user, userPhysics);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty(gun);
|
Dirty(gun);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,11 +332,12 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
EntityUid ammo,
|
EntityUid ammo,
|
||||||
EntityCoordinates fromCoordinates,
|
EntityCoordinates fromCoordinates,
|
||||||
EntityCoordinates toCoordinates,
|
EntityCoordinates toCoordinates,
|
||||||
|
out bool userImpulse,
|
||||||
EntityUid? user = null,
|
EntityUid? user = null,
|
||||||
bool throwItems = false)
|
bool throwItems = false)
|
||||||
{
|
{
|
||||||
var shootable = EnsureComp<AmmoComponent>(ammo);
|
var shootable = EnsureComp<AmmoComponent>(ammo);
|
||||||
Shoot(gunUid, gun, new List<(EntityUid? Entity, IShootable Shootable)>(1) { (ammo, shootable) }, fromCoordinates, toCoordinates, user, throwItems);
|
Shoot(gunUid, gun, new List<(EntityUid? Entity, IShootable Shootable)>(1) { (ammo, shootable) }, fromCoordinates, toCoordinates, out userImpulse, user, throwItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Shoot(
|
public abstract void Shoot(
|
||||||
@@ -344,6 +346,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
||||||
EntityCoordinates fromCoordinates,
|
EntityCoordinates fromCoordinates,
|
||||||
EntityCoordinates toCoordinates,
|
EntityCoordinates toCoordinates,
|
||||||
|
out bool userImpulse,
|
||||||
EntityUid? user = null,
|
EntityUid? user = null,
|
||||||
bool throwItems = false);
|
bool throwItems = false);
|
||||||
|
|
||||||
@@ -436,7 +439,7 @@ public record struct AttemptShootEvent(EntityUid User, string? Message, bool Can
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="User">The user that fired this gun.</param>
|
/// <param name="User">The user that fired this gun.</param>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct GunShotEvent(EntityUid User);
|
public record struct GunShotEvent(EntityUid User, List<(EntityUid? Uid, IShootable Shootable)> Ammo);
|
||||||
|
|
||||||
public enum EffectLayers : byte
|
public enum EffectLayers : byte
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using Content.Shared.Popups;
|
|||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Content.Shared.Weapons.Melee.Events;
|
using Content.Shared.Weapons.Melee.Events;
|
||||||
using Content.Shared.Weapons.Melee.Components;
|
using Content.Shared.Weapons.Melee.Components;
|
||||||
using Content.Shared.Weapons.Melee.Events;
|
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
using Content.Shared.Weapons.Ranged.Systems;
|
using Content.Shared.Weapons.Ranged.Systems;
|
||||||
using Content.Shared.Wieldable.Components;
|
using Content.Shared.Wieldable.Components;
|
||||||
|
|||||||
@@ -2,3 +2,8 @@
|
|||||||
license: "CC0-1.0"
|
license: "CC0-1.0"
|
||||||
copyright: "Watering by elittle13. Converted to .OGG and MONO by EmoGarbage404 (github)"
|
copyright: "Watering by elittle13. Converted to .OGG and MONO by EmoGarbage404 (github)"
|
||||||
source: "https://freesound.org/people/elittle13/sounds/568558"
|
source: "https://freesound.org/people/elittle13/sounds/568558"
|
||||||
|
|
||||||
|
- files: ["harpoon.ogg"]
|
||||||
|
license: "CC0-1.0"
|
||||||
|
copyright: "grappling hook by 16bitstudios. Converted to .OGG and MONO by metalgearsloth"
|
||||||
|
source: "https://freesound.org/people/16bitstudios/sounds/541975/"
|
||||||
|
|||||||
BIN
Resources/Audio/Weapons/Guns/Gunshots/harpoon.ogg
Normal file
@@ -2,3 +2,8 @@
|
|||||||
license: "CC-BY-SA-3.0"
|
license: "CC-BY-SA-3.0"
|
||||||
copyright: "Taken from Citadel station."
|
copyright: "Taken from Citadel station."
|
||||||
source: "https://github.com/Citadel-Station-13/Citadel-Station-13-RP/blob/5b43cb2545a19957ec6ce3352dceac5e347e77df/sound/weapons/plasma_cutter.ogg"
|
source: "https://github.com/Citadel-Station-13/Citadel-Station-13-RP/blob/5b43cb2545a19957ec6ce3352dceac5e347e77df/sound/weapons/plasma_cutter.ogg"
|
||||||
|
|
||||||
|
- files: ["reel.ogg"]
|
||||||
|
license: "CC0-1.0"
|
||||||
|
copyright: "User tosha73 on freesound.org"
|
||||||
|
source: "https://freesound.org/people/tosha73/sounds/509902/"
|
||||||
|
|||||||
BIN
Resources/Audio/Weapons/reel.ogg
Normal file
@@ -34,6 +34,7 @@ research-technology-basic-xenoarcheology = Basic XenoArcheology
|
|||||||
research-technology-alternative-research = Alternative Research
|
research-technology-alternative-research = Alternative Research
|
||||||
research-technology-magnets-tech = Localized Magnetism
|
research-technology-magnets-tech = Localized Magnetism
|
||||||
research-technology-advanced-parts = Advanced Parts
|
research-technology-advanced-parts = Advanced Parts
|
||||||
|
research-technology-grappling = Grappling
|
||||||
research-technology-abnormal-artifact-manipulation = Abnormal Artifact Manipulation
|
research-technology-abnormal-artifact-manipulation = Abnormal Artifact Manipulation
|
||||||
research-technology-gravity-manipulation = Gravity Manipulation
|
research-technology-gravity-manipulation = Gravity Manipulation
|
||||||
research-technology-mobile-anomaly-tech = Mobile Anomaly Tech
|
research-technology-mobile-anomaly-tech = Mobile Anomaly Tech
|
||||||
|
|||||||
@@ -214,22 +214,54 @@
|
|||||||
map: [ "unshaded" ]
|
map: [ "unshaded" ]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: ToggleableLightVisuals
|
- type: ToggleableLightVisuals
|
||||||
spriteLayer: unshaded
|
spriteLayer: unshaded
|
||||||
inhandVisuals:
|
inhandVisuals:
|
||||||
left:
|
left:
|
||||||
- state: inhand-left-unshaded
|
- state: inhand-left-unshaded
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
right:
|
right:
|
||||||
- state: inhand-right-unshaded
|
- state: inhand-right-unshaded
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: Appearance
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.TetherVisualsStatus.Key:
|
||||||
|
unshaded:
|
||||||
|
True: { visible: true }
|
||||||
|
False: { visible: false }
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
name: grappling gun
|
||||||
|
parent: BaseItem
|
||||||
|
id: WeaponGrapplingGun
|
||||||
|
components:
|
||||||
|
- type: AmmoCounter
|
||||||
|
- type: GrapplingGun
|
||||||
|
- type: Gun
|
||||||
|
soundGunshot: /Audio/Weapons/Guns/Gunshots/harpoon.ogg
|
||||||
|
fireRate: 0.5
|
||||||
|
- type: RechargeCycleAmmo
|
||||||
|
- type: BasicEntityAmmoProvider
|
||||||
|
proto: GrapplingHook
|
||||||
|
capacity: 1
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Weapons/Guns/Launchers/grappling_gun.rsi
|
||||||
|
layers:
|
||||||
|
- state: base
|
||||||
|
- state: base-unshaded
|
||||||
|
map: [ "unshaded" ]
|
||||||
|
shader: unshaded
|
||||||
|
visible: true
|
||||||
|
- type: UseDelay
|
||||||
|
delay: 1.5
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: GenericVisualizer
|
- type: GenericVisualizer
|
||||||
visuals:
|
visuals:
|
||||||
enum.TetherVisualsStatus.Key:
|
enum.TetherVisualsStatus.Key:
|
||||||
unshaded:
|
unshaded:
|
||||||
True: { visible: true }
|
True: { state: base-unshaded }
|
||||||
False: { visible: false }
|
False: { state: base-unshaded-off }
|
||||||
|
|
||||||
# Admeme
|
# Admeme
|
||||||
- type: entity
|
- type: entity
|
||||||
|
|||||||
@@ -670,3 +670,38 @@
|
|||||||
radius: 1
|
radius: 1
|
||||||
color: orange
|
color: orange
|
||||||
energy: 0.5
|
energy: 0.5
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: GrapplingHook
|
||||||
|
name: grappling hook
|
||||||
|
noSpawn: true
|
||||||
|
components:
|
||||||
|
- type: EmbeddableProjectile
|
||||||
|
- type: Clickable
|
||||||
|
- type: Sprite
|
||||||
|
noRot: false
|
||||||
|
sprite: Objects/Weapons/Guns/Launchers/grappling_gun.rsi
|
||||||
|
layers:
|
||||||
|
- state: hook
|
||||||
|
- state: hook-unshaded
|
||||||
|
shader: unshaded
|
||||||
|
- type: Physics
|
||||||
|
bodyType: Dynamic
|
||||||
|
linearDamping: 0
|
||||||
|
angularDamping: 0
|
||||||
|
- type: Projectile
|
||||||
|
deleteOnCollide: false
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 0
|
||||||
|
- type: Fixtures
|
||||||
|
fixtures:
|
||||||
|
projectile:
|
||||||
|
shape:
|
||||||
|
!type:PhysShapeAabb
|
||||||
|
bounds: "-0.1,-0.1,0.1,0.1"
|
||||||
|
hard: false
|
||||||
|
mask:
|
||||||
|
- Impassable
|
||||||
|
- HighImpassable
|
||||||
|
- type: GrapplingProjectile
|
||||||
|
|||||||
@@ -243,6 +243,7 @@
|
|||||||
- HolofanProjector
|
- HolofanProjector
|
||||||
- WeaponForceGun
|
- WeaponForceGun
|
||||||
- WeaponTetherGun
|
- WeaponTetherGun
|
||||||
|
- WeaponGrapplingGun
|
||||||
- ClothingBackpackHolding
|
- ClothingBackpackHolding
|
||||||
- ClothingBackpackSatchelHolding
|
- ClothingBackpackSatchelHolding
|
||||||
- ClothingBackpackDuffelHolding
|
- ClothingBackpackDuffelHolding
|
||||||
|
|||||||
@@ -120,3 +120,12 @@
|
|||||||
Steel: 500
|
Steel: 500
|
||||||
Glass: 400
|
Glass: 400
|
||||||
Silver: 100
|
Silver: 100
|
||||||
|
|
||||||
|
- type: latheRecipe
|
||||||
|
id: WeaponGrapplingGun
|
||||||
|
result: WeaponGrapplingGun
|
||||||
|
completetime: 5
|
||||||
|
materials:
|
||||||
|
Steel: 500
|
||||||
|
Glass: 400
|
||||||
|
Gold: 100
|
||||||
|
|||||||
@@ -145,6 +145,18 @@
|
|||||||
recipeUnlocks:
|
recipeUnlocks:
|
||||||
- RPED
|
- RPED
|
||||||
|
|
||||||
|
- type: technology
|
||||||
|
id: Grappling
|
||||||
|
name: research-technology-grappling
|
||||||
|
icon:
|
||||||
|
sprite: Objects/Weapons/Guns/Launchers/grappling_gun.rsi
|
||||||
|
state: base
|
||||||
|
discipline: Experimental
|
||||||
|
tier: 2
|
||||||
|
cost: 5000
|
||||||
|
recipeUnlocks:
|
||||||
|
- WeaponGrapplingGun
|
||||||
|
|
||||||
# Tier 3
|
# Tier 3
|
||||||
|
|
||||||
- type: technology
|
- type: technology
|
||||||
|
|||||||
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-3.0",
|
||||||
|
"copyright": "Sprited by discord Kheprep#7153",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "base"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "base-unshaded"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "base-unshaded-off"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left-unshaded",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right-unshaded",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rope"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hook"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hook-unshaded"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 5.3 KiB |