Peoplemon  0.1.0
Peoplemon 3 game source documentation
Interaction.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_INTERACTION_HPP
2 #define CORE_SYSTEMS_INTERACTION_HPP
3 
4 #include <BLIB/ECS.hpp>
5 #include <BLIB/Events.hpp>
8 #include <Core/Events/Battle.hpp>
10 #include <unordered_map>
11 #include <unordered_set>
12 
13 namespace core
14 {
15 namespace system
16 {
17 class Systems;
18 
27 : public bl::event::Listener<event::GameSaveInitializing, event::BattleCompleted> {
28 public:
34  Interaction(Systems& owner);
35 
40  void init();
41 
48  bool interact(bl::ecs::Entity interactor);
49 
56  bool npcTalkedTo(const std::string& name) const;
57 
64  bool trainerTalkedto(const std::string& name) const;
65 
72  bool flagSet(const std::string& flag) const;
73 
79  void setFlag(const std::string& flag);
80 
81 private:
82  Systems& owner;
83  bl::ecs::Entity interactingEntity;
84  ai::Conversation currentConversation;
85  std::unordered_map<std::string, std::unordered_set<std::string>> talkedTo;
86  std::unordered_set<std::string> flags;
87  component::Trainer* interactingTrainer;
88 
89  void processConversationNode();
90  void faceEntity(bl::ecs::Entity toRotate, bl::ecs::Entity toFace);
91 
92  void continuePressed();
93  void failMessageFinished();
94  void choiceMade(const std::string& choice);
95  void giveItemDecided(const std::string& choice);
96  void giveMoneyDecided(const std::string& choice);
97 
98  virtual void observe(const event::GameSaveInitializing& save) override;
99  virtual void observe(const event::BattleCompleted& battle) override;
100  void setTalked(const std::string& name);
101 
102  void startBattle();
103 
104  friend struct bl::serial::SerializableObject<Interaction>;
105 };
106 
107 } // namespace system
108 } // namespace core
109 
110 #endif
Core classes and functionality for both the editor and game.
Wrapper around file::Conversation that tracks current node,.
Adding this to an entity will make it a trainer that can battle.
Definition: Trainer.hpp:18
Fired when a battle finishes.
Definition: Battle.hpp:36
Fired when the game is saving or loading. Allows systems to hook in their data.
Definition: GameSave.hpp:22
The main interaction system. Manages interaction between entities. Handles item logic and NPC convers...
Definition: Interaction.hpp:27
void init()
Subscribes to the game event bus.
Definition: Interaction.cpp:33
Interaction(Systems &owner)
Construct a new Interaction system.
Definition: Interaction.cpp:27
bool flagSet(const std::string &flag) const
Checks if the given conversation flag has been set.
bool npcTalkedTo(const std::string &name) const
Returns whether or not the given npc has been talked to.
bool interact(bl::ecs::Entity interactor)
Performs an interation on behalf of the given entity.
Definition: Interaction.cpp:35
bool trainerTalkedto(const std::string &name) const
Returns whether or not the given trainer has been talked to.
void setFlag(const std::string &flag)
Sets the conversation flag.
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47