-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoriManager.h
201 lines (160 loc) · 5.53 KB
/
MoriManager.h
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Data/ProgressGridData.h"
#include "GameFramework/Actor.h"
#include "MoriManager.generated.h"
class ADisharmonyGameMode;
class ALandscape;
class UTexture2D;
class UHierarchicalInstancedStaticMeshComponent;
UCLASS()
class UNSATISFACTORY_API AMoriManager : public AActor
{
GENERATED_BODY()
UPROPERTY()
ADisharmonyGameMode* GameMode;
public:
// Sets default values for this actor's properties
AMoriManager();
float GetMyceliumWeight(int32 x, int32 y);
UFUNCTION(BlueprintCallable)
bool KillTree(int32 index, int32 &type, float &age);
FVector GetWorldLocByIndex(int32 index);
FVector GetWorldLocByCoords(int32 x, int32 y);
///Takes cell coordinates, desired direction, and tree patch resolution, returns a set of trees found by winding through this area
TArray<int32> CreateTreePatchRes(int32 X, int32 Y, ETreePatchDirection direction, int32 height, int32 width, int32 offset);
TArray<int32> CreatePioneerTreeLanes(TArray<int32> indicesX, TArray<int32> indicesY, int32 dX, int32 dY, int32 length);
protected:
void LoadData();
void GenerateTrees();
void InstantiateTrees();
void GenerateMycelium();
void GenerateWaterLevels();
void TickMycelium(float DeltaTime);
//Data
UPROPERTY(EditAnywhere, Category = "Data References")
UProgressGridData* ProgressGridData;
public:
//Initialized via game mode
void InitializeSystem();
// Called every frame
virtual void Tick(float DeltaTime) override;
void RegisterGameMode(ADisharmonyGameMode* gm)
{
GameMode = gm;
}
void WorldToMapCoords(int32 &x, int32 &y, int32 &curIndex);
UPROPERTY(EditAnywhere, Category = "Temp")
AActor* WaterPlaceholder = nullptr;
UPROPERTY(EditAnywhere, Category = "Temp")
bool bAdjustWater = true;
UPROPERTY(EditAnywhere)
bool bGenerate = true;
UPROPERTY(EditAnywhere, Category = "Trees")
float MaxTreeSize = 0.95;
UPROPERTY(EditAnywhere, Category = "Trees")
float LargeTreesDefinition = 0.65;
UPROPERTY(EditAnywhere, Category = "Trees")
float DeadChanceLarge = 0.3;
UPROPERTY(EditAnywhere, Category = "Trees")
float DeadStandingChanceLarge = 0.9;
UPROPERTY(EditAnywhere, Category = "Trees")
float DeadChanceSmall = 0.42;
UPROPERTY(EditAnywhere, Category = "Trees")
float DeadStandingChanceSmall = 0.4;
UPROPERTY(EditAnywhere, Category = "Trees")
float JitterScale_m = 4;
UPROPERTY(EditAnywhere, Category = "Grid")
int32 ReadRes = 4033;
UPROPERTY(EditAnywhere, Category = "Grid")
int32 Resolution = 4033;
UPROPERTY(EditAnywhere, Category = "Grid")
int32 HISM_Num_Side = 2;
UPROPERTY()
int32 HISM_Width = 1;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Map Loading")
FString DirectoryPath = "MapRaws/";
UPROPERTY(EditAnywhere, Category = "Trees")
float SSpruceDensityModifier = 1;
UPROPERTY(EditAnywhere, Category = "Trees")
float SSpruceCullRadius = 10;
UPROPERTY(EditAnywhere, Category = "Trees")
float DFirDensityModifier = 1;
UPROPERTY(EditAnywhere, Category = "Trees")
float DFirCullRadius = 8;
UPROPERTY(EditAnywhere, Category = "Trees")
float WHemlockDensityModifier = 1;
UPROPERTY(EditAnywhere, Category = "Trees")
float WHemlockCullRadius = 6;
UPROPERTY(EditAnywhere, Category = "Map Loading")
float VertexOffset = -201600.0;
UPROPERTY(EditAnywhere, Category = "Map Loading")
float HeightScale = 100;
UPROPERTY(EditAnywhere, Category = "Map Loading")
float WidthScale = 200;
UPROPERTY(EditAnywhere, Category = "Map Loading")
float HeightOffsetMultiplier = 0;
UPROPERTY(EditAnywhere, Category = "References")
AActor* LandscapeActor;
UPROPERTY(EditAnywhere, Category = "Map Loading")
UTexture2D* Data_Heightmap;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> HISM_SSpruce;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> HISM_DFir;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> HISM_WHemlock;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> HISM_SSpruce_Dead_S;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> HISM_DFir_Dead_S;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> HISM_WHemlock_Dead_S;
UPROPERTY(EditAnywhere, Category = "Mycelium")
float MyceliumDepletionTime = 360;
UPROPERTY(EditAnywhere, Category = "Mycelium")
float MyceliumGrowthTime = 720;
UPROPERTY(EditAnywhere, Category = "Mycelium")
float MyceliumDepletionMin = .1;
UPROPERTY(EditAnywhere, Category = "Mycelium")
bool DebugMycelium = false;
UPROPERTY(EditAnywhere, Category = "Mycelium")
UHierarchicalInstancedStaticMeshComponent* HISM_MyceliumDebugger = nullptr;
UPROPERTY(EditAnywhere, Category = "Mycelium")
UMaterialInstance* MyceliumDebuggerMaterial;
protected:
UPROPERTY()
bool bMarkFrameDirty = false;
UPROPERTY()
TArray<UHierarchicalInstancedStaticMeshComponent*> dirtyHISMs;
//Persists
UPROPERTY()
TArray<float> VertexHeightMap;
UPROPERTY()
TArray<float>WaterLevelsMap;
UPROPERTY()
TArray<int8> TM_Type;
UPROPERTY()
TArray<int32> TM_InstanceIx;
UPROPERTY()
TArray<float> TM_Viability;
UPROPERTY()
TArray<float> TM_Age;
//Acts as a tree map in the end, 1 is culled, 0/2/3 are trees. More accurate to use Type though?
UPROPERTY()
TArray<int8> TM_GrowthStageCullMap;
UPROPERTY(BlueprintReadOnly)
TArray<float> TM_MyceliumWeight;
UPROPERTY()
TMap<int32, float> M_DepletionIndices;
UPROPERTY()
TArray<int32> Keys;
//Used for tree generation and deleted
UPROPERTY()
TArray<float> SSpruceViabilityMap;
UPROPERTY()
TArray<float> DFirViabilityMap;
UPROPERTY()
TArray<float> WHemlockViabilityMap;
};