Debian Codegraph @

include/ifx.h

raw
1 #pragma once
2
3 #include "imodule.h"
4 #include "ideclmanager.h"
5 #include "math/Vector3.h"
6
7 namespace fx
8 {
9
10 class IFxAction
11 {
12 public:
13 using Ptr = std::shared_ptr<IFxAction>;
14
15 enum class Type
16 {
17 Undefined = -1,
18 Light = 0,
19 Particle,
20 Decal,
21 Model,
22 Sound,
23 Shake,
24 AttachLight,
25 AttachEntity,
26 Launch,
27 Shockwave
28 };
29
30 virtual ~IFxAction() {}
31
32 virtual Type getActionType() = 0;
33
34 // Returns the name of this action (which might be an empty string)
35 virtual const std::string& getName() = 0;
36
37 // Returns the action delay in seconds
38 virtual float getDelayInSeconds() = 0;
39
40 // Action duration in seconds, before it is killed or restarted
41 virtual float getDurationInSeconds() = 0;
42
43 // True: Don't shake the entity this effect is attached to
44 virtual bool getIgnoreMaster() = 0;
45
46 // Shake parameters
47
48 virtual float getShakeTimeInSeconds() = 0;
49 virtual float getShakeAmplitude() = 0;
50 virtual float getShakeDistance() = 0;
51 virtual bool getShakeFalloff() = 0;
52 virtual float getShakeImpulse() = 0;
53
54 // True: The light in this effect doesn't cast shadows
55 virtual bool getNoShadows() = 0;
56
57 // Causes the sibling action to happen when this action does.
58 virtual const std::string& getFireSiblingAction() = 0;
59
60 // Let the delay be random between min and max (in seconds)
61 // If both are 0.0 no random delay is active and the regular delay is used instead
62 virtual std::pair<float, float> getRandomDelay() = 0;
63
64 // According to the docs this is not used
65 virtual float getRotate() = 0;
66
67 // Move around with the entity (vs stationary after spawning)
68 virtual bool getTrackOrigin() = 0;
69
70 // True: the action starts again after the 'duration' has run out
71 virtual bool getRestart() = 0;
72
73 // Fade in the RGB of the light or model over <time> seconds
74 virtual float getFadeInTimeInSeconds() = 0;
75
76 // Fade out the light/model. Ignored if fadeIn is set, you can use 2 separate
77 // actions (tied together with uselight) if you want a light to fade in and out.
78 virtual float getFadeOutTimeInSeconds() = 0;
79
80 // Size of the decal (corresponds to "size" keyword)
81 virtual float getDecalSize() = 0;
82
83 // Offset from the origin of the entity (or bind point) this action is located at
84 virtual const Vector3& getOffset() = 0;
85
86 // Axis of the model, mutually exclusive with angle
87 virtual const Vector3& getAxis() = 0;
88
89 // Alternate way of setting the axis of the model
90 virtual const Vector3& getAngle() = 0;
91
92 // Returns the name of the action containing the light which should be used
93 virtual const std::string& getUseLight() = 0;
94
95 // Modify the model in a named sibling action. Can be used to fade out a particle in a sibling.
96 virtual const std::string& getUseModel() = 0;
97
98 // Attach to external light (a light not defined in the effect) for fading.
99 virtual const std::string& getAttachLight() = 0;
100
101 // Attach to an external entity
102 virtual const std::string& getAttachEntity() = 0;
103
104 // Launches a projectile of the given entityDef
105 virtual const std::string& getLaunchProjectileDef() = 0;
106
107 // If not empty, this action spawns a light with this material
108 virtual const std::string& getLightMaterialName() = 0;
109
110 // For Type::Light actions, this defines the RGB colour components
111 virtual const Vector3& getLightRgbColour() = 0;
112
113 // For Type::Light actions, this defines the radius of the spawned light
114 virtual float getLightRadius() = 0;
115
116 // Return the name of the model or particle
117 virtual const std::string& getModelName() = 0;
118
119 // For Type::Decal actions, this defines the decal material name
120 virtual const std::string& getDecalMaterialName() = 0;
121
122 // Unused according to docs
123 virtual bool getParticleTrackVelocity() = 0;
124
125 // For Type::Sound actions: start a sound (on any channel)
126 virtual const std::string& getSoundShaderName() = 0;
127
128 // For Type::Shockwave actions: the name of the shockwave entityDef
129 virtual const std::string& getShockwaveDefName() = 0;
130 };
131
132 class IFxDeclaration :
133 public decl::IDeclaration
134 {
135 public:
136 using Ptr = std::shared_ptr<IFxDeclaration>;
137
138 // Returns the number of actions in this FX declaration
139 virtual std::size_t getNumActions() = 0;
140
141 // Returns the n-th action (based on the given 0-based index)
142 virtual IFxAction::Ptr getAction(std::size_t index) = 0;
143
144 // Returns the name of the joint this FX should bind to
145 // Evaluated to an empty string if "bindTo" is not set
146 virtual std::string getBindTo() = 0;
147 };
148
149 /**
150 * Convenience interface to deal with FX declarations
151 */
152 class IFxManager :
153 public RegisterableModule
154 {
155 public:
156 /**
157 * Lookup an FX declaration by name.
158 * If the decl is not found, an empty reference is returned.
159 */
160 virtual IFxDeclaration::Ptr findFx(const std::string& name) = 0;
161 };
162
163 }
164
165 constexpr const char* const MODULE_FXMANAGER("FxManager");
166
167 inline fx::IFxManager& GlobalFxManager()
168 {
169 static module::InstanceReference<fx::IFxManager> _reference(MODULE_FXMANAGER);
170 return _reference;
171 }