Plasma Engine  2.0
Loading...
Searching...
No Matches
TransformComponent.h
1#pragma once
2
3#include <Core/World/Component.h>
4#include <Core/World/World.h>
5#include <Foundation/Time/Time.h>
6#include <GameEngine/GameEngineDLL.h>
7
10{
11 using StorageType = plUInt16;
12
13 enum Enum
14 {
15 None = 0,
16 Running = PL_BIT(0),
17 AutoReturnStart = PL_BIT(1),
18 AutoReturnEnd = PL_BIT(2),
19 AnimationReversed = PL_BIT(5),
21 };
22
23 struct Bits
24 {
25 StorageType Running : 1;
26 StorageType AutoReturnStart : 1;
27 StorageType AutoReturnEnd : 1;
28 StorageType Unused1 : 1;
29 StorageType Unused2 : 1;
30 StorageType AnimationReversed : 1;
31 };
32};
33
34PL_DECLARE_FLAGS_OPERATORS(plTransformComponentFlags);
35
37class PL_GAMEENGINE_DLL plTransformComponent : public plComponent
38{
39 PL_ADD_DYNAMIC_REFLECTION(plTransformComponent, plComponent);
40
42 // plComponent
43
44public:
45 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
46 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
47
48protected:
49 virtual void OnSimulationStarted() override;
50
52 // plTransformComponent
53
54public:
57
61 void SetDirectionForwards(bool bForwards); // [ scriptable ]
62
66 void ToggleDirection(); // [ scriptable ]
67
69 bool IsDirectionForwards() const; // [ scriptable ]
70
72 bool IsRunning(void) const; // [ property ]
73
75 void SetRunning(bool bRunning); // [ property ]
76
78 bool GetReverseAtStart(void) const; // [ property ]
79 void SetReverseAtStart(bool b); // [ property ]
80
82 bool GetReverseAtEnd(void) const; // [ property ]
83 void SetReverseAtEnd(bool b); // [ property ]
84
86 float m_fAnimationSpeed = 1.0f; // [ property ]
87
88protected:
90 plTime m_AnimationTime;
91};
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 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
Base class for some components that modify an object's transform.
Definition TransformComponent.h:38
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
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
Definition TransformComponent.h:24
Internal flags for the current state of a transform component.
Definition TransformComponent.h:10
Enum
Definition TransformComponent.h:14
@ Running
The component is currently modifying the transform.
Definition TransformComponent.h:16
@ AutoReturnStart
When reaching the start point, the transform should automatically turn around.
Definition TransformComponent.h:17
@ AutoReturnEnd
When reaching the end point, the transform should automatically turn around.
Definition TransformComponent.h:18
@ AnimationReversed
The animation playback is currently in reverse.
Definition TransformComponent.h:19