netcode progress, improved handling of missing frames
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FlaxEngine;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PlayerInputState2
|
||||
public struct PlayerInputState2 : IEquatable<PlayerInputState2>
|
||||
{
|
||||
public ulong Frame;
|
||||
public Float2 ViewDelta;
|
||||
@@ -17,6 +19,22 @@ public struct PlayerInputState2
|
||||
public float MoveRight;
|
||||
public bool Attack;
|
||||
public bool Jump;
|
||||
|
||||
/*public override bool Equals([NotNullWhen(true)] object obj)
|
||||
{
|
||||
if (obj is not PlayerInputState2 other)
|
||||
return false;
|
||||
return Frame == other.Frame && ViewDelta == other.ViewDelta && MoveForward == other.MoveForward && MoveRight == other.MoveRight && Attack == other.Attack && Jump == other.Jump;
|
||||
}*/
|
||||
|
||||
public bool Equals(PlayerInputState2 other)
|
||||
{
|
||||
return Frame == other.Frame && ViewDelta == other.ViewDelta && MoveForward == other.MoveForward && MoveRight == other.MoveRight && Attack == other.Attack && Jump == other.Jump;
|
||||
}
|
||||
|
||||
public static bool operator ==(PlayerInputState2 left, PlayerInputState2 right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(PlayerInputState2 left, PlayerInputState2 right) => !left.Equals(right);
|
||||
}
|
||||
|
||||
public interface IPlayerInput
|
||||
@@ -80,6 +98,9 @@ public class PlayerInput2 : IPlayerInput
|
||||
_recordState.Attack |= Input.GetAction("Attack");
|
||||
_recordState.Jump |= Input.GetAction("Jump");
|
||||
_recordState.Frame = _frame;
|
||||
|
||||
if (Input.GetKeyDown(KeyboardKeys.F))
|
||||
Thread.Sleep(20);
|
||||
}
|
||||
|
||||
public PlayerInputState2 GetState() => _recordState;
|
||||
|
||||
Reference in New Issue
Block a user