Closed sKeLeTr0n closed 9 years ago
"(_parser.Header.PlaybackTime * 1000) / _parser.Header.PlaybackFrames" is pretty close but I think that is not 100% realtime...and "_parser.TickRate" is way to fast.
Hey,
look into DemoParser.cs, lines 68-78: https://github.com/moritzuehling/demoinfo-public/blob/master/DemoInfo/DemoParser.cs
public float TickRate
{
get { return this.Header.PlaybackFrames / this.Header.PlaybackTime; }
}
public float TickTime
{
get { return this.Header.PlaybackTime / this.Header.PlaybackFrames; }
}
public int CurrrentTick { get; private set; }
public double CurrentTime { get; private set; }
CurrentTime
is currently not set (that's a bug, I'll fix this tomorrow), but you can use CurrentTick.
1 Tick is TickTime
Seconds long. You can use this to play a demo in Realtime.
A quick way to parse a demo in realtime: https://gist.github.com/moritzuehling/cb4df828dc0ff48e1bb9 (This is an excerpt of an other project of me, I deleted some unnecesary stuff. But the important part is here.
timeSinceLastFrame += elapsedGameTime.ElapsedGameTime.TotalSeconds; //Okay, time has moved.
while (timeSinceLastFrame > parser.TickTime) //As long as we're in the future
{
parser.ParseNextTick(); //Parse a tick
timeSinceLastFrame -= parser.TickTime; //We're now parser.TickTime nearer to the future
}
//Do something else, draw the stuff.
elapsedGameTime is the time since the last call of the Update-Method.
This seems to be realtime at least for me.
I hope I could help!
Hey, not really an Issue but whatever :P How can I know how many milliseconds I need to wait for the next tick, to play it in realtime? So how many milliseconds I need per tick? Do you know that?