Plasma Engine  2.0
Loading...
Searching...
No Matches
FakeRopeComponent.h
1#pragma once
2
3#include <Core/World/ComponentManager.h>
4#include <GameEngine/Physics/RopeSimulator.h>
5
7
8class PL_GAMECOMPONENTS_DLL plFakeRopeComponentManager : public plComponentManager<class plFakeRopeComponent, plBlockStorageType::FreeList>
9{
10public:
13
14 virtual void Initialize() override;
15
16private:
17 void Update(const plWorldModule::UpdateContext& context);
18};
19
21
33class PL_GAMECOMPONENTS_DLL plFakeRopeComponent : public plComponent
34{
36
38 // plComponent
39
40public:
41 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
42 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
43
44 virtual void OnActivated() override;
45 virtual void OnDeactivated() override;
46
48 // plFakeRopeComponent
49
50public:
53
55 plUInt16 m_uiPieces = 16; // [ property ]
56
57 void SetAnchor1Reference(const char* szReference); // [ property ]
58 void SetAnchor2Reference(const char* szReference); // [ property ]
59
61 void SetAnchor1(plGameObjectHandle hActor);
63 void SetAnchor2(plGameObjectHandle hActor);
64
66 void SetSlack(float fVal);
67 float GetSlack() const { return m_fSlack; }
68
70 void SetAttachToAnchor1(bool bVal);
72 void SetAttachToAnchor2(bool bVal);
73 bool GetAttachToAnchor1() const;
74 bool GetAttachToAnchor2() const;
75
77 float m_fDamping = 0.5f; // [ property ]
78
79private:
80 plResult ConfigureRopeSimulator();
81 void SendCurrentPose();
82 void SendPreviewPose();
83 void RuntimeUpdate();
84
85 plGameObjectHandle m_hAnchor1;
86 plGameObjectHandle m_hAnchor2;
87
88 float m_fSlack = 0.0f;
89 plUInt32 m_uiPreviewHash = 0;
90
91 // if the owner or the anchor object are flagged as 'dynamic', the rope must follow their movement
92 // otherwise it can skip some update steps
93 bool m_bIsDynamic = true;
94 plUInt8 m_uiCheckEquilibriumCounter = 0;
95 plUInt8 m_uiSleepCounter = 0;
96 plRopeSimulator m_RopeSim;
97 float m_fWindInfluence = 0.0f;
98
99private:
100 const char* DummyGetter() const { return nullptr; }
101};
Base class of all component types.
Definition Component.h:25
Definition ComponentManager.h:88
Simulates the behavior of a rope/cable without physical interaction with the world.
Definition FakeRopeComponent.h:34
Definition FakeRopeComponent.h:9
A simple simulator for swinging and hanging ropes.
Definition RopeSimulator.h:17
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
virtual void Initialize()
This method is called after the constructor. A derived type can override this method to do initializa...
Definition WorldModule.h:98
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 handle to a game object.
Definition Declarations.h:76
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition WorldModule.h:33