feat(entities): migrar la configuració del player a data/entities/player/player.yaml
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// player_config.hpp - Configuració de la nau del player carregada des de YAML
|
||||
// © 2026 JailDesigner
|
||||
//
|
||||
// POD struct amb sub-structs per organitzar els paràmetres del jugador
|
||||
// (física, invulnerabilitat, hurt, empenta visual, colors, weapon). Es
|
||||
// construeix a partir d'un node fkyaml carregat per EntityLoader.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "external/fkyaml_node.hpp"
|
||||
|
||||
struct PlayerConfig {
|
||||
struct ShapeCfg {
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct PhysicsCfg {
|
||||
float mass;
|
||||
float restitution;
|
||||
float linear_damping;
|
||||
float angular_damping;
|
||||
float collision_radius;
|
||||
float rotation_speed; // rad/s
|
||||
float acceleration; // px/s^2 multiplicat per la massa
|
||||
float max_velocity; // px/s (clamp post-integració)
|
||||
float death_impact_factor; // [0..1] moment transferit a l'enemic al morir
|
||||
};
|
||||
|
||||
struct InvulnerabilityCfg {
|
||||
float duration;
|
||||
float blink_visible;
|
||||
float blink_invisible;
|
||||
};
|
||||
|
||||
struct HurtCfg {
|
||||
float duration;
|
||||
float blink_hz;
|
||||
};
|
||||
|
||||
struct VisualThrustCfg {
|
||||
float push_divisor;
|
||||
float scale_divisor;
|
||||
};
|
||||
|
||||
struct ColorsCfg {
|
||||
SDL_Color normal;
|
||||
SDL_Color hurt;
|
||||
};
|
||||
|
||||
struct WeaponCfg {
|
||||
float bullet_speed;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
ShapeCfg shape;
|
||||
PhysicsCfg physics;
|
||||
InvulnerabilityCfg invulnerability;
|
||||
HurtCfg hurt;
|
||||
VisualThrustCfg visual_thrust;
|
||||
ColorsCfg colors;
|
||||
WeaponCfg weapon;
|
||||
|
||||
// Construeix un PlayerConfig a partir del node YAML. Retorna std::nullopt
|
||||
// si falten camps requerits o el format no és vàlid (el caller decideix
|
||||
// si abortar).
|
||||
static auto fromYaml(const fkyaml::node& node) -> std::optional<PlayerConfig>;
|
||||
};
|
||||
Reference in New Issue
Block a user