[Port] Hristov / Христов | [Port] Manual Sending Of The Cartridge / Ручное Досылание Патрона (#58)

* tweak: hristov

* WD EDIT

* fix
This commit is contained in:
Spatison
2024-09-21 13:21:44 +03:00
committed by GitHub
parent d044cdeab4
commit 2ed017c842
22 changed files with 129 additions and 17 deletions

View File

@@ -61,15 +61,10 @@ public sealed class WieldableSystem : EntitySystem
private void OnShootAttempt(EntityUid uid, GunRequiresWieldComponent component, ref AttemptShootEvent args)
{
if (TryComp<WieldableComponent>(uid, out var wieldable) &&
!wieldable.Wielded)
if (TryComp<WieldableComponent>(uid, out var wieldable) && !wieldable.Wielded)
{
args.Cancelled = true;
if (!HasComp<MeleeWeaponComponent>(uid) && !HasComp<MeleeRequiresWieldComponent>(uid))
{
args.Message = Loc.GetString("wieldable-component-requires", ("item", uid));
}
args.Message = Loc.GetString("wieldable-component-requires", ("item", uid));
}
}
@@ -214,6 +209,17 @@ public sealed class WieldableSystem : EntitySystem
/// <returns>True if the attempt wasn't blocked.</returns>
public bool TryUnwield(EntityUid used, WieldableComponent component, EntityUid user)
{
// WD EDIT START
if (!component.Wielded)
return false;
if (TryComp<BallisticAmmoProviderComponent>(used, out var ballisticAmmoProvider)
&& ballisticAmmoProvider.Entities.Count != 0
&& TryComp<CartridgeAmmoComponent>(ballisticAmmoProvider.Entities[^1], out var cartridgeAmmo)
&& cartridgeAmmo.Spent)
return false;
// WD EDIT END
var ev = new BeforeUnwieldEvent();
RaiseLocalEvent(used, ev);