/// <summary> /// initializes the ReplayService. This is when the log file is actually loaded into memory. /// </summary> public void init() { allLines = File.ReadAllLines(logFilePath); updatesLeft = getUpdateCount(); RandCommand rc = (RandCommand)LogCommand.parse(allLines[0]); Rand.Instance.Seed = rc.Seed; lineNumber = 1; }
private InputCommand getInputOnLine() { try { string line = readLine(lineNumber); LogCommand command = LogCommand.parse(line); while (!(command is InputCommand)) { lineNumber++; command = LogCommand.parse(readLine(lineNumber)); } InputCommand io = (InputCommand)command; return(io); } catch (LogOverException e) { replayOver = true; return(new InputCommand(0, 0, new List <Keys>(), Mouse.GetState())); } }
/// <summary> /// Gets the number of times to spend on the current line in the log file /// </summary> /// <returns></returns> private long getUpdateCount() { try { string line = readLine(lineNumber); LogCommand command = LogCommand.parse(line); while (!(command is InputCommand)) { lineNumber++; command = LogCommand.parse(readLine(lineNumber)); } InputCommand io = (InputCommand)command; return(io.Duration); } catch (LogOverException e) { replayOver = true; return(-1); } }