IVSmoke 1.0
Loading...
Searching...
No Matches
IVSmokeHolePreset.h
1// Copyright (c) 2026, Team SDB. All rights reserved.
2
3#pragma once
4
5#include "Curves/CurveFloat.h"
6#include "Engine/DataAsset.h"
7#include "IVSmokeHolePreset.generated.h"
8
9/**
10 * Type of way the hole is created.
11 */
12UENUM(BlueprintType)
13enum class EIVSmokeHoleType : uint8
14{
15 /** Fast bullet type. */
16 Penetration,
17
18 /** Grenade type. */
19 Explosion,
20
21 /** General-purpose mesh type that can be moved. */
22 Dynamic,
23};
24
25/**
26 * Data asset containing hole configuration preset.
27 * Automatically registered to global registry on load.
28 */
29UCLASS(BlueprintType)
30class IVSMOKE_API UIVSmokeHolePreset : public UPrimaryDataAsset
31{
32 GENERATED_BODY()
33
34protected:
35 virtual void PostLoad() override;
36 virtual void BeginDestroy() override;
37
38public:
39 //~============================================================================
40 // Common
41
42 /**
43 * Hole Type. 0 = Penetration, 1 = Explosion, 2 = Dynamic
44 * Create a hole in a different way depending on this value.
45 */
46 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke")
47 EIVSmokeHoleType HoleType = EIVSmokeHoleType::Penetration;
48
49 /**
50 * This radius range that affects.
51 */
52 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (ClampMin = "0.1", ClampMax = "1000.0", EditConditionHides, EditCondition = "HoleType != EIVSmokeHoleType::Dynamic"))
53 float Radius = 50.0f;
54
55 /**
56 * Total effect duration.
57 */
58 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (ClampMin = "0.01", ClampMax = "60.0", Tooltip = "Define how long the hole will last within the smoke"))
59 float Duration = 3.0f;
60
61 /**
62 * Softness of the edges.
63 * 0 = hard edge, 1 = soft gradient
64 */
65 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (ClampMin = "0.0", ClampMax = "1.0", Tooltip = "0 = hard edge, 1 = soft gradient"))
66 float Softness = 0.3f;
67
68 //~============================================================================
69 // Explosion
70
71 /**
72 * Expansion time. The expansion time is used for expansion-related curve values.
73 */
74 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke | Expansion", meta = (ClampMin = "0.0", ClampMax = "60.0", EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Explosion",
75 Tooltip = "Expansion time is used for expansion-related curve values."))
76 float ExpansionDuration = 0.15f;
77
78 /**
79 * Fade range curve over expansion time.
80 * Use normalized time between 0 and 1.
81 */
82 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke | Expansion", meta = (EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Explosion",
83 Tooltip = "Fade range curve over expansion time. Use normalized time between 0 and 1"))
84 TObjectPtr<UCurveFloat> ExpansionFadeRangeCurveOverTime;
85
86 /**
87 * Fade out range curve over shrink time.
88 * At the end of the expansion time, the shrink time begins.
89 * ShrinkDuration = Duration - ExpansionDuration
90 * Use normalized time between 0 and 1
91 */
92 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke | Shrink", meta = (EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Explosion",
93 Tooltip = "Fade range curve over shrink time. Use normalized time between 0 and 1"))
94 TObjectPtr<UCurveFloat> ShrinkFadeRangeCurveOverTime;
95
96 /**
97 * Distortion exp value over expansion time.
98 * 1 - pow((1 - NormalizedTime), ExpValue)
99 */
100 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke | Distortion", meta = (ClampMin = "1.0", ClampMax = "5.0", EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Explosion",
101 Tooltip = "Distortion exp value over expansion time. 1 - pow((1 - NormalizedTime), ExpValue)"))
102 float DistortionExpOverTime = 1.0f;
103
104 /**
105 * Distortion degree max value.
106 * The degree of distortion is proportional to (dis(hole voxel to explosion point) / radius).
107 */
108 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke | Distortion", meta = (ClampMin = "0.0", ClampMax = "1000.0", EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Explosion",
109 Tooltip = "Distortion degree max value."))
110 float DistortionDistance = 250.0f;
111
112 //~============================================================================
113 // Penetration
114
115 /**
116 * EndRadius represents the radius at the EndPosition in a penetration hole.
117 */
118 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (ClampMin = "0.0", ClampMax = "1000.0", EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Penetration",
119 Tooltip = "EndRadius represents the radius at the EndPosition in a penetration hole."))
120 float EndRadius = 25.0f;
121
122 /**
123 * Bullet thickness for obstacle collision detection.
124 * Larger values make bullets more likely to be blocked by nearby walls.
125 */
126 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (ClampMin = "0.1", ClampMax = "50.0", EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Penetration",
127 Tooltip = "Bullet thickness for obstacle detection. Larger values make bullets more likely to be blocked by nearby walls."))
128 float BulletThickness = 5.0f;
129
130 //~============================================================================
131 // Dynamic
132
133 /**
134 * The size of a hole
135 */
136 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Dynamic",
137 Tooltip = "The size of a hole"))
138 FVector3f Extent = FVector3f(50.f, 50.f, 50.f);
139
140 /**
141 * Minimum travel distance to make a hole
142 */
143 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IVSmoke", meta = (ClampMin = "10.0", ClampMax = "500.0", EditConditionHides, EditCondition = "HoleType == EIVSmokeHoleType::Dynamic",
144 Tooltip = "Minimum travel distance to make a hole"))
145 float DistanceThreshold = 50.0f;
146
147 // ============================================================================
148
149 /** Returns the this preset id. */
150 FORCEINLINE uint8 GetPresetID() const { return CachedID; }
151
152 /**
153 * Find and return the preset with the key id.
154 * If not, return nullptr.
155 */
156 static TObjectPtr<UIVSmokeHolePreset> FindByID(const uint8 InPresetID);
157
158 /**
159 * Returns the y value corresponding to the x value of the curve.
160 * If the curve is nullptr, return 0.
161 */
162 static float GetFloatValue(const TObjectPtr<UCurveFloat> Curve, const float X);
163
164private:
165 /** Cached preset id. */
166 uint8 CachedID = 0;
167
168 /** Register this preset to global registry. */
169 void RegisterToGlobalRegistry();
170
171 /** Unregister this preset from global registry. */
172 void UnregisterFromGlobalRegistry();
173};