public List <PlayerGhostData> GetNextPlayerInputs(TimeSpan levelTime) { List <PlayerGhostData> result = new List <PlayerGhostData>(PlayerHistory.Count); for (int i = 0; i < PlayerHistory.Count; i++) { PlayerGhostData candidate = PlayerHistory[i][nextPlayerCursors[i]]; if (levelTime > candidate.TotalGametime) { if (nextPlayerCursors[i] + 1 < PlayerHistory[i].Count) { nextPlayerCursors[i]++; } lastResults[i] = candidate; result.Add(candidate); } else { result.Add(lastResults[i]); } } return(result); }
public void RecordPlayerInput(TimeSpan levelTime, float mouvement, bool isJumping) { List <PlayerGhostData> currentInputStream = PlayerHistory[PlayerHistory.Count - 1]; PlayerGhostData lastInput = currentInputStream.LastOrDefault(); if (mouvement != lastInput.Mouvement || isJumping != lastInput.IsJumping) { currentInputStream.Add(new PlayerGhostData(levelTime - currentStreamDelta, mouvement, isJumping)); } }