Atoms Crowd
7.0.0
Behaviour.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/GlobalNames.h>
12
#include <AtomsCore/Metadata/MapMetadata.h>
13
14
namespace
Atoms
15
{
16
17
class
BehaviourTreeContext;
18
class
Blackboard;
19
20
class
ATOMS_EXPORT
Behaviour
21
{
22
public
:
23
enum
Status
24
{
25
INVALID = 0,
26
SUCCESS,
27
FAILURE,
28
RUNNING,
29
ABORTED,
30
SUSPENDEND
31
};
32
33
struct
State
34
{
35
union
36
{
37
int
intValue;
38
int
int2Value[2];
39
short
short4Value[4];
40
float
float2Value[2];
41
double
doubleValue;
42
void
* ptrValue;
43
};
44
unsigned
short
status;
45
unsigned
short
index;
46
unsigned
short
tickCount;
47
unsigned
short
padding;
48
};
49
50
Behaviour
();
51
52
Behaviour
(
unsigned
short
idx,
unsigned
short
parentIdx);
53
54
virtual
~
Behaviour
();
55
56
virtual
const
char
* typeName()
const
;
57
58
virtual
void
initialize(
BehaviourTreeContext
* context,
State
* data);
59
60
virtual
void
update(
BehaviourTreeContext
* context,
State
* data);
61
62
virtual
void
terminate(
BehaviourTreeContext
* context,
State
* data);
63
64
virtual
void
releaseData(
BehaviourTreeContext
* context,
State
* data);
65
66
void
tick(
BehaviourTreeContext
* context,
State
* data);
67
68
virtual
void
onChildUpdated(
BehaviourTreeContext
* context,
State
* data,
unsigned
int
childIndex,
unsigned
short
childStatus);
69
70
virtual
void
addChild(
unsigned
short
childIndex);
71
72
virtual
void
setAttributes(
const
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard);
73
virtual
void
getAttributes(
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard);
74
75
virtual
void
getAttributeProperties(
AtomsCore::MapMetadata
* attributes);
76
77
virtual
bool
needPreallocatedMemory()
const
;
78
79
virtual
bool
isGPUNode()
const
;
80
81
unsigned
short
index;
82
short
parentIndex;
83
unsigned
short
span;
84
unsigned
char
baseType;
85
unsigned
char
lock;
86
};
87
}
88
89
#define BT_BEHAVIOUR_DEFINE_GET_ATTRIBUTE(TYPE, NAME) \
90
TYPE NAME## Meta(NAME.value); \
91
attributes->addEntry(#NAME, &NAME##Meta); \
92
\
93
94
#define BT_BEHAVIOUR_DEFINE_GET_METADATA_ATTRIBUTE(NAME) \
95
if (!NAME.value) {attributes->addEmptyEntry(#NAME);} else {attributes->addEntry(#NAME, NAME.value); } \
96
\
97
Atoms::Behaviour
Definition:
Behaviour.h:21
Atoms::BehaviourTreeContext
Definition:
BehaviourTreeContext.h:24
Atoms::Blackboard
Definition:
Blackboard.h:35
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
Behaviour.h