Plasma Engine  2.0
Loading...
Searching...
No Matches
AiBehavior.h
1#pragma once
2
3#include <AiPlugin/AiPluginDLL.h>
4#include <GameEngine/GameEngineDLL.h>
5
6class plAiBehavior;
9class plGameObject;
10class plAiActionQueue;
11
12enum class plAiScoreCategory
13{
14 Fallback,
15 Idle,
16 ActiveIdle,
17 Investigate,
18 Command,
19 Combat,
20 Interrupt,
21};
22
24{
25public:
27
28 void SetScore(plAiScoreCategory category, float fValue)
29 {
30 PL_ASSERT_DEBUG(fValue >= 0.0f && fValue <= 1.0f, "Value is out of 0-1 range.");
31 m_fValue = static_cast<float>(category) + fValue;
32 }
33
34 float GetScore() const { return m_fValue; }
35
36 const plAiPerception* m_pPerception = nullptr;
37
38private:
39 float m_fValue = 0.0f;
40};
41
43{
44 plAiBehavior* m_pBehavior = nullptr;
45 const plAiPerception* m_pPerception = nullptr;
46 float m_fScore = 0.0f;
47};
48
49class PL_AIPLUGIN_DLL plAiBehavior
50{
51public:
52 plAiBehavior() = default;
53 virtual ~plAiBehavior() = default;
54
56 {
58 bool m_bAllowBehaviorSwitch = true;
60 bool m_bEndBehavior = false;
61 };
62
63 virtual bool IsAvailable(float fActiveBehaviorScore) const { return true; }
64 virtual void FlagNeededPerceptions(plAiPerceptionManager& ref_PerceptionManager) = 0;
65
66 virtual plAiBehaviorScore DetermineBehaviorScore(plGameObject& owner, const plAiPerceptionManager& perceptionManager) = 0;
67
68 virtual void ActivateBehavior(plGameObject& owner, const plAiPerception* pPerception, plAiActionQueue& inout_ActionQueue) = 0;
69 virtual void ReactivateBehavior(plGameObject& owner, const plAiPerception* pPerception, plAiActionQueue& inout_ActionQueue) = 0;
70 virtual void DeactivateBehavior(plGameObject& owner, plAiActionQueue& inout_ActionQueue) {}
71 virtual ContinuationState ContinueBehavior(plGameObject& owner, plAiActionQueue& inout_ActionQueue)
72 {
73 ContinuationState res;
74 res.m_bEndBehavior = inout_ActionQueue.IsEmpty();
75 return res;
76 }
77
78 virtual plTime GetCooldownDuration() { return plTime::MakeZero(); }
79};
Definition AiActionQueue.h:9
bool IsEmpty() const
Returns true when no action is currently queued.
Definition AiActionQueue.cpp:15
Definition AiBehavior.h:50
Definition AiBehavior.h:24
Definition AiPerception.h:7
Definition AiPerceptionManager.h:12
This class represents an object inside the world.
Definition GameObject.h:32
Definition AiBehavior.h:56
Definition AiBehavior.h:43
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
PL_ALWAYS_INLINE static constexpr plTime MakeZero()
Creates an instance of plTime that was initialized with zero.
Definition Time.h:42