コード例 #1
0
        protected override void Initialize()
        {
            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            // Add it first so that it can obtained by the UI system
            Input = new InputManager(Services);
            Services.AddService(Input);
            GameSystems.Add(Input);

            // Initialize the systems
            base.Initialize();

            Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            GameSystems.Add(DebugRenderSystem);
            GameSystems.Add(DebugTextSystem);
            GameSystems.Add(ProfilingSystem);

            EffectSystem = new EffectSystem(Services);
            Services.AddService(EffectSystem);

            // prepare effect compilation settings if we have a settings object
            if (Settings != null)
            {
                // align settings with what we may be forcing
                if (ForceReleaseEffects)
                {
                    Settings.CompilationMode = CompilationMode.Release;
                }
                if (ForceCollectEffects)
                {
                    // we want to collect effects. make sure they are release versions
                    Settings.EffectCompilation = EffectCompilationMode.Local;
                    Settings.CompilationMode   = CompilationMode.Release;
                }
                else if (Settings.CompilationMode == CompilationMode.Testing || Settings.CompilationMode == CompilationMode.Debug)
                {
                    // don't collect debug shaders, we won't want to distribute them!
                    Settings.EffectCompilation = EffectCompilationMode.Local;
                }
            }

            // If requested in game settings, compile effects remotely and/or notify new shader requests
            EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem, Settings?.PackageName,
                                                                               ForceCollectEffects ? EffectCompilationMode.Local : (Settings?.EffectCompilation ?? EffectCompilationMode.Local));

            // Setup shader compiler settings from a compilation mode.
            EffectSystem.SetCompilationMode(ForceReleaseEffects || ForceCollectEffects ? CompilationMode.Release : (Settings?.CompilationMode ?? CompilationMode.Release));

            GameSystems.Add(EffectSystem);

            if (Settings != null)
            {
                Streaming.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>());
            }
            GameSystems.Add(Streaming);
            GameSystems.Add(SceneSystem);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the VR System
            GameSystems.Add(VRDeviceSystem);

            // TODO: data-driven?
            Content.Serializer.RegisterSerializer(new ImageSerializer());

            OnGameStarted(this);
        }
コード例 #2
0
        protected override void Initialize()
        {
            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            // Add it first so that it can obtained by the UI system
            Input = new InputManager(Services);
            Services.AddService(Input);
            GameSystems.Add(Input);

            // Initialize the systems
            base.Initialize();

            Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            GameSystems.Add(DebugTextSystem);
            GameSystems.Add(ProfilingSystem);

            EffectSystem = new EffectSystem(Services);
            Services.AddService(EffectSystem);

            // If requested in game settings, compile effects remotely and/or notify new shader requests
            EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem, Settings?.PackageName, Settings?.EffectCompilation ?? EffectCompilationMode.Local, Settings?.RecordUsedEffects ?? false);

            // Setup shader compiler settings from a compilation mode.
            // TODO: We might want to provide overrides on the GameSettings to specify debug and/or optim level specifically.
            if (Settings != null)
            {
                EffectSystem.SetCompilationMode(Settings.CompilationMode);
            }

            GameSystems.Add(EffectSystem);

            if (Settings != null)
            {
                Streaming.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>());
            }
            GameSystems.Add(Streaming);
            GameSystems.Add(SceneSystem);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the VR System
            GameSystems.Add(VRDeviceSystem);

            // TODO: data-driven?
            Content.Serializer.RegisterSerializer(new ImageSerializer());

            OnGameStarted(this);
        }