record demos as packets
This commit is contained in:
@@ -90,11 +90,13 @@ namespace Game
|
||||
public class PlayerInput
|
||||
{
|
||||
public const byte DemoVer = 1;
|
||||
public const int MaxPlayerStates = 120;
|
||||
|
||||
public PlayerState currentState;
|
||||
public ulong frame;
|
||||
//public ulong oldestFrame;
|
||||
|
||||
private PlayerState[] states = new PlayerState[120];
|
||||
private PlayerState[] states = new PlayerState[MaxPlayerStates];
|
||||
|
||||
public virtual bool Predict => false;
|
||||
|
||||
@@ -110,7 +112,7 @@ namespace Game
|
||||
{
|
||||
//Console.Print("recorded frame " + frame);
|
||||
|
||||
states[frame % 120] = currentState;
|
||||
states[frame % MaxPlayerStates] = currentState;
|
||||
|
||||
/*ulong oldest = ulong.MaxValue;
|
||||
for (int i = 0; i < 120; i++)
|
||||
@@ -130,7 +132,7 @@ namespace Game
|
||||
|
||||
public bool GetState(ulong frame, out PlayerInputState inputState, out PlayerActorState actorState)
|
||||
{
|
||||
int frameIndex = (int)frame % 120;
|
||||
int frameIndex = (int)frame % MaxPlayerStates;
|
||||
if (states[frameIndex].input.frame != frame)
|
||||
{
|
||||
inputState = default;
|
||||
@@ -145,7 +147,7 @@ namespace Game
|
||||
|
||||
public void SetState(ulong frame, PlayerInputState inputState)
|
||||
{
|
||||
int frameIndex = (int)frame % 120;
|
||||
int frameIndex = (int)frame % MaxPlayerStates;
|
||||
states[frameIndex].input = inputState;
|
||||
states[frameIndex].input.frame = frame;
|
||||
states[frameIndex].actor = new PlayerActorState();
|
||||
@@ -153,7 +155,7 @@ namespace Game
|
||||
|
||||
public void SetState(ulong frame, PlayerInputState inputState, PlayerActorState actorState)
|
||||
{
|
||||
int frameIndex = (int)frame % 120;
|
||||
int frameIndex = (int)frame % MaxPlayerStates;
|
||||
states[frameIndex].input = inputState;
|
||||
states[frameIndex].input.frame = frame;
|
||||
states[frameIndex].actor = actorState;
|
||||
|
||||
Reference in New Issue
Block a user