WiP movement prediction.

This commit is contained in:
Pieter-Jan Briers
2020-06-24 02:21:20 +02:00
parent 822436bb81
commit da45a52325
48 changed files with 1101 additions and 540 deletions

View File

@@ -0,0 +1,43 @@
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
[ComponentReference(typeof(SharedStunnableComponent))]
public class StunnableComponent : SharedStunnableComponent
{
private bool _stunned;
private bool _knockedDown;
private bool _slowedDown;
public override bool Stunned => _stunned;
public override bool KnockedDown => _knockedDown;
public override bool SlowedDown => _slowedDown;
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (!(curState is StunnableComponentState state))
{
return;
}
_stunned = state.Stunned;
_knockedDown = state.KnockedDown;
_slowedDown = state.SlowedDown;
WalkModifierOverride = state.WalkModifierOverride;
RunModifierOverride = state.RunModifierOverride;
if (Owner.TryGetComponent(out MovementSpeedModifierComponent movement))
{
movement.RefreshMovementSpeedModifiers();
}
}
}
}

View File

@@ -0,0 +1,26 @@
using Content.Shared.GameObjects.Components.Movement;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
#nullable enable
namespace Content.Client.GameObjects.Components.Movement
{
[RegisterComponent]
[ComponentReference(typeof(IMoverComponent))]
public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent, IMoverComponent
{
public override GridCoordinates LastPosition { get; set; }
public override float StepSoundDistance { get; set; }
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
if (IoCManager.Resolve<IPlayerManager>().LocalPlayer!.ControlledEntity == Owner)
{
base.HandleComponentState(curState, nextState);
}
}
}
}

View File

@@ -0,0 +1,30 @@
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Nutrition
{
[RegisterComponent]
public class HungerComponent : SharedHungerComponent
{
private HungerThreshold _currentHungerThreshold;
public override HungerThreshold CurrentHungerThreshold => _currentHungerThreshold;
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
if (!(curState is HungerComponentState hunger))
{
return;
}
_currentHungerThreshold = hunger.CurrentThreshold;
if (Owner.TryGetComponent(out MovementSpeedModifierComponent movement))
{
movement.RefreshMovementSpeedModifiers();
}
}
}
}

View File

@@ -0,0 +1,30 @@
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Nutrition
{
[RegisterComponent]
public class ThirstComponent : SharedThirstComponent
{
private ThirstThreshold _currentThirstThreshold;
public override ThirstThreshold CurrentThirstThreshold => _currentThirstThreshold;
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
if (!(curState is ThirstComponentState thirst))
{
return;
}
_currentThirstThreshold = thirst.CurrentThreshold;
if (Owner.TryGetComponent(out MovementSpeedModifierComponent movement))
{
movement.RefreshMovementSpeedModifiers();
}
}
}
}