-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBehaviorTree.h
More file actions
65 lines (54 loc) · 1.35 KB
/
Copy pathBehaviorTree.h
File metadata and controls
65 lines (54 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include<stack>
#include "Behavior.h"
namespace BT
{
enum class EActionMode
{
Attack,
Patrol,
Runaway,
};
enum class EConditionMode
{
IsSeeEnemy,
IsHealthLow,
IsEnemyDead,
};
class BehaviorTree
{
public:
BehaviorTree(Behavior* InRoot):Root(InRoot) {}
virtual ~BehaviorTree() {}
void Tick();
bool HaveRoot() { return Root ? true : false; }
void SetRoot(Behavior* InNode) { Root = InNode; }
void Release() { Root->Release(); }
private:
Behavior* Root;
};
class BehaviorTreeBuilder
{
public:
BehaviorTreeBuilder() { }
virtual ~BehaviorTreeBuilder() { }
BehaviorTreeBuilder* Sequence();
BehaviorTreeBuilder* Action(EActionMode ActionModes);
BehaviorTreeBuilder* Condition(EConditionMode ConditionMode, bool IsNegation);
BehaviorTreeBuilder* Selector();
BehaviorTreeBuilder* Repeat(int RepeatNum);
BehaviorTreeBuilder* ActiveSelector();
BehaviorTreeBuilder* Filter();
BehaviorTreeBuilder* Parallel(EPolicy InSucess, EPolicy InFailure);
BehaviorTreeBuilder* Monitor(EPolicy InSucess, EPolicy InFailure);
BehaviorTreeBuilder* Back();
BehaviorTree* End();
BehaviorTreeBuilder* Action(Behavior* NewBehavior);
BehaviorTreeBuilder* Condition(Behavior* NewBehavior);
private:
void AddBehavior(Behavior* NewBehavior);
private:
Behavior* TreeRoot = nullptr;
std::stack<Behavior*> NodeStack;
};
}