protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); if (State == GameState.Active) { deltaTime = (float)e.Time; cumulativeTime += deltaTime; currentFishModelIndex += 24 * deltaTime; if (autoPilot) { if (leaderTarget == Vector3.Zero || Vector3.Distance(LeaderBoid.Position, leaderTarget) < 2 * Boid.MAX_SPEED) { leaderTarget = GetRandomPosition(); } LeaderBoid.MoveToPoint(leaderTarget, deltaTime); } else { LeaderBoid.CheckBoundaries(); LeaderBoid.Velocity = Vector3.Clamp(LeaderBoid.Velocity, -Vector3.One * Boid.MAX_SPEED, Vector3.One * Boid.MAX_SPEED); LeaderBoid.CalculatePositionAndRotation(deltaTime); } Boids.ForEach(boid => ((Boid)boid).Move(Boids.Where(b => b != boid).ToList(), deltaTime)); UpdateFlockMiddle(); Camera.Update(); if (shouldPause) { shouldPause = false; State = GameState.Paused; LogDebugInfo(); } } ProcessEvents(); }