1 #ifndef CORE_FILES_NPC_HPP
2 #define CORE_FILES_NPC_HPP
4 #include <BLIB/Resources.hpp>
5 #include <BLIB/Serialization.hpp>
40 bool save(
const std::string& file)
const;
49 bool saveBundle(bl::serial::binary::OutputStream& output,
50 bl::resource::bundle::FileHandlerContext& ctx)
const;
59 bool load(
const std::string& file, bl::tmap::Direction spawnDir = bl::tmap::Direction::Up);
67 bool loadDev(std::istream& input);
75 bool loadProd(bl::serial::binary::InputStream& input);
87 const std::string&
name()
const;
126 std::string nameField;
127 std::string animField;
128 std::string conversationField;
131 friend struct bl::serial::SerializableObject<
NPC>;
142 struct SerializableObject<
core::file::NPC> :
public SerializableObjectBase {
151 : SerializableObjectBase(
"NPC")
152 , nameField(
"name", *this, &
N::nameField, SerializableFieldBase::Required{})
153 , animField(
"anim", *this, &
N::animField, SerializableFieldBase::Required{})
154 , conversationField(
"conv", *this, &
N::conversationField, SerializableFieldBase::Required{})
155 , behaviorField(
"behavior", *this, &
N::behaviorField, SerializableFieldBase::Required{}) {}
Core classes and functionality for both the editor and game.
Set of behaviors for NPCs and trainers.
bool loadDev(std::istream &input)
Loads the NPC from the json stream.
bool save(const std::string &file) const
Saves the NPC data to the given file.
std::string & conversation()
The conversation file of the NPC.
Behavior & behavior()
The behavior of the NPC.
std::string & name()
The name of the NPC.
bool load(const std::string &file, bl::tmap::Direction spawnDir=bl::tmap::Direction::Up)
Loads the NPC data from the given file.
bool loadProd(bl::serial::binary::InputStream &input)
Loads the NPC from it's binary format.
NPC()=default
Construct a new NPC file.
std::string & animation()
The directory of the movement animations.
bool saveBundle(bl::serial::binary::OutputStream &output, bl::resource::bundle::FileHandlerContext &ctx) const
Saves the data from this object to the given bundle and registers depency files if any.
SerializableField< 3, N, std::string > conversationField
SerializableField< 2, N, std::string > animField
SerializableField< 1, N, std::string > nameField
SerializableField< 4, N, core::file::Behavior > behaviorField