2016-02-05 05:52:05 +00:00
|
|
|
#ifndef _DNAMP1_AFSM_HPP_
|
|
|
|
#define _DNAMP1_AFSM_HPP_
|
2016-02-04 02:04:05 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
#include <athena/FileWriter.hpp>
|
2016-02-04 02:04:05 +00:00
|
|
|
#include "../DNACommon/DNACommon.hpp"
|
|
|
|
#include "DNAMP1.hpp"
|
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
namespace DataSpec::DNAMP1
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
struct AFSM : public BigYAML
|
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
Value<atUint32> stateCount;
|
|
|
|
Vector<String<-1>, DNA_COUNT(stateCount)> stateNames;
|
|
|
|
Value<atUint32> triggerCount;
|
|
|
|
|
|
|
|
struct State : public BigYAML
|
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
Value<atUint32> transitionCount;
|
|
|
|
struct Transition : public BigYAML
|
|
|
|
{
|
|
|
|
Delete _d;
|
|
|
|
Value<atUint32> triggerCount;
|
|
|
|
|
|
|
|
struct Trigger : public BigYAML
|
|
|
|
{
|
|
|
|
Delete _d;
|
|
|
|
bool first = false;
|
|
|
|
String<-1> name;
|
|
|
|
Value<float> parameter;
|
|
|
|
Value<atUint32> targetState;
|
2016-03-04 23:04:53 +00:00
|
|
|
void read(athena::io::IStreamReader& __dna_reader)
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* name */
|
|
|
|
name = __dna_reader.readString(-1);
|
|
|
|
/* parameter */
|
|
|
|
parameter = __dna_reader.readFloatBig();
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
/* targetState */
|
|
|
|
targetState = __dna_reader.readUint32Big();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void write(athena::io::IStreamWriter& __dna_writer) const
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* name */
|
|
|
|
__dna_writer.writeString(name, -1);
|
|
|
|
/* parameter */
|
|
|
|
__dna_writer.writeFloatBig(parameter);
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
/* targetState */
|
|
|
|
__dna_writer.writeUint32Big(targetState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void read(athena::io::YAMLDocReader& __dna_docin)
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* name */
|
|
|
|
name = __dna_docin.readString("name");
|
|
|
|
/* parameter */
|
|
|
|
parameter = __dna_docin.readFloat("parameter");
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
/* targetState */
|
|
|
|
targetState = __dna_docin.readUint32("targetState");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void write(athena::io::YAMLDocWriter& __dna_docout) const
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* name */
|
|
|
|
__dna_docout.writeString("name", name);
|
|
|
|
/* parameter */
|
|
|
|
__dna_docout.writeFloat("parameter", parameter);
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
/* targetState */
|
|
|
|
__dna_docout.writeUint32("targetState", targetState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::AFSM::Transition::Trigger";
|
2016-02-04 02:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
__isz += name.size() + 1;
|
|
|
|
return __isz + (first ? 8 : 4);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Trigger, DNA_COUNT(triggerCount)> triggers;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void read(athena::io::IStreamReader& __dna_reader)
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* triggerCount */
|
|
|
|
triggerCount = __dna_reader.readUint32Big();
|
|
|
|
int i = 0;
|
|
|
|
/* triggers */
|
|
|
|
__dna_reader.enumerate<Trigger>(triggers, triggerCount,
|
2016-03-04 23:04:53 +00:00
|
|
|
[&](athena::io::IStreamReader& in, Trigger& tr){
|
2016-02-04 02:04:05 +00:00
|
|
|
tr.first = i == 0;
|
|
|
|
tr.read(in);
|
|
|
|
i++;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void write(athena::io::IStreamWriter& __dna_writer) const
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* triggerCount */
|
|
|
|
__dna_writer.writeInt32Big(triggerCount);
|
|
|
|
/* triggers */
|
|
|
|
__dna_writer.enumerate(triggers);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void read(athena::io::YAMLDocReader& __dna_docin)
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
/* triggers */
|
2016-03-04 23:04:53 +00:00
|
|
|
triggerCount = __dna_docin.enumerate<Trigger>("triggers", triggers,
|
|
|
|
[&](athena::io::YAMLDocReader& in, Trigger& tr){
|
2016-02-04 02:04:05 +00:00
|
|
|
tr.first = i == 0;
|
|
|
|
tr.read(in);
|
|
|
|
i++;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void write(athena::io::YAMLDocWriter& __dna_docout) const
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
/* triggers */
|
|
|
|
__dna_docout.enumerate("triggers", triggers);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::AFSM::Transition";
|
2016-02-04 02:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
__isz = __EnumerateSize(__isz, triggers);
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Transition, DNA_COUNT(transitionCount)> transitions;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<State, DNA_COUNT(stateCount)> states;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
2016-02-04 02:04:05 +00:00
|
|
|
{
|
|
|
|
AFSM afsm;
|
|
|
|
afsm.read(rs);
|
2016-08-22 03:47:48 +00:00
|
|
|
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
|
|
|
afsm.toYAMLStream(writer);
|
2016-02-04 02:04:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // _RETRO_AFSM_HPP_
|