コード例 #1
0
 public Recorder(GameCartridge gameCartridge, string fileName)
 {
     this.demo      = new Demo(gameCartridge.Random.Seed);
     this.totalTime = 0f;
     this.fileName  = fileName;
 }
コード例 #2
0
        private void FinishLoadingContent(GameCartridge gameCartridge)
        {
#if DEBUG
            DebugLevel = DebugLevel.Passive;
#endif

            // Most cartridges get setup automatically but since the gamecartridge hasn't been inserted yet we have to do it early here
            gameCartridge.SetupSceneLayers(this, specification, WindowInterface);

            var debugActor            = gameCartridge.SceneLayers.DebugScene.AddActor("DebugActor");
            var demoPlaybackComponent = new DemoPlaybackComponent(debugActor);

            var demoName           = Demo.MostRecentlySavedDemoPath;
            var demoSpeed          = 1;
            var shouldSkipSnapshot = DebugLevel == DebugLevel.Off;

            void SetRandomSeedFromString(string seed)
            {
                gameCartridge.Random.Seed = (int)NoiseBasedRNG.SeedFromString(seed);
            }

            this.specification.commandLineArgs.RegisterEarlyFlagArg("skipsnapshot", () => { shouldSkipSnapshot = true; });
            this.specification.commandLineArgs.RegisterEarlyValueArg("randomseed", SetRandomSeedFromString);
            this.specification.commandLineArgs.RegisterEarlyValueArg("demopath", arg => { demoName = arg; });
            this.specification.commandLineArgs.RegisterEarlyValueArg("demospeed", arg => { demoSpeed = int.Parse(arg); });
            this.specification.commandLineArgs.RegisterEarlyValueArg("demo", arg =>
            {
                switch (arg)
                {
                case "record":
                    new DemoRecorderComponent(debugActor, new Demo.Recorder(gameCartridge, demoName));
                    break;

                case "playback":
                    DemoPlayback = demoPlaybackComponent.SetDemo(gameCartridge, Demo.FromDisk_Sync(demoName, MachinaClient.FileSystem), demoName, demoSpeed);
                    break;

                case "playback-nogui":
                    DemoPlayback = demoPlaybackComponent.SetDemo(gameCartridge, Demo.FromDisk_Sync(demoName, MachinaClient.FileSystem), demoName, demoSpeed);
                    demoPlaybackComponent.ShowGui = false;
                    break;

                default:
                    MachinaClient.Print("Unknown demo mode", arg);
                    break;
                }
            });

            this.specification.commandLineArgs.RegisterEarlyFlagArg("debug",
                                                                    () => { DebugLevel = DebugLevel.Active; });

#if DEBUG
            // PlayIntroAndLoadGame(gameCartridge);
            InsertGameCartridgeAndRun(gameCartridge);
#else
            if (SkipIntro)
            {
                InsertGameCartridgeAndRun(gameCartridge);
            }
            else
            {
                PlayIntroAndLoadGame(gameCartridge);
            }
#endif
            // Currently we go [SetupDebugScene] -> [LoadGame] -> [LateSetup], hopefully the cartridge system will mitigate the need for this.
            if (GamePlatform.IsDesktop)
            {
                // NOTE: If we play the intro in a debug build this flag will not be honored, tech debt.
                new SnapshotTaker(debugActor, shouldSkipSnapshot);
            }
        }