Toy Box filled with toys (ready for merge) (#16252)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Cluwne;
|
||||
|
||||
namespace Content.Server.Weapons.Melee.WeaponRandom;
|
||||
|
||||
public sealed class WeaponRandomSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<WeaponRandomComponent, MeleeHitEvent>(OnMeleeHit);
|
||||
}
|
||||
|
||||
private void OnMeleeHit(EntityUid uid, WeaponRandomComponent component, MeleeHitEvent args)
|
||||
{
|
||||
foreach (var entity in args.HitEntities)
|
||||
{
|
||||
if (HasComp<CluwneComponent>(entity) && component.AntiCluwne)
|
||||
{
|
||||
_audio.PlayPvs(component.DamageSound, uid);
|
||||
args.BonusDamage = component.DamageBonus;
|
||||
}
|
||||
|
||||
else if (_random.Prob(component.RandomDamageChance) && component.RandomDamage)
|
||||
{
|
||||
_audio.PlayPvs(component.DamageSound, uid);
|
||||
args.BonusDamage = component.DamageBonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user