Make PKA require wielding (#16638)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Wieldable;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Weapons.Melee.Components;
|
namespace Content.Shared.Weapons.Melee.Components;
|
||||||
@@ -5,7 +6,7 @@ namespace Content.Shared.Weapons.Melee.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates that this meleeweapon requires wielding to be useable.
|
/// Indicates that this meleeweapon requires wielding to be useable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, Access(typeof(WieldableSystem))]
|
||||||
public sealed class MeleeRequiresWieldComponent : Component
|
public sealed class MeleeRequiresWieldComponent : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Wieldable;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Weapons.Ranged.Components;
|
namespace Content.Shared.Weapons.Ranged.Components;
|
||||||
@@ -5,7 +6,7 @@ namespace Content.Shared.Weapons.Ranged.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates that this gun requires wielding to be useable.
|
/// Indicates that this gun requires wielding to be useable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, Access(typeof(WieldableSystem))]
|
||||||
public sealed class GunRequiresWieldComponent : Component
|
public sealed class GunRequiresWieldComponent : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using Content.Shared.Wieldable;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Weapons.Ranged.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies an accuracy bonus upon wielding.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(WieldableSystem))]
|
||||||
|
public sealed partial class GunWieldBonusComponent : Component
|
||||||
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("minAngle"), AutoNetworkedField]
|
||||||
|
public Angle MinAngle = Angle.FromDegrees(-43);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Angle bonus applied upon being wielded.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField("maxAngle"), AutoNetworkedField]
|
||||||
|
public Angle MaxAngle = Angle.FromDegrees(-43);
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
private void OnBallisticUse(EntityUid uid, BallisticAmmoProviderComponent component, UseInHandEvent args)
|
private void OnBallisticUse(EntityUid uid, BallisticAmmoProviderComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
ManualCycle(uid, component, Transform(uid).MapPosition, args.User);
|
ManualCycle(uid, component, Transform(uid).MapPosition, args.User);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public sealed partial class WieldableComponent : Component
|
|||||||
public bool Wielded = false;
|
public bool Wielded = false;
|
||||||
|
|
||||||
[DataField("wieldedInhandPrefix")]
|
[DataField("wieldedInhandPrefix")]
|
||||||
public string WieldedInhandPrefix = "wielded";
|
public string? WieldedInhandPrefix = "wielded";
|
||||||
|
|
||||||
public string? OldInhandPrefix = null;
|
public string? OldInhandPrefix = null;
|
||||||
|
|
||||||
|
|||||||
7
Content.Shared/Wieldable/ItemWieldedEvent.cs
Normal file
7
Content.Shared/Wieldable/ItemWieldedEvent.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Content.Shared.Wieldable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised directed on an entity when it is wielded.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public readonly record struct ItemWieldedEvent;
|
||||||
@@ -39,6 +39,8 @@ public sealed class WieldableSystem : EntitySystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<MeleeRequiresWieldComponent, AttemptMeleeEvent>(OnMeleeAttempt);
|
SubscribeLocalEvent<MeleeRequiresWieldComponent, AttemptMeleeEvent>(OnMeleeAttempt);
|
||||||
SubscribeLocalEvent<GunRequiresWieldComponent, AttemptShootEvent>(OnShootAttempt);
|
SubscribeLocalEvent<GunRequiresWieldComponent, AttemptShootEvent>(OnShootAttempt);
|
||||||
|
SubscribeLocalEvent<GunWieldBonusComponent, ItemWieldedEvent>(OnGunWielded);
|
||||||
|
SubscribeLocalEvent<GunWieldBonusComponent, ItemUnwieldedEvent>(OnGunUnwielded);
|
||||||
|
|
||||||
SubscribeLocalEvent<IncreaseDamageOnWieldComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
|
SubscribeLocalEvent<IncreaseDamageOnWieldComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
|
||||||
}
|
}
|
||||||
@@ -63,6 +65,26 @@ public sealed class WieldableSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGunUnwielded(EntityUid uid, GunWieldBonusComponent component, ItemUnwieldedEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<GunComponent>(uid, out var gun))
|
||||||
|
return;
|
||||||
|
|
||||||
|
gun.MinAngle -= component.MinAngle;
|
||||||
|
gun.MaxAngle -= component.MaxAngle;
|
||||||
|
Dirty(gun);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGunWielded(EntityUid uid, GunWieldBonusComponent component, ref ItemWieldedEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<GunComponent>(uid, out var gun))
|
||||||
|
return;
|
||||||
|
|
||||||
|
gun.MinAngle += component.MinAngle;
|
||||||
|
gun.MaxAngle += component.MaxAngle;
|
||||||
|
Dirty(gun);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDisarmAttemptEvent(EntityUid uid, WieldableComponent component, DisarmAttemptEvent args)
|
private void OnDisarmAttemptEvent(EntityUid uid, WieldableComponent component, DisarmAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (component.Wielded)
|
if (component.Wielded)
|
||||||
@@ -197,6 +219,9 @@ public sealed class WieldableSystem : EntitySystem
|
|||||||
_popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", uid)), args.Args.User, args.Args.User);
|
_popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", uid)), args.Args.User, args.Args.User);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", args.Args.User),("item", uid)), args.Args.User, Filter.PvsExcept(args.Args.User), true);
|
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", args.Args.User),("item", uid)), args.Args.User, Filter.PvsExcept(args.Args.User), true);
|
||||||
|
|
||||||
|
var ev = new ItemWieldedEvent();
|
||||||
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,17 @@
|
|||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Weapons/Guns/Basic/kinetic_accelerator.rsi
|
sprite: Objects/Weapons/Guns/Basic/kinetic_accelerator.rsi
|
||||||
size: 30
|
size: 30
|
||||||
|
- type: GunWieldBonus
|
||||||
|
minAngle: -43
|
||||||
|
maxAngle: -43
|
||||||
|
- type: Wieldable
|
||||||
|
wieldedInhandPrefix: null
|
||||||
- type: Gun
|
- type: Gun
|
||||||
fireRate: 0.75
|
fireRate: 0.75
|
||||||
selectedMode: SemiAuto
|
selectedMode: SemiAuto
|
||||||
|
angleDecay: 45
|
||||||
|
minAngle: 44
|
||||||
|
maxAngle: 45
|
||||||
availableModes:
|
availableModes:
|
||||||
- SemiAuto
|
- SemiAuto
|
||||||
soundGunshot:
|
soundGunshot:
|
||||||
@@ -24,7 +32,7 @@
|
|||||||
True: { visible: False }
|
True: { visible: False }
|
||||||
False: { visible: True }
|
False: { visible: True }
|
||||||
- type: RechargeBasicEntityAmmo
|
- type: RechargeBasicEntityAmmo
|
||||||
rechargeCooldown: 1
|
rechargeCooldown: 0.75
|
||||||
rechargeSound:
|
rechargeSound:
|
||||||
path: /Audio/Weapons/Guns/MagIn/kinetic_reload.ogg
|
path: /Audio/Weapons/Guns/MagIn/kinetic_reload.ogg
|
||||||
- type: BasicEntityAmmoProvider
|
- type: BasicEntityAmmoProvider
|
||||||
|
|||||||
Reference in New Issue
Block a user