Implement config-driven unlock groups so that multiple things can be unlocked at once (including buildings)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Building.h"
|
||||
#include "BuildingConfig.h"
|
||||
#include "BuildingSystem.h"
|
||||
@@ -46,7 +48,17 @@ const ShipDef* findAvailableSchematic(const GameConfig& cfg)
|
||||
{
|
||||
for (const ShipDef& def : cfg.ships.ships)
|
||||
{
|
||||
if (def.unlockAtStationLevel == -1) { return &def; }
|
||||
// A ship starts unlocked iff no unlock group grants it (REQ-LOCK-EXPLICIT).
|
||||
bool granted = false;
|
||||
for (const UnlockGroupDef& group : cfg.unlocks.groups)
|
||||
{
|
||||
if (std::find(group.ships.begin(), group.ships.end(), def.id) != group.ships.end())
|
||||
{
|
||||
granted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!granted) { return &def; }
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user