feat: limitar modo BOIDS a escenarios con ≤1.000 bolas
Pulsar B en escenarios 6-8 (o custom >1K) no activa boids y muestra notificación. Cambiar de escenario estando en BOIDS queda bloqueado si el destino supera BOIDS_MAX_BALLS (= SCENE_BALLS_5). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,8 @@ constexpr int BALL_COUNT_SCENARIOS[SCENARIO_COUNT] = {
|
||||
SCENE_BALLS_5, SCENE_BALLS_6, SCENE_BALLS_7, SCENE_BALLS_8
|
||||
};
|
||||
|
||||
constexpr int BOIDS_MAX_BALLS = SCENE_BALLS_5; // 1 000 bolas máximo en modo BOIDS
|
||||
|
||||
// Límites de escenario para modos automáticos (índices en BALL_COUNT_SCENARIOS)
|
||||
// 0 1 2 3 4 5 6 7
|
||||
constexpr int DEMO_AUTO_MIN_SCENARIO = 2; // mínimo 100 bolas
|
||||
|
||||
@@ -564,7 +564,21 @@ void Engine::toggleDepthZoom() {
|
||||
}
|
||||
|
||||
// Boids (comportamiento de enjambre)
|
||||
bool Engine::isScenarioAllowedForBoids(int scenario_id) const {
|
||||
int ball_count = (scenario_id == CUSTOM_SCENARIO_IDX)
|
||||
? custom_scenario_balls_
|
||||
: BALL_COUNT_SCENARIOS[scenario_id];
|
||||
return ball_count <= BOIDS_MAX_BALLS;
|
||||
}
|
||||
|
||||
void Engine::toggleBoidsMode(bool force_gravity_on) {
|
||||
if (current_mode_ != SimulationMode::BOIDS) {
|
||||
// Intentando activar BOIDS — verificar escenario actual
|
||||
if (!isScenarioAllowedForBoids(scene_manager_->getCurrentScenario())) {
|
||||
showNotificationForAction("Boids: máximo 1.000 pelotas");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (current_mode_ == SimulationMode::BOIDS) {
|
||||
// Salir del modo boids
|
||||
current_mode_ = SimulationMode::PHYSICS;
|
||||
@@ -654,6 +668,12 @@ void Engine::setCustomScenario(int balls) {
|
||||
|
||||
// Escenarios (número de pelotas)
|
||||
void Engine::changeScenario(int scenario_id, const char* notification_text) {
|
||||
if (current_mode_ == SimulationMode::BOIDS) {
|
||||
if (!isScenarioAllowedForBoids(scenario_id)) {
|
||||
showNotificationForAction("Boids: máximo 1.000 pelotas");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Pasar el modo actual al SceneManager para inicialización correcta
|
||||
scene_manager_->changeScenario(scenario_id, current_mode_);
|
||||
|
||||
|
||||
@@ -269,6 +269,9 @@ class Engine {
|
||||
// PostFX helper
|
||||
void applyPostFXPreset(int mode);
|
||||
|
||||
// Boids: comprueba si un escenario tiene ≤ BOIDS_MAX_BALLS bolas
|
||||
bool isScenarioAllowedForBoids(int scenario_id) const;
|
||||
|
||||
// GPU helpers
|
||||
bool loadGpuSpriteTexture(size_t index); // Upload one sprite texture to GPU
|
||||
void recreateOffscreenTexture(); // Recreate when resolution changes
|
||||
|
||||
Reference in New Issue
Block a user