Peoplemon  0.1.0
Peoplemon 3 game source documentation
NPC.cpp
Go to the documentation of this file.
2 
3 #include <Core/Properties.hpp>
4 
5 namespace core
6 {
7 namespace component
8 {
9 NPC::NPC(const file::NPC& data)
10 : _name(data.name())
11 , _conversation() {
12  if (!_conversation.load(
13  bl::util::FileUtil::joinPath(Properties::ConversationPath(), data.conversation()))) {
14  BL_LOG_ERROR << "Failed to load npc conversation: " << data.conversation();
15 #ifdef PEOPLEMON_DEBUG
16  _conversation = file::Conversation::makeLoadError(data.conversation());
17 #endif
18  }
19 }
20 
21 const std::string& NPC::name() const { return _name; }
22 
23 const file::Conversation& NPC::conversation() const { return _conversation; }
24 
25 } // namespace component
26 } // namespace core
Core classes and functionality for both the editor and game.
NPC(const file::NPC &data)
Construct a new NPC component.
Definition: NPC.cpp:9
const file::Conversation & conversation() const
The conversation of the NPC.
Definition: NPC.cpp:23
const std::string & name() const
The name of the NPC.
Definition: NPC.cpp:21
Stores a conversation that an NPC or trainer can have with the player.
bool load(const std::string &file)
Loads the conversation from the given file.
static Conversation makeLoadError(const std::string &filename)
Helper function to create a conversation that reports an error if in debug mode.
File data for NPCs.
Definition: NPC.hpp:26
std::string & conversation()
The conversation file of the NPC.
Definition: NPC.cpp:58
static const std::string & ConversationPath()
Definition: Properties.cpp:539