42 virtual void BeginPlay()
override;
43 virtual void OnConstruction(
const FTransform& Transform)
override;
45 UFUNCTION(CallInEditor, Category=
"Dungeon|Editor")
46 void CreateDungeonInEditor();
48 UFUNCTION(CallInEditor, Category=
"Dungeon|Editor")
49 void DestroyDungeonInEditor();
51 UFUNCTION(CallInEditor, Category=
"Dungeon|Editor")
52 void HideAllRoomRoofs();
54 UFUNCTION(BlueprintCallable, Category=
"Dungeon")
57 UFUNCTION(BlueprintImplementableEvent, Category=
"Dungeon")
58 void OnDungeonComplete(const int32 NumOfRooms);
59 UFUNCTION(BlueprintImplementableEvent, Category="Dungeon")
60 void OnDoorsSpawned(const int32 NumOfDoors);
62 UFUNCTION(BlueprintImplementableEvent, Category="Dungeon")
63 void OnAISpawned(const int32 NumOfPawns);
64 UFUNCTION(NetMulticast, Reliable)
65 void Multicast_DungeonComplete(int32 NumRooms);
69 UFUNCTION(BlueprintCallable, Category="Dungeon")
70 FRandomStream& GetRandomStream() const;
72 UFUNCTION(BlueprintCallable, Category="Dungeon|Helper")
73 bool IsOverlapping(const FBox& CandidateBox);
77 UFUNCTION(BlueprintNativeEvent, Category="Dungeon|Helper")
81 UFUNCTION(BlueprintCallable, Category="Dungeon|
Debug")
82 UMaterialInstanceDynamic* GetMaterialInstance()
const {
return RoomMaterialInstance;};
87 void SpawnStartingRoom();
92 void CreateDynamicMaterials();
100 void ContinueSpawnNextRoom();
102 void SetInitialValues();
105 void SpawnSpecialRoom();
108 void ScheduleSpawn(
const FTimerDelegate::TMethodPtr<AProceduralDungeonBuilder> SpawnMethod);
111 void AddAISpawnPointsToList(
const USceneComponent* AIRootComponent);
113 void CheckExitsForJoiningRooms();
117 void SpawnDoorAtLocation();
119 void SpawnAIAtLocation();
122 void SetRoomsReady()
const;
125 void DungeonComplete();
130 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=
"Dungeon|Rooms")
134 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms")
135 int32 StartingRoomNumber = 0;
137 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms|Amount")
138 int32 NumberOfRoomsToSpawn = 50;
140 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms|Amount")
141 bool bUseRandomNumberOfRooms = false;
142 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms|Amount", meta=(EditCondition="bUseRandomNumberOfRooms"))
143 int32 MinNumberOfRoomsToSpawn = 2;
144 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms")
145 TSubclassOf<AActor> RoomChecker =
nullptr;
146 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms")
147 bool bApplyDynamicMaterial = true;
149 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms", meta=(EditCondition="bApplyDynamicMaterial"))
150 UMaterialInterface* RoomMaterial =
nullptr;
153 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Rooms", meta=(EditCondition="bApplyDynamicMaterial"))
154 class UDataTable* MaterialDataTable =
nullptr;
157 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General|Exits")
158 bool bCheckRoomExitCount = false;
160 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General|Exits")
161 int32 CheckRoomExitCountMin = 3;
162 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General")
163 bool bCheckRoomTypes = true;
166 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General|Exits")
167 bool bGetClosestExit = false;
169 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General|Exits", meta=(EditCondition=bGetClosestExit))
170 bool bRandomGetClosestExit = false;
171 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General|Exits", meta=(EditCondition=bRandomGetClosestExit))
172 float RandomClosesExitWeight = 0.5f;
177 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General")
178 bool bUseRandomSeed = true;
179 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General", meta=(EditCondition="!bUseRandomSeed"))
184 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Walls")
185 TSubclassOf<AActor> WallFill =
nullptr;
186 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Walls")
187 bool bFillWithDeadEndRooms = false;
189 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Doors")
190 bool bSpawnDoors = true;
191 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Doors", meta=(EditCondition="bSpawnDoors"))
192 bool bLimitDoors = true;
193 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Doors", meta=(EditCondition="bLimitDoors"))
194 int32 DoorLimit = 10;
195 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Doors")
196 TArray<TSubclassOf<AActor>> DoorTypes;
198 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|Doors")
199 TArray<int32> DoorWeights;
200 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General")
201 bool bCreateOnBeginPlay = true;
202 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General")
203 bool bUseGameModeStream = true;
206 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|
General")
207 bool bCheckForJoiningRooms = true;
209 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|AI")
210 int32 AIToSpawn = 10;
211 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Dungeon|AI")
212 TArray<TSubclassOf<AActor>> AITypes;
219 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
220 bool bComplete = false;
222 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
223 TArray<USceneComponent*> AvailableExits;
224 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
225 TArray<USceneComponent*> DoorLocations;
227 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
228 TArray<USceneComponent*> ExitsToFill;
229 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
230 USceneComponent* SelectedExit =
nullptr;
232 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
233 AActor* LastSpawnedRoom =
nullptr;
234 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
235 TArray<UPrimitiveComponent*> OverlappedComponents;
236 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
237 TArray<AActor*> DungeonActors;
238 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
239 TArray<TSubclassOf<AActor>> SpecialRoomTypeClasses;
244 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation|Rooms")
245 UMaterialInstanceDynamic* RoomMaterialInstance =
nullptr;
248 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation|Rooms")
249 TArray<FBox> PlacedRoomBounds;
251 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
252 USceneComponent* SelectedAISpawn =
nullptr;
253 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
254 USceneComponent* SelectedDoorSpawn =
nullptr;
255 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
256 TArray<USceneComponent*> AISpawns;
257 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation")
258 bool bUsingGameModeSteam = false;
261 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation|
Debug")
262 TArray<USceneComponent*> AISpawnsSelected;
263 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation|
Debug")
264 TArray<USceneComponent*> AISpawnsFailed;
265 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation|
Debug")
266 TArray<USceneComponent*> DoorSpawnsSelected;
267 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Dungeon|Creation|
Debug")
268 TArray<USceneComponent*> DoorSpawnsFailed;
273 void OnRoomsComplete();
276 void CheckRoomAttemptsNumber();
280 void SetNumberOfRooms();
283 bool GetShouldStopSpawningRooms() const;
287 bool GetShouldSpawnSpecialRoom() const;
289 USceneComponent* GetNextExit();
291 UClass* GetNewRoomClass() const;
292 UClass* GetStartingRoomClass();
293 UClass* GetSpecialRoomClass() const;
294 UClass* GetDeadEndRoomClass() const;
296 UFUNCTION(BlueprintCallable, Category="Dungeon", DisplayName="Get Rooms Of Type")
307 void RemoveExitsByDistance(TArray<USceneComponent*>& ExitsA, TArray<USceneComponent*>& ExitsB) const;
311 bool SetDungeonValues();
320 void LogDebugError(const FString& Message) const;
321 void LogDebugWarning(const FString& Message) const;
322 void LogDebugMessage(const FString& Message, const
bool bWarning = false, const
bool bError = false) const;
327 FActorSpawnParameters SpawnParams;
329 UPROPERTY(VisibleAnywhere, Category="Dungeon|Rooms")
330 int32 RoomsSpawned = 0;
332 int32 AttemptChecker = 0;
335 UPROPERTY(VisibleAnywhere, Category="Dungeon|Rooms")
336 int32 StartingNumberOfRoomsToSpawn = 0;
338 UPROPERTY(VisibleAnywhere, Category="Dungeon|Rooms")
339 int32 TotalNumberOfRoomsToSpawn = 0;
345 UPROPERTY(VisibleAnywhere, Category="Dungeon|AI")
346 int32 StartingAIToSpawn = 0;
348 UPROPERTY(VisibleAnywhere, Category="Dungeon|AI")
350 UPROPERTY(VisibleAnywhere, Category="Dungeon|Doors")
351 int32 DoorsSpawned = 0;
355 UPROPERTY(VisibleAnywhere, Category="Dungeon|Creation")
356 bool bCreatedInEditor = false;
359 FRandomStream RandomStream;
360 FRandomStream* RandomStreamPtr =
nullptr;
362 FRandomStream NullRandomStream;
368 UPROPERTY(EditAnywhere, Category="Dungeon|Optimization")
369 float ExitLocationDistanceOverlap = 0.1f;
380 UPROPERTY(EditAnywhere, Category="Dungeon|Optimization")
381 bool bDeleteExitBeforeSpawn = true;
383 UPROPERTY(EditAnywhere, Category="Dungeon|Optimization", meta=(ClampMin=1, ClampMax=5))
384 int32 RoomAttemptsBeforeFail = 5;
386 UPROPERTY(EditAnywhere, Category="Dungeon|Optimization", meta=(ClampMin=1, ClampMax=10))
387 int32 RoomAttemptsMathMultiplier = 5;
389 bool bHasInvalidClass = false;
392 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
393 bool bHideRoomRoofs = false;
394 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
395 bool bGiveRoomsRandomStream = false;
397 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
398 bool bAddStartingExit = false;
399 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
400 bool bDebuggingMode = true;
402 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
403 bool bDrawFailedExits = false;
406 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug|Log")
407 bool bLogDungeonSummary = true;
409 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug|Log")
410 bool bLogDungeonSteps = false;
412 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
413 bool bResetRoomTypesOnComplete = false;
416 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
417 bool bDelayEachRoomBuild = false;
418 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
419 bool bDelayEachAISpawn = false;
420 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
421 bool bDelayEachDoorSpawn = false;
428 UPROPERTY(EditAnywhere, Category="Dungeon|
Debug")
429 float BuildDelayTime = 0.1f;
430 FTimerHandle BuildDelayHandle;