Esempio n. 1
0
        /// <summary>
        /// Initializes the <see cref="Komodo.Core.Engine.Graphics.GraphicsManager"/> and all <see cref="Komodo.Core.ECS.Systems.ISystem"/> objects.
        /// </summary>
        public void Initialize()
        {
            GraphicsManager.Initialize();
            DefaultSpriteShader = new BasicEffect(GraphicsManager.GraphicsDeviceManager.GraphicsDevice)
            {
                TextureEnabled     = true,
                VertexColorEnabled = true,
            };
            GraphicsManager.VSync = false;

            CameraSystem.Initialize();
            SoundSystem.Initialize();

            var physicsSystems = PhysicsSystems.ToArray();

            foreach (var system in physicsSystems)
            {
                system.Initialize();
            }
            var render3DSystems = Render3DSystems.ToArray();

            foreach (var system in render3DSystems)
            {
                system.Initialize();
            }
            var render2DSystems = Render2DSystems.ToArray();

            foreach (var system in render2DSystems)
            {
                system.Initialize();
            }

            BehaviorSystem.Initialize();
        }
Esempio n. 2
0
        /// <summary>
        /// Creates and begins tracking a new <see cref="Komodo.Core.ECS.Systems.PhysicsSystem"/>.
        /// </summary>
        public PhysicsSystem CreatePhysicsSystem()
        {
            var system = new PhysicsSystem(this);

            PhysicsSystems.Add(system);
            return(system);
        }
Esempio n. 3
0
 private MainGame(string title, string startingViewName, SceneFactory sceneFactory, IController controller)
 {
     _graphics             = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     _startingViewName     = startingViewName;
     _sceneFactory         = sceneFactory;
     _controller           = controller;
     _metrics = new Metrics();
     _ecs     = Entity.System;
     Renderers.RegisterAll(_ecs);
     PhysicsSystems.RegisterAll(_ecs);
     Window.Title = title;
 }
Esempio n. 4
0
        /// <summary>
        /// Updates <see cref="Komodo.Core.ECS.Systems.ISystem"/> objects.
        /// </summary>
        /// <param name="gameTime">Time passed since last <see cref="Update(GameTime)"/>.</param>
        public void Update(GameTime gameTime)
        {
            InputManager.Update();

            BehaviorSystem.PreUpdate(gameTime);
            CameraSystem.PreUpdate(gameTime);
            SoundSystem.PreUpdate(gameTime);
            var physicsSystems = PhysicsSystems.ToArray();

            foreach (var system in physicsSystems)
            {
                system.PreUpdate(gameTime);
            }
            var render3DSystems = Render3DSystems.ToArray();

            foreach (var system in render3DSystems)
            {
                system.PreUpdate(gameTime);
            }
            var render2DSystems = Render2DSystems.ToArray();

            foreach (var system in render2DSystems)
            {
                system.PreUpdate(gameTime);
            }

            BehaviorSystem.UpdateComponents(gameTime);
            CameraSystem.UpdateComponents(gameTime);
            SoundSystem.UpdateComponents(gameTime);
            foreach (var system in physicsSystems)
            {
                system.UpdateComponents(gameTime);
            }

            BehaviorSystem.PostUpdate(gameTime);
            CameraSystem.PostUpdate(gameTime);
            SoundSystem.PostUpdate(gameTime);
            foreach (var system in physicsSystems)
            {
                system.PostUpdate(gameTime);
            }
            foreach (var system in render3DSystems)
            {
                system.PostUpdate(gameTime);
            }
            foreach (var system in render2DSystems)
            {
                system.PostUpdate(gameTime);
            }
        }
        private NeedlesslyComplexMainGame(string title, string startingViewName, SceneFactory sceneFactory, IController controller)
        {
            _graphics = new GraphicsDeviceManager(this);
            _graphics.GraphicsProfile = GraphicsProfile.HiDef;
            Content.RootDirectory     = "Content";
            _startingViewName         = startingViewName;
            _sceneFactory             = sceneFactory;
            _controller = controller;
            MouseSnapshot.MousePositionProvider = new MouseViewport();
            _ecs = Entity.System;
            _ecs.Register(new MotionStateSelector());
            Renderers.RegisterAll(_ecs);
            PhysicsSystems.RegisterAll(_ecs);
            AnimationSystems.RegisterAll(_ecs);
            MouseSystems.RegisterAll(_ecs);
            KeyboardSystems.RegisterAll(_ecs);
            _ecs.Register(new CameraDirector());
            Window.Title = title;
#if DEBUG
            DevelopmentSystems.RegisterAll(_ecs);
#endif
        }