Files
OldThink/Content.Shared/Clothing/SharedMagbootsComponent.cs

48 lines
1.6 KiB
C#
Raw Normal View History

using System;
2021-06-09 22:19:39 +02:00
using Content.Shared.Movement.Components;
using Content.Shared.Movement.EntitySystems;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
2022-01-28 13:28:05 -05:00
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
2021-06-09 22:19:39 +02:00
namespace Content.Shared.Clothing
{
[NetworkedComponent()]
public abstract class SharedMagbootsComponent : Component
{
public abstract bool On { get; set; }
protected void OnChanged()
{
// inventory system will automatically hook into the event raised by this and update accordingly
if (Owner.TryGetContainer(out var container))
{
2021-12-03 15:53:09 +01:00
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(container.Owner);
}
}
2022-01-28 13:28:05 -05:00
[DataField("walkMoveCoeffecient", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public float WalkMoveCoeffecient = 0.85f;
2022-01-28 13:28:05 -05:00
[DataField("sprintMoveCoeffecient", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public float SprintMoveCoeffecient = 0.65f;
public float WalkSpeedModifier => On ? WalkMoveCoeffecient : 1;
public float SprintSpeedModifier => On ? SprintMoveCoeffecient : 1;
[Serializable, NetSerializable]
public sealed class MagbootsComponentState : ComponentState
{
public bool On { get; }
public MagbootsComponentState(bool @on)
{
On = on;
}
}
}
}