Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX stunbaton decrease energy on hit #1599

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Content.Server/Stunnable/Systems/StunbatonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Popups;
using Content.Shared.Stunnable;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Events;

namespace Content.Server.Stunnable.Systems
Expand All @@ -32,6 +33,8 @@ public override void Initialize()
SubscribeLocalEvent<StunbatonComponent, ItemToggleActivateAttemptEvent>(TryTurnOn);
SubscribeLocalEvent<StunbatonComponent, ItemToggledEvent>(ToggleDone);
SubscribeLocalEvent<StunbatonComponent, ChargeChangedEvent>(OnChargeChanged);
SubscribeLocalEvent<StunbatonComponent, MeleeHitEvent>(OnEnergyDecrease); //ss220 stunbaton decrease energy fix
SubscribeLocalEvent<StunbatonComponent, ThrowDoHitEvent>(OnThrowEnergyDecrease); //ss220 stunbaton decrease energy fix
}

// SS220-Stunbaton-rework begin
Expand Down Expand Up @@ -113,5 +116,25 @@ private void OnChargeChanged(Entity<StunbatonComponent> entity, ref ChargeChange
_itemToggle.TryDeactivate(entity.Owner, predicted: false);
}
}

//ss220 stunbaton decrease energy fix start
private void OnEnergyDecrease(Entity<StunbatonComponent> entity, ref MeleeHitEvent args)
{
if (TryComp<BatteryComponent>(entity.Owner, out var batteryComponent) && _itemToggle.IsActivated(entity.Owner))
{
_battery.TryUseCharge(entity.Owner, entity.Comp.EnergyPerUse, batteryComponent);
}

}

private void OnThrowEnergyDecrease(Entity<StunbatonComponent> entity, ref ThrowDoHitEvent args)
{
if (TryComp<BatteryComponent>(entity.Owner, out var batteryComponent) && _itemToggle.IsActivated(entity.Owner))
{
_battery.TryUseCharge(entity.Owner, entity.Comp.EnergyPerUse, batteryComponent);
}
}
//ss220 stunbaton decrease energy fix end

}
}
Loading