Fix world generation interface architecture
- Simplify IWorldGenerationFunction interface (5 required + 4 optional methods)
- Remove over-engineered methods (getProducedData, getRequiredPreviousFunctions, canExecute)
- Correct execute() signature to match implementations: execute(WorldData&, PlanetaryCore&)
- Add UniversalRegionFusionFunctionAdapter wrapper for template compatibility
- Update all 8 Phase 0/1 functions to implement corrected interface
- Delete unnecessary AWorldGenerationFunction abstract class
Phase 0 (2/2): InitializeWorldTerrain, InitializePlanetaryCore
Phase 1 (6/6): MeteoriteImpact, ImpactEffects, PlanetaryDifferentiation,
VolcanicRedistribution, Cooling, UniversalRegionFusion
All functions now properly inherit from IWorldGenerationFunction with
consistent configure/execute pattern.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
919b68afd0
commit
63a2d251ff
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "IWorldGenerationFunction.h"
|
||||||
#include "PlanetaryCore.h"
|
#include "PlanetaryCore.h"
|
||||||
|
#include "WorldData.h"
|
||||||
#include "warfactory/IDataNode.h"
|
#include "warfactory/IDataNode.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ namespace warfactory {
|
|||||||
*
|
*
|
||||||
* Process: Surface cools → Energy accumulated → Split between space loss and core transfer
|
* Process: Surface cools → Energy accumulated → Split between space loss and core transfer
|
||||||
*/
|
*/
|
||||||
class CoolingPhaseFunction {
|
class CoolingPhaseFunction : public IWorldGenerationFunction {
|
||||||
private:
|
private:
|
||||||
float surface_cooling_rate_per_cycle; // °C reduction per cycle for surface tiles (base rate)
|
float surface_cooling_rate_per_cycle; // °C reduction per cycle for surface tiles (base rate)
|
||||||
float energy_to_core_ratio; // Fraction of accumulated energy transferred to core
|
float energy_to_core_ratio; // Fraction of accumulated energy transferred to core
|
||||||
@ -34,24 +36,18 @@ public:
|
|||||||
CoolingPhaseFunction();
|
CoolingPhaseFunction();
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
// CONFIGURATION
|
// IWorldGenerationFunction Implementation
|
||||||
// ========================================
|
// ========================================
|
||||||
|
|
||||||
/**
|
void configure(const IDataNode& config) override;
|
||||||
* @brief Configure cooling process from JSON parameters
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
* @param config_node JSON configuration containing gradual_cooling parameters
|
std::string getStepName() const override;
|
||||||
* Expected structure:
|
bool isConfigured() const override;
|
||||||
* {
|
void reset() override;
|
||||||
* "surface_cooling_rate_per_cycle": 50,
|
|
||||||
* "energy_to_core_ratio": 0.3,
|
// ========================================
|
||||||
* "energy_to_space_ratio": 0.7,
|
// CONFIGURATION (Advanced)
|
||||||
* "minimum_surface_temperature": -273,
|
// ========================================
|
||||||
* "minimum_core_temperature": 1000,
|
|
||||||
* "optimal_cooling_core_temperature": 2000,
|
|
||||||
* "reference_surface_temperature": 1000
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
void configure(const IDataNode& config_node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set surface cooling rate per geological cycle
|
* @brief Set surface cooling rate per geological cycle
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
#include "warfactory/IDataNode.h"
|
#include "warfactory/IDataNode.h"
|
||||||
|
|
||||||
class WorldData;
|
// Forward declarations
|
||||||
|
namespace warfactory {
|
||||||
|
class WorldData;
|
||||||
|
class PlanetaryCore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace warfactory {
|
namespace warfactory {
|
||||||
|
|
||||||
@ -13,34 +16,81 @@ namespace warfactory {
|
|||||||
*
|
*
|
||||||
* Each function represents a specific operation like crater generation,
|
* Each function represents a specific operation like crater generation,
|
||||||
* volcanic activity, or meteorite impacts within a broader phase.
|
* volcanic activity, or meteorite impacts within a broader phase.
|
||||||
|
*
|
||||||
|
* PATTERN: Configure-Execute
|
||||||
|
* 1. configure(config) - Load parameters from JSON (called once)
|
||||||
|
* 2. execute(world, core) - Apply generation to world data (can be called multiple times)
|
||||||
|
* 3. reset() - Clear state for re-execution
|
||||||
*/
|
*/
|
||||||
class IWorldGenerationFunction {
|
class IWorldGenerationFunction {
|
||||||
public:
|
public:
|
||||||
virtual ~IWorldGenerationFunction() = default;
|
virtual ~IWorldGenerationFunction() = default;
|
||||||
|
|
||||||
virtual std::string getFunctionName() const = 0;
|
/**
|
||||||
|
* @brief Configure the function with JSON parameters
|
||||||
|
* @param config Configuration node from Regular_world.json
|
||||||
|
*
|
||||||
|
* Called ONCE before execution to load all parameters.
|
||||||
|
*/
|
||||||
|
virtual void configure(const IDataNode& config) = 0;
|
||||||
|
|
||||||
virtual bool execute(WorldData& world, const IDataNode& config) = 0;
|
/**
|
||||||
|
* @brief Execute the generation function
|
||||||
|
* @param world World terrain data to modify
|
||||||
|
* @param core Planetary core data to modify
|
||||||
|
*
|
||||||
|
* Can be called multiple times after configuration.
|
||||||
|
* Modifies world terrain and/or planetary core based on function purpose.
|
||||||
|
*/
|
||||||
|
virtual void execute(WorldData& world, PlanetaryCore& core) = 0;
|
||||||
|
|
||||||
virtual bool canExecute(const WorldData& world) const = 0;
|
/**
|
||||||
|
* @brief Get the name of this generation step
|
||||||
|
* @return Step name matching Regular_world.json "name" field
|
||||||
|
*/
|
||||||
|
virtual std::string getStepName() const = 0;
|
||||||
|
|
||||||
virtual float getProgress() const = 0;
|
/**
|
||||||
|
* @brief Check if function has been properly configured
|
||||||
virtual bool isComplete() const = 0;
|
* @return True if configure() was called successfully
|
||||||
|
*/
|
||||||
|
virtual bool isConfigured() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset function state for re-execution
|
||||||
|
*
|
||||||
|
* Clears any internal state but keeps configuration.
|
||||||
|
* After reset(), configure() must be called again.
|
||||||
|
*/
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
|
|
||||||
virtual std::string getFunctionDescription() const = 0;
|
// ========================================
|
||||||
|
// OPTIONAL: Progress Tracking (for UI/debug)
|
||||||
|
// ========================================
|
||||||
|
|
||||||
virtual float getEstimatedDuration() const = 0;
|
/**
|
||||||
|
* @brief Get execution progress (optional - default implementation)
|
||||||
|
* @return Progress from 0.0 (not started) to 1.0 (complete)
|
||||||
|
*/
|
||||||
|
virtual float getProgress() const { return 0.0f; }
|
||||||
|
|
||||||
virtual std::vector<std::string> getRequiredPreviousFunctions() const = 0;
|
/**
|
||||||
|
* @brief Check if execution is complete (optional - default implementation)
|
||||||
|
* @return True if function finished execution
|
||||||
|
*/
|
||||||
|
virtual bool isComplete() const { return false; }
|
||||||
|
|
||||||
virtual std::vector<std::string> getProducedData() const = 0;
|
/**
|
||||||
|
* @brief Get human-readable description (optional - default implementation)
|
||||||
|
* @return Description of what this function does
|
||||||
|
*/
|
||||||
|
virtual std::string getFunctionDescription() const { return getStepName(); }
|
||||||
|
|
||||||
virtual int getFunctionOrder() const = 0;
|
/**
|
||||||
|
* @brief Get parent phase name (optional - default implementation)
|
||||||
virtual std::string getParentPhase() const = 0;
|
* @return Phase name from Regular_world.json
|
||||||
|
*/
|
||||||
|
virtual std::string getParentPhase() const { return "unknown"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace warfactory
|
} // namespace warfactory
|
||||||
@ -32,7 +32,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
ImpactEffectsApplicationFunction();
|
ImpactEffectsApplicationFunction();
|
||||||
|
|
||||||
// Inherited from IWorldGenerationFunction
|
// ========================================
|
||||||
|
// IWorldGenerationFunction Implementation
|
||||||
|
// ========================================
|
||||||
|
|
||||||
void configure(const IDataNode& config) override;
|
void configure(const IDataNode& config) override;
|
||||||
void execute(WorldData& world, PlanetaryCore& core) override;
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
std::string getStepName() const override;
|
std::string getStepName() const override;
|
||||||
|
|||||||
@ -23,7 +23,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
InitializePlanetaryCoreFunction();
|
InitializePlanetaryCoreFunction();
|
||||||
|
|
||||||
// Inherited from IWorldGenerationFunction
|
// ========================================
|
||||||
|
// IWorldGenerationFunction Implementation
|
||||||
|
// ========================================
|
||||||
|
|
||||||
void configure(const IDataNode& config) override;
|
void configure(const IDataNode& config) override;
|
||||||
void execute(WorldData& world, PlanetaryCore& core) override;
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
std::string getStepName() const override;
|
std::string getStepName() const override;
|
||||||
|
|||||||
@ -22,7 +22,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
InitializeWorldTerrainFunction();
|
InitializeWorldTerrainFunction();
|
||||||
|
|
||||||
// Inherited from IWorldGenerationFunction
|
// ========================================
|
||||||
|
// IWorldGenerationFunction Implementation
|
||||||
|
// ========================================
|
||||||
|
|
||||||
void configure(const IDataNode& config) override;
|
void configure(const IDataNode& config) override;
|
||||||
void execute(WorldData& world, PlanetaryCore& core) override;
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
std::string getStepName() const override;
|
std::string getStepName() const override;
|
||||||
|
|||||||
@ -35,7 +35,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
MeteoriteImpactGenerationFunction();
|
MeteoriteImpactGenerationFunction();
|
||||||
|
|
||||||
// Inherited from IWorldGenerationFunction
|
// ========================================
|
||||||
|
// IWorldGenerationFunction Implementation
|
||||||
|
// ========================================
|
||||||
|
|
||||||
void configure(const IDataNode& config) override;
|
void configure(const IDataNode& config) override;
|
||||||
void execute(WorldData& world, PlanetaryCore& core) override;
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
std::string getStepName() const override;
|
std::string getStepName() const override;
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "IWorldGenerationFunction.h"
|
||||||
#include "PlanetaryCore.h"
|
#include "PlanetaryCore.h"
|
||||||
|
#include "WorldData.h"
|
||||||
#include "warfactory/IDataNode.h"
|
#include "warfactory/IDataNode.h"
|
||||||
#include "warfactory/ResourceRegistry.h"
|
#include "warfactory/ResourceRegistry.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -23,7 +25,7 @@ namespace warfactory {
|
|||||||
* Process operates over 100M year cycles during early planetary formation when
|
* Process operates over 100M year cycles during early planetary formation when
|
||||||
* core is still molten and gravitational sorting is active.
|
* core is still molten and gravitational sorting is active.
|
||||||
*/
|
*/
|
||||||
class PlanetaryDifferentiationFunction {
|
class PlanetaryDifferentiationFunction : public IWorldGenerationFunction {
|
||||||
private:
|
private:
|
||||||
float heavy_metal_threshold_density; // g/cm³ - threshold for heavy metal classification
|
float heavy_metal_threshold_density; // g/cm³ - threshold for heavy metal classification
|
||||||
float sinking_rate_per_cycle; // Fraction of heavy metals that sink per cycle
|
float sinking_rate_per_cycle; // Fraction of heavy metals that sink per cycle
|
||||||
@ -42,20 +44,18 @@ public:
|
|||||||
PlanetaryDifferentiationFunction();
|
PlanetaryDifferentiationFunction();
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
// CONFIGURATION
|
// IWorldGenerationFunction Implementation
|
||||||
// ========================================
|
// ========================================
|
||||||
|
|
||||||
/**
|
void configure(const IDataNode& config) override;
|
||||||
* @brief Configure differentiation process from JSON parameters
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
* @param config_node JSON configuration containing heavy_metal_sinking parameters
|
std::string getStepName() const override;
|
||||||
* Expected structure:
|
bool isConfigured() const override;
|
||||||
* {
|
void reset() override;
|
||||||
* "heavy_metal_threshold_density": 5.0,
|
|
||||||
* "sinking_rate_per_cycle": 0.7,
|
// ========================================
|
||||||
* "differentiation_efficiency": 1.0
|
// CONFIGURATION (Advanced)
|
||||||
* }
|
// ========================================
|
||||||
*/
|
|
||||||
void configure(const IDataNode& config_node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set density threshold for heavy metal classification
|
* @brief Set density threshold for heavy metal classification
|
||||||
|
|||||||
@ -0,0 +1,118 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IWorldGenerationFunction.h"
|
||||||
|
#include "UniversalRegionFusionFunction.h"
|
||||||
|
#include "../WorldData.h"
|
||||||
|
#include "../PlanetaryCore.h"
|
||||||
|
#include "../TectonicRegion.h"
|
||||||
|
#include "../ClimateRegion.h"
|
||||||
|
|
||||||
|
namespace warfactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adapter wrapper for UniversalRegionFusionFunction template
|
||||||
|
*
|
||||||
|
* Since UniversalRegionFusionFunction is a template that operates on different
|
||||||
|
* region types, this adapter provides the standard IWorldGenerationFunction
|
||||||
|
* interface for integration into the world generation pipeline.
|
||||||
|
*
|
||||||
|
* The adapter manages separate fusion instances for each region type:
|
||||||
|
* - TectonicRegion (plate boundaries, continental drift)
|
||||||
|
* - ClimateRegion (weather patterns, climate zones)
|
||||||
|
* - Future region types can be added as needed
|
||||||
|
*/
|
||||||
|
class UniversalRegionFusionFunctionAdapter : public IWorldGenerationFunction {
|
||||||
|
private:
|
||||||
|
// Template instances for different region types
|
||||||
|
UniversalRegionFusionFunction<TectonicRegion> tectonic_fusion;
|
||||||
|
UniversalRegionFusionFunction<ClimateRegion> climate_fusion;
|
||||||
|
|
||||||
|
// Cycle duration for fusion calculations
|
||||||
|
double current_cycle_duration_years;
|
||||||
|
|
||||||
|
// Configuration state
|
||||||
|
bool configured;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct adapter with step name
|
||||||
|
*/
|
||||||
|
UniversalRegionFusionFunctionAdapter();
|
||||||
|
|
||||||
|
// ========================================
|
||||||
|
// IWorldGenerationFunction Implementation
|
||||||
|
// ========================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure all fusion instances with same parameters
|
||||||
|
* @param config Configuration node from Regular_world.json
|
||||||
|
*
|
||||||
|
* Expected structure:
|
||||||
|
* {
|
||||||
|
* "enabled": true,
|
||||||
|
* "radius_calculation": "natural_logarithm",
|
||||||
|
* "base_radius": 1.5,
|
||||||
|
* "mass_reference": 5.0,
|
||||||
|
* "fusion_threshold_percentage": 0.3,
|
||||||
|
* "use_largest_radius_for_threshold": true,
|
||||||
|
* "weighted_position_update": true,
|
||||||
|
* "mass_combination": "additive",
|
||||||
|
* "applies_to_all_region_types": true
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
void configure(const IDataNode& config) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Execute fusion for all region types in the world
|
||||||
|
* @param world World data containing all region collections
|
||||||
|
* @param core Planetary core (not used by fusion, but required by interface)
|
||||||
|
*
|
||||||
|
* Applies fusion to:
|
||||||
|
* - Tectonic regions (continental plates, oceanic plates, volcanic zones)
|
||||||
|
* - Climate regions (weather cells, wind patterns, climate zones)
|
||||||
|
*/
|
||||||
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the name of this generation step
|
||||||
|
* @return "universal_region_fusion"
|
||||||
|
*/
|
||||||
|
std::string getStepName() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if function has been properly configured
|
||||||
|
* @return True if configure() was called successfully
|
||||||
|
*/
|
||||||
|
bool isConfigured() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset all fusion instances
|
||||||
|
*
|
||||||
|
* Clears state and sets configured = false
|
||||||
|
*/
|
||||||
|
void reset() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Apply fusion to tectonic regions
|
||||||
|
* @param world World data to process
|
||||||
|
* @return Number of fusion operations performed
|
||||||
|
*/
|
||||||
|
int applyTectonicFusion(WorldData& world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Apply fusion to climate regions
|
||||||
|
* @param world World data to process
|
||||||
|
* @return Number of fusion operations performed
|
||||||
|
*/
|
||||||
|
int applyClimateFusion(WorldData& world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extract cycle duration from configuration if present
|
||||||
|
* @param config Configuration node
|
||||||
|
* @return Cycle duration in years (default: 100 million)
|
||||||
|
*/
|
||||||
|
double extractCycleDuration(const IDataNode& config);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace warfactory
|
||||||
@ -25,7 +25,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
VolcanicRedistributionFunction();
|
VolcanicRedistributionFunction();
|
||||||
|
|
||||||
// Inherited from IWorldGenerationFunction
|
// ========================================
|
||||||
|
// IWorldGenerationFunction Implementation
|
||||||
|
// ========================================
|
||||||
|
|
||||||
void configure(const IDataNode& config) override;
|
void configure(const IDataNode& config) override;
|
||||||
void execute(WorldData& world, PlanetaryCore& core) override;
|
void execute(WorldData& world, PlanetaryCore& core) override;
|
||||||
std::string getStepName() const override;
|
std::string getStepName() const override;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user