working replay system

This commit is contained in:
2022-03-21 19:01:28 +02:00
parent 99637255da
commit 4997077978
17 changed files with 243 additions and 108 deletions

View File

@@ -35,7 +35,7 @@ namespace Game
{
int rawsize = Marshal.SizeOf(typeof(T));
if (rawsize > rawData.Length - position)
throw new ArgumentException("Not enough data to fill struct. Array length from position: "+(rawData.Length-position) + ", Struct length: "+rawsize);
throw new ArgumentException("Not enough data to fill struct. Array length from position: " + (rawData.Length-position) + ", Struct length: " + rawsize);
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(rawData, position, buffer, rawsize);
T retobj = (T)Marshal.PtrToStructure(buffer, typeof(T));
@@ -56,21 +56,19 @@ namespace Game
bufferEnumerable = buffer.GetEnumerator();
Console.Print("demo numstates: " + buffer.Count);
OnEndFrame(); // advances to first frame
}
public override void OnUpdate()
{
lastState = currentState;
}
public override void OnFixedUpdate()
{
}
private int asdf = 0;
public override void OnEndFrame()
{
// TODO: check if the current state frame matches the current frame number before advancing
/*asdf++;
if (asdf < 8)
return;*/
if (bufferEnumerable == null || !bufferEnumerable.MoveNext())
{
if (buffer.Any())
@@ -85,6 +83,7 @@ namespace Game
//var actorState = currentState.actor;
currentState.input = bufferEnumerable.Current;
//frame++;
//currentState.actor = actorState;
}
}