/// <summary> /// Loads all needed ContentManager content. /// </summary> public void LoadContent(bool isReload, ContentManager contentManager, bool fromCompositor) { this.content = contentManager; if (!fromCompositor && !isReload) { //////////////////////////////////////////////////////////////////////////// // This must always remain the first entity created this.sceneMgrRootEntity = new BaseEntity(this.Game); this.sceneMgrRootEntity.Name = "SceneMgr Root"; this.AddEntity(sceneMgrRootEntity); //////////////////////////////////////////////////////////////////////////// this.cameraInterface = new CameraInterface(this.Game); AddInterface(this.cameraInterface); AddInterface(new PhysicsInterface(this.Game)); AddInterface(new InputInterface(this.Game)); this.entityLoader = new EntityLoader(this.Game); AddInterface(this.Game.Graphics); SetupBaseCamera(); MsgSetGravity msgSetGrav = ObjectPool.Aquire <MsgSetGravity>(); msgSetGrav.Gravity = new Vector3(0.0f, -60.00f, 0.0f); this.Game.SendInterfaceMessage(msgSetGrav, InterfaceType.Physics); // Start the first physics frame. MsgBeginPhysicsFrame msgBeginFrame = ObjectPool.Aquire <MsgBeginPhysicsFrame>(); msgBeginFrame.GameTime = new GameTime(); this.Game.SendInterfaceMessage(msgBeginFrame, InterfaceType.Physics); } }
/// <summary> /// Updates all entities and interfaces that are currently running /// </summary> /// <param name="gameTime">Contains timer information</param> protected override void UpdateCore(GameTime gameTime) { ProcessEntityQueues(); gameTimeData = gameTime; // Update all interfaces foreach (QSInterface qsInterface in this.interfaces.Values) { qsInterface.Update(gameTime); } // End the current physics frame MsgEndPhysicsFrame msgEndFrame = ObjectPool.Aquire <MsgEndPhysicsFrame>(); this.Game.SendInterfaceMessage(msgEndFrame, InterfaceType.Physics); foreach (BaseEntity entity in this.activeEntities) { entity.Update(gameTime); } if (msgEndFrame.FrameEnded) { foreach (BaseEntity entity in this.activeEntities) { entity.FixedUpdate(gameTime); } } // Begin the next physics frame MsgBeginPhysicsFrame msgBeginFrame = ObjectPool.Aquire <MsgBeginPhysicsFrame>(); msgBeginFrame.GameTime = gameTime; this.Game.SendInterfaceMessage(msgBeginFrame, InterfaceType.Physics); }