Plasma Engine  2.0
Loading...
Searching...
No Matches
NavigationComponent.h
1#pragma once
2
3#include <AiPlugin/AiPluginDLL.h>
4#include <AiPlugin/Navigation/Navigation.h>
5#include <AiPlugin/Navigation/Steering.h>
6#include <Core/World/Component.h>
7#include <Core/World/World.h>
8
9PL_DECLARE_FLAGS(plUInt32, plAiNavigationDebugFlags, PrintState, VisPathCorridor, VisPathLine, VisTarget);
10PL_DECLARE_REFLECTABLE_TYPE(PL_AIPLUGIN_DLL, plAiNavigationDebugFlags);
11
14{
15 using StorageType = plUInt8;
16
17 enum Enum
18 {
24
25 Default = Idle
26 };
27};
28
29PL_DECLARE_REFLECTABLE_TYPE(PL_AIPLUGIN_DLL, plAiNavigationComponentState);
30
32
45class PL_AIPLUGIN_DLL plAiNavigationComponent : public plComponent
46{
48
50 // plComponent
51
52public:
53 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
54 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
55
56protected:
57 virtual void OnSimulationStarted() override;
58
60 // plAiNavMeshPathTestComponent
61
62public:
65
71 void SetDestination(const plVec3& vGlobalPos, bool bAllowPartialPath);
72
74 void CancelNavigation();
75
78
79 float m_fReachedDistance = 1.0f;
80 float m_fSpeed = 5.0f;
81 float m_fFootRadius = 0.15f;
82 plUInt32 m_uiCollisionLayer = 0;
83 float m_fFallHeight = 0.7f;
84 float m_fAcceleration = 3.0f;
85 float m_fDecceleration = 8.0f;
86
88
91
92protected:
93 void Update();
94 void Steer(plTransform& transform, float tDiff);
95 void PlaceOnGround(plTransform& transform, float tDiff);
96
98 plAiSteering m_Steering;
99 plAiNavigation m_Navigation;
100 float m_fFallSpeed = 0.0f;
101 bool m_bAllowPartialPath = false;
102 plUInt8 m_uiSkipNextFrames = 0;
103
104private:
105 const char* DummyGetter() const { return nullptr; }
106};
Adds functionality to navigate on a navmesh.
Definition NavigationComponent.h:46
plHashedString m_sNavmeshConfig
[ property ] Which navmesh to walk on.
Definition NavigationComponent.h:76
plHashedString m_sPathSearchConfig
[ property ] What constraints there are for walking on the navmesh.
Definition NavigationComponent.h:77
plBitflags< plAiNavigationDebugFlags > m_DebugFlags
[ property ] What aspects of the navigation to visualize.
Definition NavigationComponent.h:87
plEnum< plAiNavigationComponentState > GetState() const
Returns the current navigation state.
Definition NavigationComponent.h:90
Computes a path through a navigation mesh.
Definition Navigation.h:41
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
Simple component manager implementation that calls an update method on all components every frame.
Definition ComponentManager.h:142
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
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
Describes the different states a navigating object may be in.
Definition NavigationComponent.h:14
Enum
Definition NavigationComponent.h:18
@ Fallen
Was high up, now reached the ground. May happen if spawned in air, otherwise should never happen,...
Definition NavigationComponent.h:22
@ Moving
Moving or waiting for a path to be computed.
Definition NavigationComponent.h:20
@ Falling
High up above the ground, falling downwards.
Definition NavigationComponent.h:21
@ Failed
Path could not be found, either because start position is invalid (off mesh) or destination is not re...
Definition NavigationComponent.h:23
@ Idle
Currently not navigating.
Definition NavigationComponent.h:19
Definition Steering.h:12
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37