extract unlock state from Simulation to UnlockState class
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -22,6 +20,7 @@
|
||||
#include "Rotation.h"
|
||||
#include "Tick.h"
|
||||
#include "TracePrintRequestedEvent.h"
|
||||
#include "UnlockState.h"
|
||||
|
||||
class AiSystem;
|
||||
class BuildingSystem;
|
||||
@@ -203,69 +202,11 @@ private:
|
||||
entt::entity m_playerStation2Entity;
|
||||
entt::entity m_currentEnemyStationEntities[2];
|
||||
|
||||
// Schematic unlock state (REQ-DEF-SCHEMATIC-DROP).
|
||||
struct SchematicState
|
||||
{
|
||||
bool unlocked;
|
||||
};
|
||||
std::map<std::string, SchematicState> m_schematicLevels;
|
||||
std::map<std::string, SchematicState> m_moduleSchematicLevels;
|
||||
std::map<std::string, SchematicState> m_buildingLevels;
|
||||
|
||||
// Unlock groups awarded so far (REQ-LOCK-EXPLICIT). Group ids.
|
||||
std::set<std::string> m_awardedUnlockGroupIds;
|
||||
|
||||
// Ids granted by some unlock group, per kind — cached from config at init.
|
||||
// An item starts locked iff it appears in the corresponding set.
|
||||
std::set<std::string> m_grantedShipIds;
|
||||
std::set<std::string> m_grantedModuleIds;
|
||||
std::set<std::string> m_grantedBuildingIds;
|
||||
std::set<std::string> m_grantedRecipeIds;
|
||||
|
||||
// Builds the granted-id sets and initializes all per-item unlock maps from
|
||||
// them (shared by the constructor and reset). Ends with recomputeUnlocked().
|
||||
void initializeUnlockState();
|
||||
|
||||
// Builds a schematic choice option for one unlock group (REQ-DEF-SCHEMATIC-DROP).
|
||||
SchematicChoiceOption makeUnlockOption(const UnlockGroupDef& group) const;
|
||||
|
||||
// Determinism helpers — fold sub-state into the hasher in deterministic order.
|
||||
static void appendSchematicMap(Hasher& hasher,
|
||||
const std::map<std::string, SchematicState>& levels);
|
||||
static void appendStringSet(Hasher& hasher, const std::set<std::string>& ids);
|
||||
|
||||
// Explicitly unlocked assembler recipe schematics (REQ-LOCK-EXPLICIT).
|
||||
std::set<std::string> m_unlockedRecipeSchematicIds;
|
||||
|
||||
// Implicit unlock sets derived from schematic state (REQ-LOCK-IMPLICIT).
|
||||
std::set<std::string> m_unlockedRecipeIds;
|
||||
std::set<std::string> m_unlockedItemIds;
|
||||
|
||||
// Recomputes m_unlockedRecipeIds and m_unlockedItemIds from current schematic state.
|
||||
void recomputeUnlocked();
|
||||
|
||||
// Result of the REQ-LOCK-IMPLICIT traversal.
|
||||
struct UnlockedSets
|
||||
{
|
||||
std::set<std::string> itemIds;
|
||||
std::set<std::string> recipeIds;
|
||||
};
|
||||
|
||||
// Pure REQ-LOCK-IMPLICIT traversal given hypothetical explicit-unlock sets.
|
||||
UnlockedSets computeUnlockedSets(const std::set<std::string>& unlockedShipSchematicIds,
|
||||
const std::set<std::string>& unlockedModuleSchematicIds,
|
||||
const std::set<std::string>& unlockedRecipeSchematicIds) const;
|
||||
|
||||
// Current explicit-unlock id sets, derived from m_schematicLevels / m_moduleSchematicLevels.
|
||||
std::set<std::string> getUnlockedShipSchematicIds() const;
|
||||
std::set<std::string> getUnlockedModuleSchematicIds() const;
|
||||
|
||||
// True if every prerequisite unlock group has been awarded (REQ-LOCK-PREREQ).
|
||||
bool prerequisitesSatisfied(const std::vector<std::string>& requiredGroupIds) const;
|
||||
|
||||
// Ids (sorted alphabetically by display name) of the recipes in
|
||||
// hypothetical.recipeIds that are not yet in m_unlockedRecipeIds.
|
||||
std::vector<std::string> computeNewlyUnlockedRecipeIds(const UnlockedSets& hypothetical) const;
|
||||
// Schematic/unlock bookkeeping (REQ-DEF-SCHEMATIC-DROP, REQ-LOCK-EXPLICIT,
|
||||
// REQ-LOCK-IMPLICIT, REQ-LOCK-BUILDING, REQ-LOCK-PREREQ). Constructed before
|
||||
// initializeSubsystems() runs since BuildingSystem's spawn-gating lambda
|
||||
// calls into it (see initializeSubsystems()).
|
||||
UnlockState m_unlockState;
|
||||
|
||||
EntityAdmin m_admin;
|
||||
BeltSystem m_beltSystem;
|
||||
|
||||
Reference in New Issue
Block a user