(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Behavior.hh
1 #ifndef GRAIL_AI_BEHAVIOR_H
2 #define GRAIL_AI_BEHAVIOR_H
3 
4 #include <string>
5 
6 namespace grail
7 {
8  class AIEntity;
9 
10  enum class BehaviorStatus
11  {
12  SUSPENDED = 0,
13  ACTIVE,
14  FINISHED,
15  DELEGALIZED,
16  };
17 
19  class Behavior
20  {
21  friend class AIEntity;
22  friend class BehaviorSequence;
23 
24  public:
25  Behavior();
26  Behavior(const Behavior&) = default;
27  Behavior(Behavior&&) = default;
28 
29  virtual ~Behavior();
30 
31  Behavior& operator = (const Behavior&) = delete;
32  Behavior& operator = (Behavior&&) = delete;
33 
36  virtual void Start(AIEntity& owner);
37 
40  virtual void Update(AIEntity &owner, float deltaTime) = 0;
41 
44  virtual void Finish(AIEntity& owner, const BehaviorStatus status);
45 
47  virtual bool IsFinished(const AIEntity& owner) const;
48 
51  virtual bool IsLegal(const AIEntity& owner) const;
52 
54  virtual bool IsInterruptible() const;
55 
60  BehaviorStatus GetStatus() const;
61 
62  virtual std::string GetName() const;
63 
64  private:
65  void UpdateStatus(const AIEntity& owner);
66  void SetStatus(BehaviorStatus newStatus);
67 
68  BehaviorStatus status = BehaviorStatus::SUSPENDED;
69  };
70 }
71 #endif //GRAIL_AI_BEHAVIOR_H
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:39
A high-level abstraction of actions in the game.
Definition: Behavior.hh:20
virtual bool IsInterruptible() const
Definition: Behavior.cpp:35
virtual void Update(AIEntity &owner, float deltaTime)=0
virtual void Start(AIEntity &owner)
Definition: Behavior.cpp:16
virtual bool IsFinished(const AIEntity &owner) const
Definition: Behavior.cpp:25
BehaviorStatus GetStatus() const
GetStatus.
Definition: Behavior.cpp:55
virtual void Finish(AIEntity &owner, const BehaviorStatus status)
Definition: Behavior.cpp:20
virtual bool IsLegal(const AIEntity &owner) const
Definition: Behavior.cpp:30
The BehaviorSequence class - specialized Behavior executing sequence of provided subbehaviors one by ...
Definition: BehaviorSequence.hh:15