allow to configure when which schematic gets unlockable

This commit is contained in:
2026-06-10 20:54:16 +02:00
parent 26857e8414
commit aad094f842
9 changed files with 25 additions and 21 deletions

View File

@@ -403,7 +403,7 @@ ShipsConfig ConfigLoader::loadShips(const std::string& path)
ShipDef def;
def.id = requireString(mt["id"], file, elemPath + ".id");
def.availableFromStart = requireBool(mt["available_from_start"], file, elemPath + ".available_from_start");
def.unlockAtStationLevel = static_cast<int>(requireInt(mt["unlock_at_station_level"], file, elemPath + ".unlock_at_station_level"));
def.layout = requireStringArray(mt["layout"], file, elemPath + ".layout");
// Schematic

View File

@@ -51,7 +51,7 @@ struct ShipLoot
struct ShipDef
{
std::string id;
bool availableFromStart;
int unlockAtStationLevel;
std::vector<std::string> layout;
ShipSchematic schematic;

View File

@@ -66,8 +66,8 @@ Simulation::Simulation(GameConfig config, unsigned int seed)
for (const ShipDef& def : m_config.ships.ships)
{
SchematicState state;
state.unlocked = def.availableFromStart;
state.level = def.availableFromStart ? def.schematic.playerProductionLevel : 0;
state.unlocked = (def.unlockAtStationLevel == -1);
state.level = (def.unlockAtStationLevel == -1) ? def.schematic.playerProductionLevel : 0;
m_schematicLevels[def.id] = state;
}
@@ -139,8 +139,8 @@ void Simulation::reset(unsigned int seed)
for (const ShipDef& def : m_config.ships.ships)
{
SchematicState state;
state.unlocked = def.availableFromStart;
state.level = def.availableFromStart ? def.schematic.playerProductionLevel : 0;
state.unlocked = (def.unlockAtStationLevel == -1);
state.level = (def.unlockAtStationLevel == -1) ? def.schematic.playerProductionLevel : 0;
m_schematicLevels[def.id] = state;
}
@@ -473,19 +473,23 @@ void Simulation::tickDeathsAndLoot()
if (es0Gone && es1Gone &&
m_currentEnemyStationEntities[0] != entt::null)
{
const int destroyedLevel = m_waveSystem->generation();
m_waveSystem->onEnemyStationsDestroyed();
placeEnemyStationSet(m_waveSystem->generation());
awardSchematicDrop();
awardSchematicDrop(destroyedLevel);
}
}
void Simulation::awardSchematicDrop()
void Simulation::awardSchematicDrop(int destroyedStationLevel)
{
std::vector<std::string> ids;
ids.reserve(m_config.ships.ships.size());
for (const ShipDef& def : m_config.ships.ships)
{
ids.push_back(def.id);
if (def.unlockAtStationLevel == -1 || def.unlockAtStationLevel <= destroyedStationLevel)
{
ids.push_back(def.id);
}
}
std::uniform_int_distribution<int> dist(0, static_cast<int>(ids.size()) - 1);

View File

@@ -100,7 +100,7 @@ private:
void tickDeathsAndLoot();
// Award a random schematic drop (REQ-DEF-SCHEMATIC-DROP) and emit the event.
void awardSchematicDrop();
void awardSchematicDrop(int destroyedStationLevel);
GameConfig m_config;
std::mt19937 m_rng;