osb/source/game/StarWorldParameters.hpp

190 lines
5.1 KiB
C++
Raw Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarGameTypes.hpp"
#include "StarSkyTypes.hpp"
#include "StarWeatherTypes.hpp"
#include "StarForceRegions.hpp"
namespace Star {
enum class WorldParametersType : uint8_t {
TerrestrialWorldParameters,
AsteroidsWorldParameters,
FloatingDungeonWorldParameters
};
extern EnumMap<WorldParametersType> const WorldParametersTypeNames;
enum class BeamUpRule : uint8_t {
Nowhere,
Surface,
Anywhere,
AnywhereWithWarning
};
extern EnumMap<BeamUpRule> const BeamUpRuleNames;
enum class WorldEdgeForceRegionType : uint8_t {
None,
Top,
Bottom,
TopAndBottom
};
extern EnumMap<WorldEdgeForceRegionType> const WorldEdgeForceRegionTypeNames;
STAR_STRUCT(VisitableWorldParameters);
STAR_STRUCT(TerrestrialWorldParameters);
STAR_STRUCT(AsteroidsWorldParameters);
STAR_STRUCT(FloatingDungeonWorldParameters);
struct VisitableWorldParameters {
VisitableWorldParameters() = default;
VisitableWorldParameters(VisitableWorldParameters const& visitableWorldParameters) = default;
explicit VisitableWorldParameters(Json const& store);
2023-06-20 04:33:09 +00:00
virtual ~VisitableWorldParameters() = default;
2023-06-20 04:33:09 +00:00
virtual WorldParametersType type() const = 0;
virtual Json store() const;
virtual void read(DataStream& ds);
virtual void write(DataStream& ds) const;
String typeName;
float threatLevel{};
2023-06-20 04:33:09 +00:00
Vec2U worldSize;
float gravity{};
bool airless{false};
2023-06-20 04:33:09 +00:00
WeatherPool weatherPool;
StringList environmentStatusEffects;
Maybe<StringList> overrideTech;
Maybe<List<Directives>> globalDirectives;
2023-06-20 04:33:09 +00:00
BeamUpRule beamUpRule;
bool disableDeathDrops{false};
bool terraformed{false};
WorldEdgeForceRegionType worldEdgeForceRegions{WorldEdgeForceRegionType::None};
2023-06-20 04:33:09 +00:00
};
struct TerrestrialWorldParameters : VisitableWorldParameters {
struct TerrestrialRegion {
String biome;
String blockSelector;
String fgCaveSelector;
String bgCaveSelector;
String fgOreSelector;
String bgOreSelector;
String subBlockSelector;
LiquidId caveLiquid{};
float caveLiquidSeedDensity{};
2023-06-20 04:33:09 +00:00
LiquidId oceanLiquid{};
int oceanLiquidLevel{};
2023-06-20 04:33:09 +00:00
bool encloseLiquids{false};
bool fillMicrodungeons{false};
2023-06-20 04:33:09 +00:00
};
struct TerrestrialLayer {
int layerMinHeight;
int layerBaseHeight;
StringList dungeons;
int dungeonXVariance;
TerrestrialRegion primaryRegion;
TerrestrialRegion primarySubRegion;
List<TerrestrialRegion> secondaryRegions;
List<TerrestrialRegion> secondarySubRegions;
Vec2F secondaryRegionSizeRange;
Vec2F subRegionSizeRange;
};
TerrestrialWorldParameters() = default;
TerrestrialWorldParameters(TerrestrialWorldParameters const& terrestrialWorldParameters) = default;
explicit TerrestrialWorldParameters(Json const& store);
2023-06-20 04:33:09 +00:00
TerrestrialWorldParameters &operator=(TerrestrialWorldParameters const& terrestrialWorldParameters);
WorldParametersType type() const override;
2023-06-20 04:33:09 +00:00
Json store() const override;
2023-06-20 04:33:09 +00:00
void read(DataStream& ds) override;
void write(DataStream& ds) const override;
2023-06-20 04:33:09 +00:00
String primaryBiome;
LiquidId primarySurfaceLiquid{};
2023-06-20 04:33:09 +00:00
String sizeName;
float hueShift{};
2023-06-20 04:33:09 +00:00
SkyColoring skyColoring;
float dayLength{};
2023-06-20 04:33:09 +00:00
Json blockNoiseConfig;
Json blendNoiseConfig;
float blendSize{};
2023-06-20 04:33:09 +00:00
TerrestrialLayer spaceLayer{};
TerrestrialLayer atmosphereLayer{};
TerrestrialLayer surfaceLayer{};
TerrestrialLayer subsurfaceLayer{};
2023-06-20 04:33:09 +00:00
List<TerrestrialLayer> undergroundLayers;
TerrestrialLayer coreLayer{};
2023-06-20 04:33:09 +00:00
};
struct AsteroidsWorldParameters : VisitableWorldParameters {
AsteroidsWorldParameters();
explicit AsteroidsWorldParameters(Json const& store);
2023-06-20 04:33:09 +00:00
WorldParametersType type() const override;
2023-06-20 04:33:09 +00:00
Json store() const override;
2023-06-20 04:33:09 +00:00
void read(DataStream& ds) override;
void write(DataStream& ds) const override;
2023-06-20 04:33:09 +00:00
int asteroidTopLevel{};
int asteroidBottomLevel{};
float blendSize{};
2023-06-20 04:33:09 +00:00
String asteroidBiome;
Color ambientLightLevel;
};
struct FloatingDungeonWorldParameters : VisitableWorldParameters {
FloatingDungeonWorldParameters() = default;
explicit FloatingDungeonWorldParameters(Json const& store);
2023-06-20 04:33:09 +00:00
WorldParametersType type() const override;
2023-06-20 04:33:09 +00:00
Json store() const override;
2023-06-20 04:33:09 +00:00
void read(DataStream& ds) override;
void write(DataStream& ds) const override;
2023-06-20 04:33:09 +00:00
int dungeonBaseHeight;
int dungeonSurfaceHeight;
int dungeonUndergroundLevel;
String primaryDungeon;
Color ambientLightLevel;
Maybe<String> biome;
Maybe<String> dayMusicTrack;
Maybe<String> nightMusicTrack;
Maybe<String> dayAmbientNoises;
Maybe<String> nightAmbientNoises;
};
Json diskStoreVisitableWorldParameters(VisitableWorldParametersConstPtr const& parameters);
VisitableWorldParametersPtr diskLoadVisitableWorldParameters(Json const& store);
ByteArray netStoreVisitableWorldParameters(VisitableWorldParametersConstPtr const& parameters);
VisitableWorldParametersPtr netLoadVisitableWorldParameters(ByteArray data);
TerrestrialWorldParametersPtr generateTerrestrialWorldParameters(String const& typeName, String const& sizeName, uint64_t seed);
AsteroidsWorldParametersPtr generateAsteroidsWorldParameters(uint64_t seed);
FloatingDungeonWorldParametersPtr generateFloatingDungeonWorldParameters(String const& dungeonWorldName);
}