Plasma Engine  2.0
Loading...
Searching...
No Matches
ParticleComponent.h
1#pragma once
2
3#include <Core/ResourceManager/Resource.h>
4#include <Core/ResourceManager/ResourceHandle.h>
5#include <Core/World/World.h>
6#include <Foundation/Types/RangeView.h>
7#include <ParticlePlugin/Effect/ParticleEffectController.h>
8#include <ParticlePlugin/Effect/ParticleEffectInstance.h>
9#include <ParticlePlugin/ParticlePluginDLL.h>
10#include <RendererCore/Components/RenderComponent.h>
11
12class plParticleRenderData;
17struct plMsgSetPlaying;
18
20
21class PL_PARTICLEPLUGIN_DLL plParticleComponentManager final : public plComponentManager<class plParticleComponent, plBlockStorageType::Compact>
22{
24
25public:
27
28 virtual void Initialize() override;
29
30 void Update(const plWorldModule::UpdateContext& context);
31
32 void UpdatePfxTransformsAndBounds();
33};
34
36class PL_PARTICLEPLUGIN_DLL plParticleComponent final : public plRenderComponent
37{
39
41 // plComponent
42
43public:
44 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
45 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
46
47protected:
48 virtual void OnDeactivated() override;
49
51 // plRenderComponent
52
53public:
54 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
55
57 // plParticleComponent
58
59public:
62
67 bool StartEffect(); // [ scriptable ]
68
70 void StopEffect(); // [ scriptable ]
71
73 void InterruptEffect(); // [ scriptable ]
74
76 bool IsEffectActive() const; // [ scriptable ]
77
79 void OnMsgSetPlaying(plMsgSetPlaying& ref_msg); // [ msg handler ]
80
82 void SetParticleEffect(const plParticleEffectResourceHandle& hEffect);
83 PL_ALWAYS_INLINE const plParticleEffectResourceHandle& GetParticleEffect() const { return m_hEffectResource; }
84
85 void SetParticleEffectFile(const char* szFile); // [ property ]
86 const char* GetParticleEffectFile() const; // [ property ]
87
88 // Exposed Parameters
89 const plRangeView<const char*, plUInt32> GetParameters() const; // [ property ]
90 void SetParameter(const char* szKey, const plVariant& value); // [ property ]
91 void RemoveParameter(const char* szKey); // [ property ]
92 bool GetParameter(const char* szKey, plVariant& out_value) const; // [ property ]
93
95 plUInt64 m_uiRandomSeed = 0; // [ property ]
96
103
105 bool m_bSpawnAtStart = true; // [ property ]
106
108 bool m_bIgnoreOwnerRotation = false; // [ property ]
109
112
114 plTime m_MinRestartDelay; // [ property ]
115
118
120 plEnum<plBasisAxis> m_SpawnDirection = plBasisAxis::PositiveZ; // [ property ]
121
124
125protected:
126 void Update();
127 plTransform GetPfxTransform() const;
128 void UpdatePfxTransformAndBounds();
129
130 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
131 void OnMsgDeleteGameObject(plMsgDeleteGameObject& msg);
132
133 plParticleEffectResourceHandle m_hEffectResource;
134
135 plTime m_RestartTime;
136
137 // Exposed Parameters
139 bool m_bIfContinuousStopRightAway = false;
140 bool m_bFloatParamsChanged = false;
141 bool m_bColorParamsChanged = false;
144};
Definition ComponentManager.h:88
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Plays a particle effect at the location of the game object.
Definition ParticleComponent.h:37
plParticleEffectController m_EffectController
Allows more fine grain control over the effect execution.
Definition ParticleComponent.h:123
plTime m_MinRestartDelay
Minimum delay between finishing and restarting.
Definition ParticleComponent.h:114
plTime m_RestartDelayRange
Random additional delay between finishing and restarting.
Definition ParticleComponent.h:117
plEnum< plOnComponentFinishedAction2 > m_OnFinishedAction
What to do when the effect is finished playing.
Definition ParticleComponent.h:111
plString m_sSharedInstanceName
If set, the component reuses the simulation state of another particle component with the same name.
Definition ParticleComponent.h:102
Definition ParticleComponent.h:22
Definition ParticleEffectController.h:7
Definition ParticleEventReaction_Effect.h:37
A particle system stores all data for one 'layer' of a running particle effect.
Definition ParticleSystemInstance.h:15
This class uses delegates to define a range of values that can be enumerated using a forward iterator...
Definition RangeView.h:24
Base class for objects that should be rendered.
Definition RenderComponent.h:9
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition DeleteObjectMessage.h:7
Definition RenderData.h:116
Common message for components that can be toggled between playing and paused states.
Definition CommonMessages.h:9
Definition UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
Definition WorldModule.h:33