public IState UpdateState(ref GameSettings gameSettings, GameTime gameTime, Camera camera, KeyboardState currentKey, KeyboardState prevKey, MouseState currentMouse, MouseState prevMouse) { Guid playerId = this._components.Entities.Where(c => c.HasComponents(ComponentFlags.IS_PLAYER)).FirstOrDefault().Id; // Level input if (currentKey.IsKeyDown(Keys.Escape) && prevKey.IsKeyUp(Keys.Escape)) { return(new PauseState(this._content, this)); } if (currentKey.IsKeyDown(Keys.Q) && prevKey.IsKeyUp(Keys.Q)) { return(new TestLevel(this._content, camera)); } if (currentKey.IsKeyDown(Keys.F) && prevKey.IsKeyUp(Keys.F)) { this._components.DelayedActions.Add(new Action(() => { for (int i = 0; i < 10; i++) { Guid testId = ArkCreation.SpawnEntityWithOverrides(Constants.Ark.Monsters.TestNpc, ref this._components, new BaseEntity(ComponentFlags.POSITION) { Position = new Position() { OriginPosition = new Vector2(Constants.Random.Next(20, this._gridCols * 48), Constants.Random.Next(0, this._gridRows * 48)) } }); InventorySystem.GenerateRandomInventoryItemsForEntity(this._components, testId); } })); } if (currentKey.IsKeyDown(Keys.E) && prevKey.IsKeyUp(Keys.E)) { this._components.DelayedActions.Add(new Action(() => { Guid testId = ArkCreation.SpawnEntityWithOverrides(Constants.Ark.Monsters.TestNpc, ref this._components, new BaseEntity(ComponentFlags.POSITION) { Position = new Position() { OriginPosition = this._components.Positions[playerId].OriginPosition } }); InventorySystem.GenerateRandomInventoryItemsForEntity(this._components, testId); })); } if (currentKey.IsKeyDown(Keys.R) && prevKey.IsKeyUp(Keys.R)) { this._components.DelayedActions.Add(new Action(() => { Guid id = this._components.Entities.Where(x => x.HasDrawableSprite() && !x.HasComponents(ComponentFlags.IS_PLAYER) && x.HasComponents(ComponentFlags.INVENTORY)).First().Id; InventorySystem.DropEntityInventory(this._components, id); this._components.DestroyEntity(id); })); } // Camera Updates CameraSystem.ControlCamera(currentKey, prevKey, camera, gameTime); CameraSystem.PanCamera(camera, gameTime); // Entity Movement Updates this._components.Entities.ForEach(c => { if (c.IsMovable()) { switch (this._components.Movements[c.Id].MovementType) { case MovementType.AI: //AI Movement System Call break; case MovementType.INPUT: MovementSystem.InputMovement(currentKey, prevKey, gameTime, this._components.Positions[c.Id], this._components.Movements[c.Id]); break; case MovementType.DIRECTED: MovementSystem.UpdateMovingEntities(this._components.Movements[c.Id], this._components.Positions[c.Id], gameTime, this._components, c); break; } } }); // Entity Information Updates // Collision CollisionSystem.CheckForCollisions(this._components, this._collisionPartition); CollisionSystem.HandleCollisions(this._components); // Set up for next frame CameraSystem.UpdateCameraTarget(this._components, camera); CollisionSystem.ResetCollisions(ref this._components); this._components.InvokeDelayedActions(); return(this); }