Files
GoakeFlax/Source/Game/GameMode/NetworkWorld.cs
2023-04-06 21:12:04 +03:00

50 lines
1.2 KiB
C#

using System.Collections.Generic;
using FlaxEngine;
using FlaxEngine.Assertions;
namespace Game;
public static class NetworkWorld
{
private class WorldState
{
public ulong frame;
public List<PlayerActor> actors;
public Dictionary<PlayerActor, PlayerLagCompStates> playerFrameHistory;
public WorldState()
{
actors = new List<PlayerActor>();
playerFrameHistory = new Dictionary<PlayerActor, PlayerLagCompStates>();
}
}
private struct PlayerLagCompState
{
public Float3 position;
}
private class PlayerLagCompStates
{
public ulong oldestFrame;
private PlayerLagCompState[] states;
public PlayerLagCompStates(int frames)
{
states = new PlayerLagCompState[frames];
}
public PlayerLagCompState GetState(ulong frame)
{
Assert.IsTrue(frame >= oldestFrame);
ulong index = frame % (ulong)states.Length;
return states[index];
}
public void SetState(PlayerLagCompState state, ulong frame)
{
ulong index = frame % (ulong)states.Length;
states[index] = state;
}
}
}