Plasma Engine  2.0
Loading...
Searching...
No Matches
FollowPathComponent.h
1#pragma once
2
3#include <Core/Messages/EventMessage.h>
4#include <Core/World/Component.h>
5#include <Core/World/ComponentManager.h>
6#include <GameEngine/Animation/PathComponent.h>
7#include <GameEngine/Animation/PropertyAnimResource.h>
8
10
12
14
15struct PL_GAMEENGINE_DLL plFollowPathMode
16{
17 using StorageType = plUInt8;
18
19 enum Enum
20 {
21 OnlyPosition,
22 AlignUpZ,
23 FullRotation,
24
25 Default = OnlyPosition
26 };
27};
28
29PL_DECLARE_REFLECTABLE_TYPE(PL_GAMEENGINE_DLL, plFollowPathMode)
30
31
45class PL_GAMEENGINE_DLL plFollowPathComponent : public plComponent
46{
48
50 // plComponent
51
52public:
53 virtual void SerializeComponent(plWorldWriter& ref_stream) const override;
54 virtual void DeserializeComponent(plWorldReader& ref_stream) override;
55
56protected:
57 virtual void OnActivated() override;
58 virtual void OnSimulationStarted() override;
59
61 // plFollowPathComponent
62
63public:
66
68 void SetPathObject(const char* szReference); // [ property ]
69
72 float m_fSpeed = 1.0f;
73 float m_fLookAhead = 1.0f;
74 float m_fSmoothing = 0.5f;
75 float m_fTiltAmount = 5.0f;
76 plAngle m_MaxTilt = plAngle::MakeFromDegree(30.0f);
77
79 void SetDistanceAlongPath(float fDistance); // [ property ]
80 float GetDistanceAlongPath() const; // [ property ]
81
83 void SetDirectionForwards(bool bForwards); // [ scriptable ]
84
86 void ToggleDirection(); // [ scriptable ]
87
91 bool IsDirectionForwards() const; // [ scriptable ]
92
94 bool IsRunning() const; // [ property ]
95
97 void SetRunning(bool bRunning); // [ property ]
98
99protected:
100 void Update(bool bForce = false);
101
102 plEventMessageSender<plMsgAnimationReachedEnd> m_ReachedEndEvent; // [ event ]
103 plGameObjectHandle m_hPathObject; // [ property ]
104 plPathComponent::LinearSampler m_PathSampler;
105
106 float m_fStartDistance = 0.0f; // [ property ]
107 bool m_bLastStateValid = false;
108 bool m_bIsRunning = true;
109 bool m_bIsRunningForwards = true;
110 plVec3 m_vLastPosition;
111 plVec3 m_vLastTargetPosition;
112 plVec3 m_vLastUpDir;
113 plAngle m_LastTiltAngle;
114
115 const char* DummyGetter() const { return nullptr; }
116};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
static constexpr plAngle MakeFromDegree(float fDegree)
Creates an instance of plAngle that was initialized from degree. (Performs a conversion)
Definition Angle_inl.h:33
Base class of all component types.
Definition Component.h:25
Simple component manager implementation that calls an update method on all components every frame.
Definition ComponentManager.h:142
A message sender that sends all messages to the next component derived from plEventMessageHandlerComp...
Definition EventMessage.h:39
This component makes the plGameObject, that it is attached to, move along a path defined by an plPath...
Definition FollowPathComponent.h:46
plEnum< plPropertyAnimMode > m_Mode
[ property ] How the path should be traversed.
Definition FollowPathComponent.h:70
plEnum< plFollowPathMode > m_FollowMode
[ property ] How the transform of the follower should be affected by the path.
Definition FollowPathComponent.h:71
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 FollowPathComponent.h:16
A handle to a game object.
Definition Declarations.h:76
Sent when an animation reached its end (either forwards or backwards playing)
Definition CommonMessages.h:42
An object that keeps track of where one is sampling the path component.
Definition PathComponent.h:130