コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: PazerOP/DemoLib
        public MainWindow()
        {
            InitializeComponent();

            m_Reader = Task.Run(() =>
            {
                var stream = File.Open("demos/cp_process_final.dem", FileMode.Open, FileAccess.Read);
                return(DemoReader.FromStream(stream));
            });

            m_Reader.ContinueWith(lastTask =>
            {
                lastTask.Result.Events.NewTick.Add(Events_NewTick);
                lastTask.Result.Events.NewTick.Add(UpdatePlayerStatuses);
                lastTask.Result.Events.NewTick.Add(UpdatePlayerPositions);

                lastTask.Result.Events.NewTick.Add(UpdateRocketPositions);

                lastTask.Result.Events.TempEntityCreated.Add(TempEntCreated);

                lastTask.Result.Events.GameEvent.Add(GameEventTriggered);

                progress.Dispatcher.Invoke(() => progress.Maximum = lastTask.Result.Header.m_PlaybackTicks.Value);

                lastTask.Result.SimulateDemo();
            });
        }
コード例 #2
0
        static void Main(string[] args)
        {
            using (var stream = File.Open(@"D:\Steam\steamapps\common\Team Fortress 2\tf\demos\testdemo.dem", FileMode.Open, FileAccess.Read))
            {
                Console.WriteLine("Parsing test demo file...");

                DateTime   start  = DateTime.Now;
                DemoReader reader = DemoReader.FromStream(stream);
                DateTime   end    = DateTime.Now;

                Console.WriteLine("Finished parsing test demo file in {0:N1}ms.", (end - start).TotalMilliseconds);

                reader.SimulateDemo();

                Console.WriteLine("Finished simulating demo.");
                Console.ReadLine();
            }
        }