public override void Update(float delta) { foreach (int entity in ECS.GetEntitiesWithComponent <CPhysics>()) { CPhysics physics = ECS.GetComponent <CPhysics>(entity); if (physics.isMoving) { HandleMovement(delta, physics); } if (physics.isMoving) { continue; } int x = 0, y = 0; if (physics.playerControlled) { if (Input.IsKeyDown(Keys.Down)) { y++; } if (Input.IsKeyDown(Keys.Up)) { y--; } if (Input.IsKeyDown(Keys.Left)) { x--; } if (Input.IsKeyDown(Keys.Right)) { x++; } } else { x = physics.queuedMovement.X; y = physics.queuedMovement.Y; } if (x != 0 || y != 0) { physics.queuedMovement = new Point(x, y); physics.isMoving = true; } if (physics.isMoving) { HandleMovement(delta, physics); } } }
public override void Update(float delta) { foreach (int entity in ECS.GetEntitiesWithComponent <CSimpleAI>()) { CSimpleAI ai = ECS.GetComponent <CSimpleAI>(entity); CPhysics physics = ECS.GetComponent <CPhysics>(entity); if (physics == null) { continue; } if (physics.isMoving) { continue; } physics.isMoving = true; physics.queuedMovement = new Point(1, 0); } }