Merge branch '20-06-24-movement-prediction' into 20-06-24-foobar

This commit is contained in:
Pieter-Jan Briers
2020-06-24 21:00:55 +02:00
64 changed files with 1127 additions and 561 deletions

View File

@@ -107,7 +107,6 @@ namespace Content.Client
"WeaponCapacitorCharger",
"PowerCellCharger",
"AiController",
"PlayerInputMover",
"Computer",
"AsteroidRock",
"ResearchServer",
@@ -120,13 +119,10 @@ namespace Content.Client
"Airlock",
"MedicalScanner",
"WirePlacer",
"Species",
"Drink",
"Food",
"FoodContainer",
"Stomach",
"Hunger",
"Thirst",
"Rotatable",
"MagicMirror",
"MedkitFill",
@@ -142,7 +138,6 @@ namespace Content.Client
"Bloodstream",
"TransformableContainer",
"Mind",
"MovementSpeedModifier",
"StorageFill",
"Mop",
"Bucket",
@@ -161,7 +156,6 @@ namespace Content.Client
"DroppedBodyPart",
"DroppedMechanism",
"BodyManager",
"Stunnable",
"SolarPanel",
"BodyScanner",
"Stunbaton",

View File

@@ -0,0 +1,12 @@
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
[ComponentReference(typeof(SharedSpeciesComponent))]
public class SpeciesComponent : SharedSpeciesComponent
{
}
}

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,16 @@
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects;
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; }
}
}

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();
}
}
}
}

View File

@@ -0,0 +1,54 @@
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Physics;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
#nullable enable
namespace Content.Client.GameObjects.EntitySystems
{
[UsedImplicitly]
public class MoverSystem : SharedMoverSystem
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override void Initialize()
{
base.Initialize();
UpdatesBefore.Add(typeof(PhysicsSystem));
}
public override void FrameUpdate(float frameTime)
{
var playerEnt = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEnt == null || !playerEnt.TryGetComponent(out IMoverComponent mover))
{
return;
}
var physics = playerEnt.GetComponent<PhysicsComponent>();
playerEnt.TryGetComponent(out CollidableComponent? collidable);
physics.Predict = true;
UpdateKinematics(playerEnt.Transform, mover, physics, collidable);
}
public override void Update(float frameTime)
{
FrameUpdate(frameTime);
}
protected override void SetController(SharedPhysicsComponent physics)
{
((PhysicsComponent)physics).SetController<MoverController>();
}
}
}

View File

@@ -444,7 +444,7 @@ namespace Content.Client.GameObjects.EntitySystems
var func = args.Function;
var funcId = _master._inputManager.NetworkBindMap.KeyFunctionID(args.Function);
var message = new FullInputCmdMessage(_master._gameTiming.CurTick, funcId, BoundKeyState.Down,
var message = new FullInputCmdMessage(_master._gameTiming.CurTick, _master._gameTiming.TickFraction, funcId, BoundKeyState.Down,
_entity.Transform.GridPosition,
args.PointerLocation, _entity.Uid);

View File

@@ -195,7 +195,7 @@ namespace Content.Client.State
if (!_mapManager.TryFindGridAt(mousePosWorld, out var grid))
grid = _mapManager.GetDefaultGrid(mousePosWorld.MapId);
var message = new FullInputCmdMessage(_timing.CurTick, funcId, args.State,
var message = new FullInputCmdMessage(_timing.CurTick, _timing.TickFraction, funcId, args.State,
grid.MapToGrid(mousePosWorld), args.PointerLocation,
entityToClick?.Uid ?? EntityUid.Invalid);

View File

@@ -77,7 +77,7 @@ namespace Content.Client.UserInterface
if (!_mapManager.TryFindGridAt(mousePosWorld, out var grid))
grid = _mapManager.GetDefaultGrid(mousePosWorld.MapId);
var message = new FullInputCmdMessage(_gameTiming.CurTick, funcId, BoundKeyState.Down,
var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId, BoundKeyState.Down,
grid.MapToGrid(mousePosWorld), args.PointerLocation, item.Uid);
// client side command handlers will always be sent the local player session.