From 5e405380ef865e8ed52367231084a32747cd3b5d Mon Sep 17 00:00:00 2001
From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Sun, 24 Sep 2023 21:33:36 +0100
Subject: [PATCH] removing embedded projectiles puts them in your hand (#20475)
* tagless fields
* put embedded projectile in hand when picked up
---------
Co-authored-by: deltanedas <@deltanedas:kde.org>
---
.../Projectiles/EmbeddableProjectileComponent.cs | 12 ++++++------
Content.Shared/Projectiles/SharedProjectileSystem.cs | 5 +++++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs b/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs
index cde7e637d4..008b7c2ced 100644
--- a/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs
+++ b/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs
@@ -13,37 +13,37 @@ public sealed partial class EmbeddableProjectileComponent : Component
///
/// Minimum speed of the projectile to embed.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("minimumSpeed"), AutoNetworkedField]
+ [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public float MinimumSpeed = 5f;
///
/// Delete the entity on embedded removal?
/// Does nothing if there's no RemovalTime.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("deleteOnRemove"), AutoNetworkedField]
+ [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public bool DeleteOnRemove;
///
/// How long it takes to remove the embedded object.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("removalTime"), AutoNetworkedField]
+ [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public float? RemovalTime = 3f;
///
/// Whether this entity will embed when thrown, or only when shot as a projectile.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("embedOnThrow"), AutoNetworkedField]
+ [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public bool EmbedOnThrow = true;
///
/// How far into the entity should we offset (0 is wherever we collided).
///
- [ViewVariables(VVAccess.ReadWrite), DataField("offset"), AutoNetworkedField]
+ [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public Vector2 Offset = Vector2.Zero;
///
/// Sound to play after embedding into a hit target.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("sound"), AutoNetworkedField]
+ [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public SoundSpecifier? Sound;
}
diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs
index 6c5d7897c2..1df743bc0b 100644
--- a/Content.Shared/Projectiles/SharedProjectileSystem.cs
+++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs
@@ -1,6 +1,7 @@
using System.Numerics;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
+using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Projectiles;
using Content.Shared.Sound.Components;
@@ -24,6 +25,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
+ [Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
@@ -85,6 +87,9 @@ public abstract partial class SharedProjectileSystem : EntitySystem
var landEv = new LandEvent(args.User, true);
RaiseLocalEvent(uid, ref landEv);
_physics.WakeBody(uid, body: physics);
+
+ // try place it in the user's hand
+ _hands.TryPickupAnyHand(args.User, uid);
}
private void OnEmbedThrowDoHit(EntityUid uid, EmbeddableProjectileComponent component, ThrowDoHitEvent args)