38 lines
1018 B
C++
38 lines
1018 B
C++
// bullet_registry.cpp - Implementació del registre de bala
|
|
// © 2026 JailDesigner
|
|
|
|
#include "game/entities/bullet_registry.hpp"
|
|
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
|
|
#include "core/entities/entity_loader.hpp"
|
|
|
|
BulletConfig BulletRegistry::config;
|
|
bool BulletRegistry::loaded = false;
|
|
|
|
auto BulletRegistry::load() -> bool {
|
|
auto yaml = Entities::EntityLoader::load("bullet");
|
|
if (!yaml) {
|
|
std::cerr << "[BulletRegistry] Error: no s'ha pogut carregar bullet.yaml\n";
|
|
return false;
|
|
}
|
|
auto cfg = BulletConfig::fromYaml(*yaml);
|
|
if (!cfg) {
|
|
std::cerr << "[BulletRegistry] Error: format invàlid a bullet.yaml\n";
|
|
return false;
|
|
}
|
|
config = *cfg;
|
|
loaded = true;
|
|
std::cout << "[BulletRegistry] Configuració de bala carregada.\n";
|
|
return true;
|
|
}
|
|
|
|
auto BulletRegistry::get() -> const BulletConfig& {
|
|
if (!loaded) {
|
|
std::cerr << "[BulletRegistry] FATAL: get() abans de load()\n";
|
|
std::exit(EXIT_FAILURE);
|
|
}
|
|
return config;
|
|
}
|