Atoms Crowd
7.0.0
ProbabilitySelector.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/BehaviourTree/Composite.h>
11
#include <Atoms/BehaviourTree/BlackboardValue.h>
12
#include <vector>
13
14
namespace
Atoms
15
{
16
class
ATOMS_EXPORT
ProbabilitySelector
:
public
Composite
17
{
18
19
public
:
20
21
struct
ProbabilitySelectorData
22
{
23
float
probability;
24
float
currentProbability;
25
std::vector<int> failedIndeces;
26
int
index;
27
};
28
29
ProbabilitySelector
();
30
31
virtual
~
ProbabilitySelector
();
32
33
virtual
const
char
* typeName()
const override
;
34
35
virtual
void
initialize(
BehaviourTreeContext
* context,
State
* data)
override
;
36
37
virtual
void
update(
BehaviourTreeContext
* context,
State
* data)
override
;
38
39
virtual
void
terminate(
BehaviourTreeContext
* context,
State
* data)
override
;
40
41
virtual
void
releaseData(
BehaviourTreeContext
* context,
State
* data)
override
;
42
43
virtual
void
onChildUpdated(
BehaviourTreeContext
* context,
State
* data,
unsigned
int
childIndex,
unsigned
short
childStatus)
override
;
44
45
virtual
void
setAttributes(
const
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard)
override
;
46
47
virtual
void
getAttributes(
AtomsCore::MapMetadata
* attributes,
Blackboard
* blackboard)
override
;
48
49
virtual
void
getAttributeProperties(
AtomsCore::MapMetadata
* attributes)
override
;
50
51
static
Behaviour
* creator();
52
53
double
getTotal(
BehaviourTreeContext
* context,
State
* data);
54
55
private
:
56
57
BlackboardIntValue
m_seed;
58
59
BlackboardDoubleValue
m_failChance;
60
61
std::vector<BlackboardDoubleValue> m_weights;
62
63
bool
m_useAgentIdAsSeed;
64
65
bool
m_useAnimatedSeed;
66
};
67
}
Atoms::Behaviour
Definition:
Behaviour.h:21
Atoms::BehaviourTreeContext
Definition:
BehaviourTreeContext.h:24
Atoms::Blackboard
Definition:
Blackboard.h:35
Atoms::BlackboardValue< int >
Atoms::Composite
Definition:
Composite.h:18
Atoms::ProbabilitySelector
Definition:
ProbabilitySelector.h:17
AtomsCore::MapMetadata
MapMetadata class.
Definition:
MapMetadata.h:24
Atoms
Atoms namespace.
Definition:
Agent.h:29
Atoms::Behaviour::State
Definition:
Behaviour.h:34
Atoms::ProbabilitySelector::ProbabilitySelectorData
Definition:
ProbabilitySelector.h:22
Atoms
Public
Atoms
BehaviourTree
Composites
ProbabilitySelector.h