allow to configure when which schematic gets unlockable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -51,7 +51,7 @@ struct ShipLoot
|
||||
struct ShipDef
|
||||
{
|
||||
std::string id;
|
||||
bool availableFromStart;
|
||||
int unlockAtStationLevel;
|
||||
std::vector<std::string> layout;
|
||||
|
||||
ShipSchematic schematic;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user