Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
EntityGroup.h
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_ENTITY_GROUP_H
4 #define GRAIL_ENTITY_GROUP_H
5 
6 #include "AIEntity.hh"
7 #include "Blackboard.hh"
8 
9 #include <string>
10 #include <vector>
11 
12 namespace grail
13 {
18  struct EntityEntry
19  {
20  std::shared_ptr<AIEntity> entity;
21  int relativePriority;
22 
23  EntityEntry(const std::shared_ptr<AIEntity>& entity, int relativePriority);
24  };
25 
27  {
28  public:
29  EntityGroup(const std::string& name);
30  EntityGroup(const std::string& name, const std::vector<EntityEntry>& entityEntries);
31 
37  static void ResetNextID(const size_t nextId = 0);
38 
39  const std::string& GetName() const;
40 
41  void SetId(size_t id);
42  size_t GetId() const;
43 
44  void AddEntityEntry(const std::shared_ptr<AIEntity>& entity, int relativePriority);
45  void RemoveEntityEntry(const AIEntity& entity);
46  void AddGroupBlackboard(const std::string& name, const std::shared_ptr<Blackboard>& blackboard);
47  void AddGlobalBlackboardMapping(std::shared_ptr<AIEntity> entity,
48  const std::vector<std::string>& blackboardNames);
49 
50  std::shared_ptr<AIEntity> GetEntity(const std::string& name) const;
51  const std::vector<EntityEntry>& GetEntityEntries() const;
52  const std::vector<std::pair<std::string, std::shared_ptr<Blackboard>>>& GetGroupBlackboards() const;
53  const std::vector<std::pair<std::shared_ptr<AIEntity>, std::vector<std::string>>>&
54  GetGlobalBlackboardMapping() const;
55  private:
56  inline static size_t nextGroupId = 0;
57  std::string name{};
58  size_t id = std::numeric_limits<size_t>::max();
59  std::vector<EntityEntry> entityEntries{};
60  std::vector<std::pair<std::string, std::shared_ptr<Blackboard>>> groupBlackboards{};
61  std::vector<std::pair<std::shared_ptr<AIEntity>, std::vector<std::string>>> globalBlackboardMapping{};
62  };
63 }
64 
65 #endif
grail::EntityEntry
EntityEntry - internal struct containing AIEntity and its relative priority. Entities with higher pri...
Definition: EntityGroup.h:18
grail::EntityGroup
Definition: EntityGroup.h:26
grail::AIEntity
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:50
grail::EntityGroup::ResetNextID
static void ResetNextID(const size_t nextId=0)
ResetNextID - Resets taken entity group IDs. Useful when a game has ended but entities were not destr...
Definition: EntityGroup.cpp:24