1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#pragma once
#include "StarJson.hpp"
#include "StarVector.hpp"
#include "StarBiMap.hpp"
#include "StarWeightedPool.hpp"
namespace Star {
STAR_EXCEPTION(SpawnTypeDatabaseException, StarException);
STAR_CLASS(SpawnTypeDatabase);
struct SpawnParameters {
enum class Area : uint8_t {
Surface,
Ceiling,
Air,
Liquid,
Solid
};
enum class Region : uint8_t {
All,
Enclosed,
Exposed
};
enum class Time : uint8_t {
All,
Day,
Night
};
static EnumMap<Area> const AreaNames;
static EnumMap<Region> const RegionNames;
static EnumMap<Time> const TimeNames;
// Null config constructs SpawnParameters filled with All
SpawnParameters(Json const& config = {});
SpawnParameters(Set<Area> areas, Region region, Time time);
bool compatible(SpawnParameters const& parameters) const;
Set<Area> areas;
Region region;
Time time;
};
struct SpawnType {
String typeName;
Vec2F dayLevelAdjustment;
Vec2F nightLevelAdjustment;
Variant<String, WeightedPool<String>> monsterType;
Json monsterParameters;
Vec2I groupSize;
float spawnChance;
SpawnParameters spawnParameters;
uint64_t seedMix;
};
SpawnType spawnTypeFromJson(Json const& config);
struct SpawnProfile {
SpawnProfile();
SpawnProfile(Json const& config);
SpawnProfile(StringSet spawnTypes, Json monsterParameters);
Json toJson() const;
StringSet spawnTypes;
Json monsterParameters;
};
SpawnProfile constructSpawnProfile(Json const& config, uint64_t seed);
class SpawnTypeDatabase {
public:
SpawnTypeDatabase();
SpawnType spawnType(String const& typeName) const;
private:
StringMap<SpawnType> m_spawnTypes;
};
}
|