Skip to content

Commit

Permalink
stop breaking the game !!!!!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
vanx committed Aug 28, 2024
1 parent 68276b9 commit 409bd06
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
37 changes: 37 additions & 0 deletions Content.Shared/Weapons/Melee/Events/MeleeAttemptedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Content.Shared.Weapons.Melee.Events;

/// <summary>
/// Raised on a melee when someone is attempting to attack with it.
/// Cancel this event to prevent it from attacking.
/// </summary>
[ByRefEvent]
public record struct MeleeAttemptedEvent
{
/// <summary>
/// The user attempting to attack with the weapon.
/// </summary>
public EntityUid User;

/// <summary>
/// The weapon being used.
/// </summary>
public EntityUid Used;

public bool Cancelled { get; private set; }

/// </summary>
/// Prevent the weapon from attacking
/// </summary>
public void Cancel()
{
Cancelled = true;
}

/// </summary>
/// Allow the weapon to attack again, only use if you know what you are doing
/// </summary>
public void Uncancel()
{
Cancelled = false;
}
}
4 changes: 2 additions & 2 deletions Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<MeleeWeaponComponent, HandSelectedEvent>(OnMeleeSelected);
SubscribeLocalEvent<MeleeWeaponComponent, ShotAttemptedEvent>(OnMeleeShotAttempted);
SubscribeLocalEvent<MeleeWeaponComponent, MeleeAttemptedEvent>(OnMeleeAttempted);
SubscribeLocalEvent<MeleeWeaponComponent, GunShotEvent>(OnMeleeShot);
SubscribeLocalEvent<BonusMeleeDamageComponent, GetMeleeDamageEvent>(OnGetBonusMeleeDamage);
SubscribeLocalEvent<BonusMeleeDamageComponent, GetHeavyDamageModifierEvent>(OnGetBonusHeavyDamageModifier);
Expand All @@ -86,7 +86,7 @@ private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEve
#endif
}

private void OnMeleeShotAttempted(EntityUid uid, MeleeWeaponComponent comp, ref ShotAttemptedEvent args)
private void OnMeleeAttempted(EntityUid uid, MeleeWeaponComponent comp, ref MeleeAttemptedEvent args)
{
if (comp.NextAttack > Timing.CurTime)
args.Cancel();
Expand Down
7 changes: 4 additions & 3 deletions Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override void Initialize()
{
SubscribeAllEvent<RequestShootEvent>(OnShootRequest);
SubscribeAllEvent<RequestStopShootEvent>(OnStopShootRequest);
SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee);
//SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee);

// Ammo providers
InitializeBallistic();
Expand Down Expand Up @@ -110,7 +110,8 @@ private void OnMapInit(Entity<GunComponent> gun, ref MapInitEvent args)
RefreshModifiers((gun, gun));
}

private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent args)
// Sets the gun cooldown to the melee attack cooldown on attack. Removed since it felt very unintuitive.
/*private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent args)
{
if (!TryComp<MeleeWeaponComponent>(uid, out var melee))
return;
Expand All @@ -120,7 +121,7 @@ private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent arg
component.NextFire = melee.NextAttack;
Dirty(component);
}
}
}*/

private void OnShootRequest(RequestShootEvent msg, EntitySessionEventArgs args)
{
Expand Down

0 comments on commit 409bd06

Please sign in to comment.