Atoms Crowd
7.0.0
Composite.h
1
#pragma once
2
// ===========================================================================
3
// Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4
//
5
// Use of this software is subject to the terms of the Toolchefs license
6
// agreement provided at the time of installation or download, or which
7
// otherwise accompanies this software in either electronic or hard copy form.
8
// ===========================================================================
9
10
#include <Atoms/Globals.h>
11
#include <Atoms/BehaviourTree/Behaviour.h>
12
#include <vector>
13
14
namespace
Atoms
15
{
16
17
class
ATOMS_EXPORT
Composite
:
public
Behaviour
18
{
19
public
:
20
Composite
();
21
virtual
~
Composite
();
22
23
virtual
const
char
* typeName()
const override
;
24
25
virtual
void
addChild(
unsigned
short
childIndex)
override
;
26
27
virtual
void
setAttributes(
const
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard)
override
;
28
29
virtual
void
getAttributes(
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard)
override
;
30
31
virtual
void
getAttributeProperties(
AtomsCore::MapMetadata
* attributes)
override
;
32
33
unsigned
short
getLocalChildIndex(
unsigned
short
idx)
const
;
34
35
std::vector<unsigned short> m_Children;
36
};
37
39
// Sequence
41
class
ATOMS_EXPORT
Sequence
:
public
Composite
42
{
43
public
:
44
Sequence
();
45
46
virtual
~
Sequence
();
47
48
virtual
const
char
* typeName()
const override
;
49
50
virtual
void
initialize(
BehaviourTreeContext
* context,
State
* data)
override
;
51
52
virtual
void
update(
BehaviourTreeContext
* context,
State
* data)
override
;
53
54
virtual
void
terminate(
BehaviourTreeContext
* context,
State
* data)
override
;
55
56
virtual
void
onChildUpdated(
BehaviourTreeContext
* context,
State
* data,
unsigned
int
childIndex,
unsigned
short
childStatus)
override
;
57
58
virtual
void
getAttributeProperties(
AtomsCore::MapMetadata
* attributes)
override
;
59
60
static
Behaviour
* creator();
61
};
62
64
// Selector
66
class
ATOMS_EXPORT
Selector
:
public
Composite
67
{
68
69
public
:
70
Selector
();
71
72
virtual
~
Selector
();
73
74
virtual
const
char
* typeName()
const override
;
75
76
virtual
void
initialize(
BehaviourTreeContext
* context,
State
* data)
override
;
77
78
virtual
void
update(
BehaviourTreeContext
* context,
State
* data)
override
;
79
80
virtual
void
terminate(
BehaviourTreeContext
* context,
State
* data)
override
;
81
82
virtual
void
onChildUpdated(
BehaviourTreeContext
* context,
State
* data,
unsigned
int
childIndex,
unsigned
short
childStatus)
override
;
83
84
virtual
void
getAttributeProperties(
AtomsCore::MapMetadata
* attributes)
override
;
85
86
static
Behaviour
* creator();
87
};
88
90
// Parallel
92
class
ATOMS_EXPORT
Parallel
:
public
Composite
93
{
94
public
:
95
96
enum
Policy {
97
RequireOne = 0,
98
RequireAll
99
};
100
101
Parallel
();
102
103
Parallel
(
unsigned
short
success,
unsigned
short
failure);
104
105
virtual
~
Parallel
();
106
107
virtual
const
char
* typeName()
const override
;
108
109
virtual
void
initialize(
BehaviourTreeContext
* context,
State
* data)
override
;
110
111
virtual
void
update(
BehaviourTreeContext
* context,
State
* data)
override
;
112
113
virtual
void
terminate(
BehaviourTreeContext
* context,
State
* data)
override
;
114
115
virtual
void
onChildUpdated(
BehaviourTreeContext
* context,
State
* data,
unsigned
int
childIndex,
unsigned
short
childStatus)
override
;
116
117
virtual
void
setAttributes(
const
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard)
override
;
118
119
virtual
void
getAttributes(
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard)
override
;
120
121
virtual
void
getAttributeProperties(
AtomsCore::MapMetadata
* attributes)
override
;
122
123
static
Behaviour
* creator();
124
125
protected
:
126
127
unsigned
short
m_eSuccessPolicy;
128
unsigned
short
m_eFailurePolicy;
129
};
130
}
Atoms::Behaviour
Definition:
Behaviour.h:21
Atoms::BehaviourTreeContext
Definition:
BehaviourTreeContext.h:24
Atoms::Blackboard
Definition:
Blackboard.h:35
Atoms::Composite
Definition:
Composite.h:18
Atoms::Parallel
Definition:
Composite.h:93
Atoms::Selector
Definition:
Composite.h:67
Atoms::Sequence
Definition:
Composite.h:42
AtomsCore::MapMetadata
MapMetadata class.
Definition:
MapMetadata.h:24
Atoms
Atoms namespace.
Definition:
Agent.h:29
Atoms::Behaviour::State
Definition:
Behaviour.h:34
Atoms
Public
Atoms
BehaviourTree
Composite.h