_net prog
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Game;
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PlayerInputState2
|
||||
{
|
||||
//public ulong frame;
|
||||
public ulong Frame;
|
||||
public Float2 ViewDelta;
|
||||
public float MoveForward;
|
||||
public float MoveRight;
|
||||
@@ -53,8 +53,13 @@ public class PlayerInput2 : IPlayerInput
|
||||
[ConsoleVariable("sensitivity")]
|
||||
private static float _sensitivity { get; set; } = 1.0f;
|
||||
|
||||
private ulong _frame;
|
||||
|
||||
public void SetFrame(ulong frame)
|
||||
{
|
||||
if (_frame != frame)
|
||||
ResetState();
|
||||
_frame = frame;
|
||||
}
|
||||
|
||||
public void UpdateState()
|
||||
@@ -74,6 +79,7 @@ public class PlayerInput2 : IPlayerInput
|
||||
_recordState.MoveRight = MathF.MaxMagnitude(_recordState.MoveRight, Input.GetAxis("Horizontal"));
|
||||
_recordState.Attack |= Input.GetAction("Attack");
|
||||
_recordState.Jump |= Input.GetAction("Jump");
|
||||
_recordState.Frame = _frame;
|
||||
}
|
||||
|
||||
public PlayerInputState2 GetState() => _recordState;
|
||||
|
||||
@@ -252,12 +252,16 @@ public class PlayerMovement : Script
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
Console.Print("playerMovement OnUpdate");
|
||||
//input.OnUpdate();
|
||||
|
||||
|
||||
//if (Input is PlayerInputDemo /*&& currentInputFrame2 >= currentInputFrame*/)
|
||||
// return;
|
||||
|
||||
if (World.IsServer)
|
||||
viewAngles = viewAngles;
|
||||
|
||||
Input.SetFrame(World.Frame);
|
||||
Input.UpdateState();
|
||||
|
||||
@@ -311,13 +315,14 @@ public class PlayerMovement : Script
|
||||
|
||||
public override void OnFixedUpdate()
|
||||
{
|
||||
Console.Print("playerMovement OnFixedUpdate");
|
||||
float timeDeltaDiff = Time.DeltaTime - 1.0f / Time.PhysicsFPS;
|
||||
if (Time.PhysicsFPS > 0 && Math.Abs(timeDeltaDiff) > 0.0001f)
|
||||
Console.Print("Time.DeltaTime is not stable: " + timeDeltaDiff);
|
||||
|
||||
//Input.OnFixedUpdate();
|
||||
PlayerInputState2 inputState = Input.GetState();
|
||||
bool predict = World.IsClient;
|
||||
bool predict = World.IsClient && false;
|
||||
if (predict)
|
||||
{
|
||||
// Get the latest frame we have predicted
|
||||
@@ -962,7 +967,7 @@ public class PlayerMovement : Script
|
||||
if (capsuleCollider && capsuleCollider.IsActive)
|
||||
{
|
||||
Quaternion rotation = capsuleCollider.LocalOrientation * Quaternion.Euler(0f, 90f, 0f);
|
||||
DebugDraw.DrawWireTube(capsuleCollider.Position, rotation, capsuleCollider.Radius,
|
||||
DebugDraw.DrawWireCapsule(capsuleCollider.Position, rotation, capsuleCollider.Radius,
|
||||
capsuleCollider.Height, Color.GreenYellow * 0.8f);
|
||||
}
|
||||
else if (meshCollider && meshCollider.IsActive)
|
||||
@@ -970,7 +975,7 @@ public class PlayerMovement : Script
|
||||
//Quaternion rotation = meshCollider.LocalOrientation * Quaternion.Euler(0f, 90f, 0f);
|
||||
DebugDraw.DrawWireCylinder(meshCollider.Position, meshCollider.Orientation, capsuleCollider.Radius,
|
||||
capsuleCollider.Height + capsuleCollider.Radius * 2, Color.GreenYellow * 0.8f);
|
||||
//DebugDraw.DrawWireTube(meshCollider.Position, rotation, meshCollider.Radius, meshCollider.Height, Color.GreenYellow * 0.8f);
|
||||
//DebugDraw.DrawWireCapsule(meshCollider.Position, rotation, meshCollider.Radius, meshCollider.Height, Color.GreenYellow * 0.8f);
|
||||
}
|
||||
else if (boxCollider && boxCollider.IsActive)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user