static void MainSimple(string[] args) { using (var streamProvider = new PipBoyStreamProvider()) using (var stream = streamProvider.ReadFile("data.dump")) { var gameStateReader = new GameStateReader(stream); while (gameStateReader.NextState()) { Console.WriteLine("Player X position: " + (float)gameStateReader.GameState.Map.World.Player.X); } } }
private static void ReadStream(Stream stream) { //var gameStateReader = new GameStateReader(stream, new GameStateReaderDebugSettings { Writer = Console.Out, DumpInitialPacketParsing = true, DumpPacketParsing = true }); var gameStateReader = new GameStateReader(stream); gameStateReader.NextState(); // read first state var playerPosition = (GameObject)gameStateReader.GameState.Map.World.Player; playerPosition.Changed += PlayerPosition_Changed; while (!Console.KeyAvailable && gameStateReader.NextState()) { // process events } }
public void Dump(Stream stream) { if (_objectFile != null) { using (var writer = new StreamWriter(new FileStream(_objectFile, FileMode.Create))) { try { //var gameStateReader = new GameStateReader(stream, new GameStateReaderDebugSettings { Writer = writer, DumpInitialPacketParsing = true, DumpPacketParsing = true }); var gameStateReader = new GameStateReader(stream); gameStateReader.NextState(); // read first state var state = (GameObject)gameStateReader.GameState; writer.WriteLine(state.ToString(true)); state.Changed += (s, e) => { foreach (var changedChild in e.ChangedChildren) { writer.WriteLine(changedChild.ToString(true)); } writer.WriteLine("==============================================================================="); }; while (!_cancelTokenSource.Token.IsCancellationRequested && gameStateReader.NextState()) { // do nothing } return; } catch (Exception e) { writer.WriteLine("Exception reading game objects: " + e.Message); writer.WriteLine(e.StackTrace); } } } // if no objectFile or an exception occured ReadToEnd(stream); }