コード例 #1
0
        public void Update_ShouldFirstRecordSystemsThenRecordFrame()
        {
            // Arrange
            GameTime.FixedDeltaTime = TimeSpan.FromSeconds(0.1);
            var gameTime = new GameTime(TimeSpan.FromSeconds(0.15));

            _gameTimeProvider.GetGameTime().Returns(gameTime);

            var scene = TestSceneFactory.Create();

            _sceneManager.CurrentScene.Returns(scene);

            var gameLoop = GetGameLoop();

            // Act
            gameLoop.Update();

            // Assert
            Received.InOrder(() =>
            {
                _performanceStatisticsRecorder.RecordSystemExecution(InputSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(BehaviorSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(CustomSystem1Name);
                _performanceStatisticsRecorder.RecordSystemExecution(CustomSystem2Name);
                _performanceStatisticsRecorder.RecordSystemExecution(CustomSystem3Name);
                _performanceStatisticsRecorder.RecordSystemExecution(PhysicsSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(EntityDestructionSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(BehaviorSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(CustomSystem1Name);
                _performanceStatisticsRecorder.RecordSystemExecution(CustomSystem2Name);
                _performanceStatisticsRecorder.RecordSystemExecution(CustomSystem3Name);
                _performanceStatisticsRecorder.RecordSystemExecution(PhysicsSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(AudioSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(AnimationSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(RenderingSystemName);
                _performanceStatisticsRecorder.RecordSystemExecution(EntityDestructionSystemName);
                _performanceStatisticsRecorder.RecordFrame();
            });
        }
コード例 #2
0
ファイル: GameLoop.cs プロジェクト: dawidkomorowski/geisha
        public void Update()
        {
            _sceneManager.OnNextFrame();

            var scene = _sceneManager.CurrentScene;

            Debug.Assert(scene != null, nameof(scene) + "scene != null");

            var gameTime = _gameTimeProvider.GetGameTime();

            _timeToSimulate += gameTime.DeltaTime;
            var fixedUpdatesPerFrame = 0;

            while (_timeToSimulate >= GameTime.FixedDeltaTime && (fixedUpdatesPerFrame < _fixedUpdatesPerFrameLimit || _fixedUpdatesPerFrameLimit == 0))
            {
                using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.InputSystemName))
                {
                    _engineSystems.InputSystem.ProcessInput(scene);
                }

                using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.BehaviorSystemName))
                {
                    _engineSystems.BehaviorSystem.ProcessBehaviorFixedUpdate(scene);
                }

                foreach (var customSystem in _engineSystems.CustomSystems)
                {
                    using (_performanceStatisticsRecorder.RecordSystemExecution(customSystem.Name))
                    {
                        customSystem.ProcessFixedUpdate(scene);
                    }
                }

                using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.PhysicsSystemName))
                {
                    _engineSystems.PhysicsSystem.ProcessPhysics(scene);
                }

                using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.EntityDestructionSystemName))
                {
                    _engineSystems.EntityDestructionSystem.DestroyEntitiesAfterFixedTimeStep(scene);
                }

                _timeToSimulate -= GameTime.FixedDeltaTime;
                fixedUpdatesPerFrame++;
            }

            using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.BehaviorSystemName))
            {
                _engineSystems.BehaviorSystem.ProcessBehaviorUpdate(scene, gameTime);
            }

            foreach (var customSystem in _engineSystems.CustomSystems)
            {
                using (_performanceStatisticsRecorder.RecordSystemExecution(customSystem.Name))
                {
                    customSystem.ProcessUpdate(scene, gameTime);
                }
            }

            using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.PhysicsSystemName))
            {
                _engineSystems.PhysicsSystem.PreparePhysicsDebugInformation();
            }

            using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.AudioSystemName))
            {
                _engineSystems.AudioSystem.ProcessAudio(scene);
            }

            using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.AnimationSystemName))
            {
                _engineSystems.AnimationSystem.ProcessAnimations(scene, gameTime);
            }

            using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.RenderingSystemName))
            {
                _engineSystems.RenderingSystem.RenderScene(scene);
            }

            using (_performanceStatisticsRecorder.RecordSystemExecution(_engineSystems.EntityDestructionSystemName))
            {
                _engineSystems.EntityDestructionSystem.DestroyEntitiesAfterFullFrame(scene);
            }

            _performanceStatisticsRecorder.RecordFrame();
            _coreDiagnosticInfoProvider.UpdateDiagnostics(scene);
        }