WiP movement prediction.
This commit is contained in:
@@ -4,6 +4,8 @@ using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.Components.Nutrition;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
@@ -15,14 +17,12 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Server.GameObjects.Components.Nutrition
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class HungerComponent : Component, IMoveSpeedModifier
|
||||
public sealed class HungerComponent : SharedHungerComponent
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IRobustRandom _random;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override string Name => "Hunger";
|
||||
|
||||
// Base stuff
|
||||
public float BaseDecayRate => _baseDecayRate;
|
||||
[ViewVariables] private float _baseDecayRate;
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
[ViewVariables] private float _actualDecayRate;
|
||||
|
||||
// Hunger
|
||||
public HungerThreshold CurrentHungerThreshold => _currentHungerThreshold;
|
||||
public override HungerThreshold CurrentHungerThreshold => _currentHungerThreshold;
|
||||
private HungerThreshold _currentHungerThreshold;
|
||||
private HungerThreshold _lastHungerThreshold;
|
||||
public float CurrentHunger => _currentHunger;
|
||||
@@ -127,6 +127,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
_currentHungerThreshold = GetHungerThreshold(_currentHunger);
|
||||
_lastHungerThreshold = HungerThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
||||
HungerThresholdEffect(true);
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public HungerThreshold GetHungerThreshold(float food)
|
||||
@@ -161,6 +162,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
{
|
||||
_currentHungerThreshold = calculatedHungerThreshold;
|
||||
HungerThresholdEffect();
|
||||
Dirty();
|
||||
}
|
||||
if (_currentHungerThreshold == HungerThreshold.Dead)
|
||||
{
|
||||
@@ -179,36 +181,11 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
_currentHunger = HungerThresholds[HungerThreshold.Okay];
|
||||
}
|
||||
|
||||
float IMoveSpeedModifier.WalkSpeedModifier
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_currentHungerThreshold == HungerThreshold.Starving)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
float IMoveSpeedModifier.SprintSpeedModifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_currentHungerThreshold == HungerThreshold.Starving)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
return new HungerComponentState(_currentHungerThreshold);
|
||||
}
|
||||
}
|
||||
|
||||
public enum HungerThreshold
|
||||
{
|
||||
Overfed,
|
||||
Okay,
|
||||
Peckish,
|
||||
Starving,
|
||||
Dead,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user