using Content.Shared.Movement.Systems;
using Content.Shared.Damage.Systems;
using Content.Shared.Inventory;
using Content.Shared.Clothing.Components;
namespace Content.Shared.Clothing.EntitySystems;
///
/// Changes the friction and acceleration of the wearer and also the damage on impact variables of thew wearer when hitting a static object.
///
public sealed class SkatesSystem : EntitySystem
{
[Dependency] private readonly MovementSpeedModifierSystem _move = default!;
[Dependency] private readonly DamageOnHighSpeedImpactSystem _impact = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnGotEquipped);
SubscribeLocalEvent(OnGotUnequipped);
SubscribeLocalEvent>(OnRefreshFrictionModifiers);
}
///
/// When item is unequipped from the shoe slot, friction, aceleration and collide on impact return to default settings.
///
private void OnGotUnequipped(Entity entity, ref ClothingGotUnequippedEvent args)
{
_move.RefreshFrictionModifiers(args.Wearer);
_impact.ChangeCollide(args.Wearer, entity.Comp.DefaultMinimumSpeed, entity.Comp.DefaultStunSeconds, entity.Comp.DefaultDamageCooldown, entity.Comp.DefaultSpeedDamage);
}
///
/// When item is equipped into the shoe slot, friction, acceleration and collide on impact are adjusted.
///
private void OnGotEquipped(Entity entity, ref ClothingGotEquippedEvent args)
{
_move.RefreshFrictionModifiers(args.Wearer);
_impact.ChangeCollide(args.Wearer, entity.Comp.MinimumSpeed, entity.Comp.StunSeconds, entity.Comp.DamageCooldown, entity.Comp.SpeedDamage);
}
private void OnRefreshFrictionModifiers(Entity ent,
ref InventoryRelayedEvent args)
{
args.Args.ModifyFriction(ent.Comp.Friction, ent.Comp.FrictionNoInput);
args.Args.ModifyAcceleration(ent.Comp.Acceleration);
}
}