CatStation/Content.Shared/Weapons/Ranged/Systems/GunSpreadModifierSystem.cs
DrSmugleaf 65f5f67cd5
Make every EntitySystem partial (#45220)
* Make every EntitySystem partial

* Oobs thats for a diff PR

* Also oops on that one

* Test systems

* git are we fr

* Update file templates

* cleanup empty classes while we are here

* forgor

---------

Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
2026-08-14 18:24:47 +00:00

29 lines
1.1 KiB
C#

using Content.Shared.Examine;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
namespace Content.Shared.Weapons.Ranged.Systems;
public sealed partial class GunSpreadModifierSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GunSpreadModifierComponent, GunGetAmmoSpreadEvent>(OnGunGetAmmoSpread);
SubscribeLocalEvent<GunSpreadModifierComponent, ExaminedEvent>(OnExamine);
}
private void OnGunGetAmmoSpread(Entity<GunSpreadModifierComponent> ent, ref GunGetAmmoSpreadEvent args)
{
args.Spread *= ent.Comp.Spread;
}
private void OnExamine(Entity<GunSpreadModifierComponent> ent, ref ExaminedEvent args)
{
var percentage = Math.Round(ent.Comp.Spread * 100);
var loc = percentage < 100 ? "examine-gun-spread-modifier-reduction" : "examine-gun-spread-modifier-increase";
percentage = percentage < 100 ? 100 - percentage : percentage - 100;
var msg = Loc.GetString(loc, ("percentage", percentage));
args.PushMarkup(msg);
}
}