Space Plunder
Loading...
Searching...
No Matches
RoomActor.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GameFramework/Actor.h"
8#include "RoomActor.generated.h"
9
10class UBoxComponent;
11
12UCLASS()
13class PROCEDURALDUNGEONS_API ARoomActor : public AActor, public IDungeonRoom
14{
15 GENERATED_BODY()
16
17public:
18 ARoomActor();
19
20
21protected:
22 virtual void BeginPlay() override;
23
24 UFUNCTION(BlueprintNativeEvent, Category="Room")
25 bool GetShouldRoomSpawnDoor(const FRandomStream& Stream) const;
26
27 // UFUNCTION(BlueprintCallable, Category="Room|Random")
28 // void ShowBounds() const {return RandomStream;};
29
30 //@ TODO Spawn all Rooms, Then Trace out to see if a Window can be put on each side
31 UFUNCTION(BlueprintCallable, Category="Room")
32 bool GetCanHaveWindow() const;
33
34 UFUNCTION(CallInEditor, Category="Room|Editor")
35 void HideRoof();
36 UFUNCTION(BlueprintCallable, Category="Room|Random")
37 FRandomStream GetRandomStream() const {return RandomStream;};
38 UFUNCTION(BlueprintCallable, Category="Room|Random")
39 bool GetIsRandomStreamSet() const {return bRandomStreamSet;};
40
41 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|General")
43
45 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|Doors")
46 bool bShouldDoorSpawn = true;
48 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|Doors", meta=(EditCondition="bShouldDoorSpawn"))
49 bool bRandomDoorSpawn = false;
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|Doors", meta=(EditCondition="bRandomDoorSpawn", ClampMin=0.0f, ClampMax=1.0f))
52 float RandomWeight = 0.5f;
53
54 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|Windows")
55 bool bCheckForWindow = false;
57 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|Windows")
58 float WindowTraceDistance = 2000.0f;
59
60 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Room|Debug")
61 // bool bGetRandomStreamAtBegin = true;
62
63
64 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
65 USceneComponent* DefaultRootComponent;
66 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
67 USceneComponent* ExitsRootComponent;
68 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
69 USceneComponent* OverlapsRootComponent;
70 //~ Spawners //
71 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
72 USceneComponent* AISpawnsRootComponent;
73 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
74 USceneComponent* WeaponSpawnsRootComponent;
75 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
76 USceneComponent* LootSpawnsRootComponent;
77 //~ Spawners //
78
79 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
80 USceneComponent* DoorsRootComponent;
81
82 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
83 USceneComponent* LightsRootComponent;
84 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
85 USceneComponent* GeometryRootComponent;
86 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
87 USceneComponent* WallsRootComponent;
88 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
89 USceneComponent* RoofRootComponent;
90 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
91 USceneComponent* FloorRootComponent;
92 // Static Decorations
93 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
94 USceneComponent* DecorationsRootComponent;
95 // Used for any Physics objects (Currently Only Static Meshes)
96 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
97 USceneComponent* PropsRootComponent;
98
99 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
100 UBoxComponent* BoundsComponent;
101
102 //Furniture: Chairs, tables, shelves, beds, etc., which add to the room's atmosphere.
103 //Props: Miscellaneous items like barrels, crates, tools, books, or artifacts that make the room feel lived-in or used.
104
105 //Paintings/Posters/Signs: Wall decorations that add narrative or thematic elements to the room.
106 //Lighting: Placement for lights, torches, lamps, chandeliers, or other sources of light.
107 //Event Triggers: Specific spots that trigger events, such as spawning enemies, activating traps, or starting a timer.
108 //Enemy Patrol Routes: Waypoints or paths that enemies can follow, making AI behavior more dynamic.
109 //Turrets/Defensive Structures: Fixed defensive emplacements that can add strategic depth to combat encounters.
110 //Health Stations/Refill Points: Areas where players can restore health, mana, or other resources.
111
112 //Ambient Sounds: Placement for sound emitters that create ambient noises like wind, dripping water, or distant machinery.
113 //Save Points/Checkpoints: Areas where the player can save their progress or respawn after death.
114
115 //Boss Arena Features: Special setups for boss encounters, such as central platforms, escape routes, or hazard zones.
116 //Cover Points: Specific locations where AI or players can take cover during combat.
117 //Lore Objects: Books, scrolls, or other items that players can interact with to learn more about the world’s lore.
118 //NPCs: Placement for non-combat characters who could provide quests, information, or trading opportunities.
119 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Component")
120 // USceneComponent* HazzardsRootComponent;
121 // Puzzle Elements
122 //Spawn Zones: Areas for spawning environmental hazards like fire, poison gas, or lightning.
123 // Traps
124 // Secrets
125 // Dynamic Elements: Moving platforms, elevators, or rotating walls that could add to the room's complexity.
126
127 //@ TODO These should get TArray<> of StaticMeshComponents? save casting each time,
128 //only do it once on begin play if works in time with builder?
129 virtual USceneComponent* GetExitsRootComponent() const override {return ExitsRootComponent;};
130 virtual USceneComponent* GetOverlapsRootComponent() const override {return OverlapsRootComponent;};
131 virtual USceneComponent* GetAISpawnsRootComponent() const override {return AISpawnsRootComponent;};
132 virtual USceneComponent* GetWeaponSpawnsRootComponent() const override {return WeaponSpawnsRootComponent;};
133 virtual USceneComponent* GetLootSpawnsRootComponent() const override {return LootSpawnsRootComponent;};
134 virtual USceneComponent* GetDoorsRootComponent() const override {return DoorsRootComponent;};
135 virtual int32 GetNumOfExits() const override;
136
137 virtual FBox GetRoomBounds() const override;
138 virtual EDungeonRoomType GetRoomType() const override {return RoomType;};
139
140 virtual bool GetShouldRoomSpawnDoorAtEntry(const FRandomStream& Stream) const override {return GetShouldRoomSpawnDoor(RandomStream);};
141 virtual void AddAttachedRoom(AActor* Actor) override;
142 virtual void ToggleAllRoomRoofs(const bool bForceHide) override;
143
144 //@Test which is more Efficient //
145 virtual void SetRandomStream(const FRandomStream& Stream) override;
146
147 virtual void SetDynamicMaterial(UMaterialInterface* Material) override;
148
149 // @TODO optimization Interface in BaseHelpers, Use for All Objects, etc.
150
151 //- Optimization Functions //
152 virtual void SetActive(const bool bActive) override;
153
154 // @TODO Optimization Levels
155 // Level 0 - No Optimizations
156 // Level 1 - Physics objects off - Decorations off
157 // Level 2 - Lights off
158 // Level 3 - All Meshes not Visible
159 virtual void SetOptimizationLevel(const int32 Level) override;
160 UFUNCTION(BlueprintImplementableEvent, Category="Optimization")
161 void OnOptimizationLevelChanged(const int32 Level, const int32 PreviousLevel);
162 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
163 int32 GetOptimizationLevel() const {return OptimizationLevel;}
164
165 virtual void SetReady() override;
166 UFUNCTION(BlueprintImplementableEvent, Category="Room")
167 void OnRoomReady();
168 UFUNCTION(BlueprintCallable, Category="Room")
169 bool GetIsRoomReady() const {return bReady;};
170
171
172 virtual void Activate();
173 virtual void Deactivate();
174
175 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
176 void ToggleLights(const bool bTurnOn) const;
177 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
178 void TogglePhysicsObjects(const bool bSimulatePhysics, const bool bVisible) const;
179 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
180 void TogglePhysicsObjectsSimulation(const bool bSimulatePhysics) const;
181 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
182 void TogglePhysicsObjectsVisibility(const bool bVisible) const;
183 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
184 void ToggleGeometry(const bool bVisible) const;
185 UFUNCTION(BlueprintCallable, Category="Room|Optimization")
186 void ToggleDecorations(const bool bVisible) const;
187 // virtual void AddAttachedRoomFromExit(USceneComponent* Exit) override;
188
189
190 UFUNCTION(BlueprintCallable, Category="Room")
191 bool GetCanBeWindow(UStaticMeshComponent* WallMesh) const;
192
193
194 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Room|Debug")
195 bool bDebuggingMode = false;
196
197
198 //@ TODO Move to Private
199 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Connections")
200 TArray<ARoomActor*> AttachedRooms;
201 // @TODO Optimize Door Actors, Are there Multiple rooms that have the same door?
202 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Room|Doors")
203 TArray<AActor*> DoorActors;
204
205private:
206
207 void GetLightComponents();
208 void GetPropComponents();
209
210 UPROPERTY(VisibleAnywhere, Category="Room|General")
211 bool bReady = false;
212
213 UPROPERTY(VisibleAnywhere, Category="Room|Random")
214 bool bRandomStreamSet = false;
215 UPROPERTY(VisibleAnywhere, Category="Room|Random")
216 FRandomStream RandomStream;
217 UPROPERTY(VisibleAnywhere, Category="Room|Random")
218 int32 Seed = 0;
219
220 UPROPERTY(VisibleAnywhere, Category="Room|Debug")
221 bool bShouldHideRoof = false;
222 UPROPERTY(VisibleAnywhere, Category="Room|Optimization")
223 int32 OptimizationLevel = 0;
224 UPROPERTY(VisibleAnywhere, Category="Room|Optimization")
225 int32 PreviousOptimizationLevel = 0;
226
227
228 UPROPERTY(VisibleAnywhere, Category="Room|Lights")
229 TArray<ULightComponent*> Lights;
230 UPROPERTY(VisibleAnywhere, Category="Room|Props")
231 TArray<UStaticMeshComponent*> Props;
232
233};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
EDungeonRoomType
Definition DungeonEnums.h:11
Definition RoomActor.h:14
virtual USceneComponent * GetAISpawnsRootComponent() const override
Definition RoomActor.h:131
virtual EDungeonRoomType GetRoomType() const override
Definition RoomActor.h:138
virtual USceneComponent * GetWeaponSpawnsRootComponent() const override
Definition RoomActor.h:132
virtual USceneComponent * GetOverlapsRootComponent() const override
Definition RoomActor.h:130
virtual USceneComponent * GetDoorsRootComponent() const override
Definition RoomActor.h:134
virtual USceneComponent * GetLootSpawnsRootComponent() const override
Definition RoomActor.h:133
virtual bool GetShouldRoomSpawnDoorAtEntry(const FRandomStream &Stream) const override
Definition RoomActor.h:140
Definition DungeonRoom.h:21