1 #ifndef CORE_FILES_BEHAVIOR_HPP
2 #define CORE_FILES_BEHAVIOR_HPP
4 #include <BLIB/Serialization.hpp>
5 #include <BLIB/Tilemap/Direction.hpp>
85 Pace(bl::tmap::Direction dir, std::uint16_t
steps);
129 bool legacyLoad(bl::serial::binary::InputStream& input);
194 std::variant<Standing, Spinning, Path, Wander> data;
197 friend struct bl::serial::SerializableObject<
Behavior>;
208 struct SerializableObject<
core::file::Behavior::Path::Pace> :
public SerializableObjectBase {
212 SerializableField<2, P, std::uint16_t>
steps;
215 : SerializableObjectBase(
"BehaviorPathPace")
216 , direction(
"direction", *this, &
P::direction, SerializableFieldBase::Required{})
217 , steps(
"steps", *this, &
P::steps, SerializableFieldBase::Required{}) {}
221 struct SerializableObject<
core::file::Behavior::Path> :
public SerializableObjectBase {
224 SerializableField<1, P, std::vector<P::Pace>>
paces;
228 : SerializableObjectBase(
"BehaviorPath")
229 , paces(
"paces", *this, &
P::paces, SerializableFieldBase::Required{})
230 , reverse(
"reverse", *this, &
P::reverse, SerializableFieldBase::Required{}) {}
234 struct SerializableObject<
core::file::Behavior::Standing> :
public SerializableObjectBase {
240 : SerializableObjectBase(
"BehaviorStanding")
241 , direction(
"direction", *this, &
S::facedir, SerializableFieldBase::Required{}) {}
245 struct SerializableObject<
core::file::Behavior::Spinning> :
public SerializableObjectBase {
251 : SerializableObjectBase(
"BehaviorSpinning")
252 , direction(
"direction", *this, &
S::spinDir, SerializableFieldBase::Required{}) {}
256 struct SerializableObject<
core::file::Behavior::Wander> :
public SerializableObjectBase {
259 SerializableField<1, W, std::uint32_t>
radius;
262 : SerializableObjectBase(
"BehaviorWander")
263 , radius(
"radius", *this, &
W::radius, SerializableFieldBase::Required{}) {}
267 struct SerializableObject<
core::file::Behavior> :
public SerializableObjectBase {
270 SerializableField<1, B, B::Type>
type;
271 SerializableField<2,
B, decltype(B::data)>
data;
274 : SerializableObjectBase(
"Behavior")
275 , type(
"type", *this, &
B::_type, SerializableFieldBase::Required{})
276 , data(
"data", *this, &
B::data, SerializableFieldBase::Required{}) {}
Core classes and functionality for both the editor and game.
bl::serial::json::Serializer< Player > Serializer
Set of behaviors for NPCs and trainers.
bool legacyLoad(bl::serial::binary::InputStream &input)
Loads the behavior data from the legacy formatted file. Use serialize and deserialize for reading and...
Spinning & spinning()
The data for spinning.
Behavior()
Empty behavior. Standing still facing down.
Type type() const
The type of behavior this is.
void setType(Type type)
Set the Type of behavior. Existing behavior data is cleared.
Wander & wander()
The data for wandering.
Standing & standing()
The data for standing still.
Type
The type of behavior.
@ Wandering
The character is allowed to wander freely.
@ FollowingPath
The character will follow a preset path.
@ StandStill
The character will stand and face a given direction.
@ SpinInPlace
The character will spin in place.
Path & path()
The data for path following.
Contains data if the behavior type is StandStill.
Standing()
Stand facing down.
bl::tmap::Direction facedir
The direction to face.
Contains data for when the behavior type is SpinInPlace.
enum core::file::Behavior::Spinning::Direction spinDir
Direction
The direction to spin.
@ Random
The character spins randomly.
@ Counterclockwise
The character spins counterclockwise.
@ Clockwise
The character spins clockwise.
Contains data for when the behavior type is following a path.
std::vector< Pace > paces
The sections of the path.
bool reverse
True if the path should be done in reverse when completed, false to loop.
Path()
Makes an empty path.
Represents a straight section of path.
std::uint16_t steps
The number of steps to take. No need to account for direction change.
Pace()
Makes a single step up.
bl::tmap::Direction direction
The direction to walk in.
Contains data for when the behavior type is Wandering.
std::uint32_t radius
The radius to stay within, in tiles.
Wander()
Wander in a 10 tile radius.
Wander(std::uint32_t r)
Creates the data.
SerializableField< 1, P, bl::tmap::Direction > direction
SerializableField< 2, P, std::uint16_t > steps
SerializableField< 2, P, bool > reverse
SerializableField< 1, P, std::vector< P::Pace > > paces
SerializableField< 1, S, bl::tmap::Direction > direction
SerializableField< 1, S, S::Direction > direction
SerializableField< 1, W, std::uint32_t > radius
SerializableField< 1, B, B::Type > type
SerializableField< 2, B, decltype(B::data)> data