Fixed gloved weapons being able to attack when not equipped. (#26762)
* Initial commit. No evil hidden files this time :) * Added newline because I forgot :( * We <3 tags :) * Fixed! Works now * Update Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -140,6 +140,14 @@ public sealed partial class MeleeWeaponComponent : Component
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("soundNoDamage"), AutoNetworkedField]
|
||||
public SoundSpecifier NoDamageSound { get; set; } = new SoundCollectionSpecifier("WeakHit");
|
||||
|
||||
/// <summary>
|
||||
/// If true, the weapon must be equipped for it to be used.
|
||||
/// E.g boxing gloves must be equipped to your gloves,
|
||||
/// not just held in your hand to be used.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool MustBeEquippedToUse = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -277,7 +277,10 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
|
||||
hands.ActiveHandEntity is { } held)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(held, out melee))
|
||||
// Make sure the entity is a weapon AND it doesn't need
|
||||
// to be equipped to be used (E.g boxing gloves).
|
||||
if (EntityManager.TryGetComponent(held, out melee) &&
|
||||
!melee.MustBeEquippedToUse)
|
||||
{
|
||||
weaponUid = held;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user