Plasma Engine  2.0
Loading...
Searching...
No Matches
VolumeComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Core/World/World.h>
5#include <Foundation/Types/RangeView.h>
6#include <GameEngine/GameEngineDLL.h>
7
9
11
16class PL_GAMEENGINE_DLL plVolumeComponent : public plComponent
17{
18 PL_DECLARE_ABSTRACT_COMPONENT_TYPE(plVolumeComponent, plComponent);
19
21 // plComponent
22
23protected:
24 virtual void OnActivated() override;
25 virtual void OnDeactivated() override;
26
27public:
28 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
29 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
30
32 // plVolumeComponent
33
34public:
37
39 void SetTemplateFile(const char* szFile); // [ property ]
40 const char* GetTemplateFile() const; // [ property ]
41
43 void SetTemplate(const plBlackboardTemplateResourceHandle& hResource);
44 plBlackboardTemplateResourceHandle GetTemplate() const { return m_hTemplateResource; }
45
47 void SetSortOrder(float fOrder); // [ property ]
48 float GetSortOrder() const { return m_fSortOrder; } // [ property ]
49
51 void SetVolumeType(const char* szType); // [ property ]
52 const char* GetVolumeType() const; // [ property ]
53
55 void SetValue(const plHashedString& sName, const plVariant& value); // [ scriptable ]
56 plVariant GetValue(plTempHashedString sName) const // [ scriptable ]
57 {
58 plVariant v;
59 m_Values.TryGetValue(sName, v);
60 return v;
61 }
62
63protected:
64 const plRangeView<const plString&, plUInt32> Reflection_GetKeys() const;
65 bool Reflection_GetValue(const char* szName, plVariant& value) const;
66 void Reflection_InsertValue(const char* szName, const plVariant& value);
67 void Reflection_RemoveValue(const char* szName);
68
69 void InitializeFromTemplate();
70 void ReloadTemplate();
71 void RemoveReloadFunction();
72
73 plBlackboardTemplateResourceHandle m_hTemplateResource;
75 plSmallArray<plHashedString, 1> m_OverwrittenValues; // only used in editor
76 float m_fSortOrder = 0.0f;
77 plSpatialData::Category m_SpatialCategory = plInvalidSpatialDataCategory;
78 bool m_bReloadFunctionAdded = false;
79};
80
82
84
86class PL_GAMEENGINE_DLL plVolumeSphereComponent : public plVolumeComponent
87{
89
91 // plVolumeComponent
92
93public:
94 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
95 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
96
98 // plVolumeSphereComponent
99
100public:
103
104 void SetRadius(float fRadius);
105 float GetRadius() const { return m_fRadius; }
106
108 void SetFalloff(float fFalloff);
109 float GetFalloff() const { return m_fFalloff; }
110
111protected:
112 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& ref_msg) const;
113
114 float m_fRadius = 5.0f;
115 float m_fFalloff = 0.5f;
116};
117
119
121
123class PL_GAMEENGINE_DLL plVolumeBoxComponent : public plVolumeComponent
124{
126
128 // plVolumeComponent
129
130public:
131 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
132 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
133
135 // plVolumeBoxComponent
136
137public:
140
142 void SetExtents(const plVec3& vExtents);
143 const plVec3& GetExtents() const { return m_vExtents; }
144
148 void SetFalloff(const plVec3& vFalloff);
149 const plVec3& GetFalloff() const { return m_vFalloff; }
150
151protected:
152 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& ref_msg) const;
153
154 plVec3 m_vExtents = plVec3(10.0f);
155 plVec3 m_vFalloff = plVec3(0.5f);
156};
Base class of all component types.
Definition Component.h:25
virtual void SerializeComponent(plWorldWriter &inout_stream) const
Override this to save the current state of the component to the given stream.
Definition Component.cpp:54
virtual void OnDeactivated()
This method is called when the component gets deactivated.
Definition Component.cpp:142
virtual void DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
virtual void OnActivated()
This method is called when the component gets activated.
Definition Component.cpp:140
Definition ComponentManager.h:88
Definition HashTable.h:333
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
This class uses delegates to define a range of values that can be enumerated using a forward iterator...
Definition RangeView.h:24
Definition SmallArray.h:219
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
A box implementation of the plVolumeComponent.
Definition VolumeComponent.h:124
A volume component can hold generic values either from a blackboard template or set directly on the c...
Definition VolumeComponent.h:17
A sphere implementation of the plVolumeComponent.
Definition VolumeComponent.h:87
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
Definition UpdateLocalBoundsMessage.h:9
Definition SpatialData.h:27