Remove IMoveSpeedModifier in favor of events (#5212)
* Remove IMoveSpeedModifier * fucking magboots * yope * rabiews
This commit is contained in:
@@ -8,37 +8,13 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Shared.Nutrition.Components
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedHungerComponent : Component, IMoveSpeedModifier
|
||||
public abstract class SharedHungerComponent : Component
|
||||
{
|
||||
public sealed override string Name => "Hunger";
|
||||
|
||||
[ViewVariables]
|
||||
public abstract HungerThreshold CurrentHungerThreshold { get; }
|
||||
|
||||
|
||||
float IMoveSpeedModifier.WalkSpeedModifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentHungerThreshold == HungerThreshold.Starving)
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
float IMoveSpeedModifier.SprintSpeedModifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentHungerThreshold == HungerThreshold.Starving)
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class HungerComponentState : ComponentState
|
||||
{
|
||||
|
||||
@@ -8,36 +8,13 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Shared.Nutrition.Components
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedThirstComponent : Component, IMoveSpeedModifier
|
||||
public abstract class SharedThirstComponent : Component
|
||||
{
|
||||
public sealed override string Name => "Thirst";
|
||||
|
||||
[ViewVariables]
|
||||
public abstract ThirstThreshold CurrentThirstThreshold { get; }
|
||||
|
||||
float IMoveSpeedModifier.SprintSpeedModifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentThirstThreshold == ThirstThreshold.Parched)
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
float IMoveSpeedModifier.WalkSpeedModifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentThirstThreshold == ThirstThreshold.Parched)
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class ThirstComponentState : ComponentState
|
||||
{
|
||||
|
||||
22
Content.Shared/Nutrition/EntitySystems/SharedHungerSystem.cs
Normal file
22
Content.Shared/Nutrition/EntitySystems/SharedHungerSystem.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.Movement.EntitySystems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Nutrition.EntitySystems
|
||||
{
|
||||
public class SharedHungerSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedHungerComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||
}
|
||||
|
||||
private void OnRefreshMovespeed(EntityUid uid, SharedHungerComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||
{
|
||||
float mod = component.CurrentHungerThreshold == HungerThreshold.Starving ? 0.75f : 1.0f;
|
||||
args.ModifySpeed(mod, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Content.Shared/Nutrition/EntitySystems/SharedThirstSystem.cs
Normal file
22
Content.Shared/Nutrition/EntitySystems/SharedThirstSystem.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.Movement.EntitySystems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Nutrition.EntitySystems
|
||||
{
|
||||
public class SharedThirstSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedThirstComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||
}
|
||||
|
||||
private void OnRefreshMovespeed(EntityUid uid, SharedThirstComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||
{
|
||||
float mod = component.CurrentThirstThreshold == ThirstThreshold.Parched ? 0.75f : 1.0f;
|
||||
args.ModifySpeed(mod, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user