Files
orni-attack/source/game/systems/continue_system.hpp
T
JailDesigner 816bc02d9d Fase 9b: extraer ContinueSystem de GameScene
GameScene::actualitzar_continue, processar_input_continue y el
helper check_and_apply_continue_timeout (3 funciones, ~140 LOC) salen
a Systems::ContinueScreen en source/game/systems/continue_system.{hpp,cpp}.

API:
- struct Systems::ContinueScreen::Context: agrupa el estado mutable
  (state, counter, tick_timer, continues_used, game_over_timer,
  lives/score/hit_timer arrays, ships, match_config) y un callback
  get_spawn_point inyectado por GameScene.
- update(ctx, dt): avanza countdown automatico y transiciona a
  GAME_OVER si timeout.
- processInput(ctx): START revive jugador(es), THRUST/SHOOT acelera
  countdown.

Helpers privados (revivePlayer, checkAndApplyTimeout) en anonymous
namespace del .cpp para evitar contaminar el header.

GameOverState ahora con underlying type explicito (uint8_t) para
permitir forward-declaration limpia en continue_system.hpp.

dibuixar_continue y unir_jugador se quedan en GameScene (render y
gameplay normal, no parte del state machine).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 07:50:43 +02:00

50 lines
1.7 KiB
C++

// continue_system.hpp - Pantalla de continue y máquina de estados de game over
// © 2025 Orni Attack
//
// Gestiona la transición CONTINUE → GAME_OVER, el countdown, los inputs de
// los jugadores para continuar la partida y la revivificación. Vive como
// estado en GameScene; este módulo solo opera sobre referencias a ese estado.
#pragma once
#include <array>
#include <cstdint>
#include <functional>
#include "core/system/game_config.hpp"
#include "core/types.hpp"
#include "game/entities/ship.hpp"
// Forward declaration: GameOverState es un enum class definido en game_scene.hpp.
// Para no traer toda la cabecera, lo declaramos aquí.
enum class GameOverState : uint8_t;
namespace Systems::ContinueScreen {
// Todo lo que el ContinueSystem lee/modifica.
struct Context {
GameOverState& state;
int& counter;
float& tick_timer;
int& continues_used;
float& game_over_timer;
std::array<int, 2>& lives_per_player;
std::array<int, 2>& score_per_player;
std::array<float, 2>& hit_timer_per_player;
std::array<Ship, 2>& ships;
GameConfig::MatchConfig& match_config;
// Helper inyectado por GameScene (obtenir_punt_spawn).
std::function<Vec2(uint8_t /*player_id*/)> get_spawn_point;
};
// Avanza el countdown automático (tick interno). Si el contador cae bajo 0,
// transiciona a GAME_OVER y arranca el timer final.
void update(Context& ctx, float delta_time);
// Procesa input durante la pantalla CONTINUE:
// START → revive al jugador (1 o 2, según quién pulsó).
// THRUST/SHOOT → acelera el countdown.
void processInput(Context& ctx);
} // namespace Systems::ContinueScreen