15 std::ofstream output(file.c_str());
16 return bl::serial::json::Serializer<Trainer>::serializeStream(output, *
this, 4, 0);
20 bl::resource::bundle::FileHandlerContext& ctx)
const {
21 if (!bl::serial::binary::Serializer<Trainer>::serialize(output, *
this))
return false;
23 const std::array<std::string, 4> Suffixes{
"up.anim",
"right.anim",
"down.anim",
"left.anim"};
24 const std::string ap =
26 for (
const std::string& s : Suffixes) {
27 const std::string p = bl::util::FileUtil::joinPath(ap, s);
28 if (bl::util::FileUtil::exists(p)) { ctx.addDependencyFile(p); }
29 else { BL_LOG_WARN <<
"Trainer " <<
name <<
" is missing anim: " << p; }
32 const auto addConv = [
this, &ctx](
const std::string& cf) {
34 if (bl::util::FileUtil::exists(c)) { ctx.addDependencyFile(c); }
35 else { BL_LOG_WARN <<
"Trainer " <<
name <<
" is missing conversation " << cf; }
43 bool Trainer::load(
const std::string& file, bl::tmap::Direction spawnDir) {
45 if (!TrainerManager::initializeExisting(file, *
this))
return false;
48 for (
auto& ppl :
peoplemon) { ppl.heal(); }
53 return bl::serial::binary::Serializer<Trainer>::deserialize(input, *
this);
57 return bl::serial::json::Serializer<Trainer>::deserializeStream(input, *
this);
Core classes and functionality for both the editor and game.
Type type() const
The type of behavior this is.
Standing & standing()
The data for standing still.
@ StandStill
The character will stand and face a given direction.
bl::tmap::Direction facedir
The direction to face.
std::vector< pplmn::OwnedPeoplemon > peoplemon
bool loadDev(std::istream &input)
Loads the trainer from the json stream.
std::string postBattleConversation
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.
bool save(const std::string &file) const
Saves the trainer data to the given file.
bool loadProd(bl::serial::binary::InputStream &input)
Loads the trainer from it's binary format.
bool load(const std::string &file, bl::tmap::Direction spawnDir=bl::tmap::Direction::Down)
Loads the trainer data from the given file.
Trainer()
Gives sane defaults.
std::string prebattleConversation
static const std::string & ConversationPath()
static const std::string & CharacterAnimationPath()