Plasma Engine  2.0
Loading...
Searching...
No Matches
CharacterControllerComponent.h
1#pragma once
2
3#include <Core/World/Component.h>
4#include <Core/World/World.h>
5#include <GameEngine/GameEngineDLL.h>
6
8
9struct PL_GAMEENGINE_DLL plMsgMoveCharacterController : public plMessage
10{
11 PL_DECLARE_MESSAGE_TYPE(plMsgMoveCharacterController, plMessage);
12
13 double m_fMoveForwards = 0;
14 double m_fMoveBackwards = 0;
15 double m_fStrafeLeft = 0;
16 double m_fStrafeRight = 0;
17 double m_fRotateLeft = 0;
18 double m_fRotateRight = 0;
19 bool m_bRun = false;
20 bool m_bJump = false;
21 bool m_bCrouch = false;
22};
23
29class PL_GAMEENGINE_DLL plCharacterControllerComponent : public plComponent
30{
31 PL_DECLARE_ABSTRACT_COMPONENT_TYPE(plCharacterControllerComponent, plComponent);
32
34 // plComponent
35
36public:
37 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
38 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
39
40
42 // plCharacterControllerComponent
43
44public:
46
52 virtual void RawMove(const plVec3& vMoveDeltaGlobal) = 0; // [ scriptable ]
53
57 virtual void MoveCharacter(plMsgMoveCharacterController& ref_msg) = 0; // [ msg handler ]
58
63 virtual void TeleportCharacter(const plVec3& vGlobalFootPos) = 0; // [ scriptable ]
64
71 virtual bool IsDestinationUnobstructed(const plVec3& vGlobalFootPos, float fCharacterHeight) = 0; // [ scriptable ]
72
74 virtual bool IsTouchingGround() = 0; // [ scriptable ]
75
77 virtual bool IsCrouching() = 0; // [ scriptable ]
78};
Base class for implementations of a character controller.
Definition CharacterControllerComponent.h:30
virtual bool IsCrouching()=0
Checks whether the CC is currently in the crouch state.
virtual bool IsTouchingGround()=0
Checks whether the CC is currently touching the ground.
virtual void MoveCharacter(plMsgMoveCharacterController &ref_msg)=0
Instructs the CC to move in certain directions. An implementation can queue the request for later pro...
virtual void RawMove(const plVec3 &vMoveDeltaGlobal)=0
Attempts to move the character into the given direction.
virtual bool IsDestinationUnobstructed(const plVec3 &vGlobalFootPos, float fCharacterHeight)=0
Checks whether the CC can be teleported to the target position without getting stuck.
virtual void TeleportCharacter(const plVec3 &vGlobalFootPos)=0
Teleports the CC to the desired global position. Ignores obstacles on the path.
Base class of all component types.
Definition Component.h:25
Base class for all message types. Each message type has it's own id which is used to dispatch message...
Definition Message.h:22
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 CharacterControllerComponent.h:10