Plasma Engine  2.0
Loading...
Searching...
No Matches
CameraShakeVolumeComponent.h
1#pragma once
2
3#include <Core/World/Component.h>
4#include <Core/World/Declarations.h>
5#include <Core/World/World.h>
6#include <GameComponentsPlugin/GameComponentsDLL.h>
7
11
15class PL_GAMECOMPONENTS_DLL plCameraShakeVolumeComponent : public plComponent
16{
17 PL_DECLARE_ABSTRACT_COMPONENT_TYPE(plCameraShakeVolumeComponent, plComponent);
18
20 // plComponent
21
22public:
23 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
24 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
25
26protected:
27 virtual void OnActivated() override;
28 virtual void OnDeactivated() override;
29 virtual void OnSimulationStarted() override;
30
32 // plCameraShakeVolumeComponent
33
34public:
37
40
42 plTime m_BurstDuration; // [ property ]
43
45 float m_fStrength; // [ property ]
46
48 float ComputeForceAtGlobalPosition(const plSimdVec4f& vGlobalPos) const;
49
51 virtual float ComputeForceAtLocalPosition(const plSimdVec4f& vLocalPos) const = 0;
52
55
56protected:
57 void OnTriggered(plMsgComponentInternalTrigger& msg);
58 void OnMsgDeleteGameObject(plMsgDeleteGameObject& msg);
59};
60
64
66
74{
76
78 // plComponent
79
80public:
81 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
82 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
83
85 // plCameraShakeVolumeSphereComponent
86
87public:
90
91 virtual float ComputeForceAtLocalPosition(const plSimdVec4f& vLocalPos) const override;
92
93 float GetRadius() const { return m_fRadius; } // [ property ]
94 void SetRadius(float fVal); // [ property ]
95
96private:
97 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& msg);
98
99 float m_fRadius = 1.0f;
100 plSimdFloat m_fOneDivRadius;
101};
Base class for components that define volumes in which a camera shake effect shall be applied.
Definition CameraShakeVolumeComponent.h:16
plEnum< plOnComponentFinishedAction > m_OnFinishedAction
In case of a burst shake, defines whether the component should delete itself afterwards.
Definition CameraShakeVolumeComponent.h:54
plTime m_BurstDuration
How long a shake burst should last. Zero for constant shaking.
Definition CameraShakeVolumeComponent.h:42
float m_fStrength
How strong the shake should be at the strongest point. Typically a value between one and zero.
Definition CameraShakeVolumeComponent.h:45
static plSpatialData::Category SpatialDataCategory
The spatial category used to find camera shake volume components through the spatial system.
Definition CameraShakeVolumeComponent.h:39
virtual float ComputeForceAtLocalPosition(const plSimdVec4f &vLocalPos) const =0
Calculates the shake strength in local space of the component.
A spherical volume in which a camera shake will be applied.
Definition CameraShakeVolumeComponent.h:74
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 OnSimulationStarted()
This method is called once for active components, at the start of the next world update,...
Definition Component.cpp:144
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 SimdFloat.h:7
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
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
For internal use by components to trigger some known behavior. Usually components will post this mess...
Definition TriggerMessage.h:26
Definition DeleteObjectMessage.h:7
Definition UpdateLocalBoundsMessage.h:9
Definition SpatialData.h:27
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12