3#include "pixelbullet/scene/entity_id.h"
4#include "pixelbullet/serialization/node.h"
12enum class PatrolOrientationMode
18[[nodiscard]]
constexpr std::string_view ToString(
const PatrolOrientationMode value)
noexcept
22 case PatrolOrientationMode::KeepRotation:
23 return "KeepRotation";
24 case PatrolOrientationMode::FaceMovement:
26 return "FaceMovement";
30inline Node& operator<<(
Node& node,
const PatrolOrientationMode& value)
32 node << std::string(ToString(value));
36inline const Node& operator>>(
const Node& node, PatrolOrientationMode& value)
38 std::string serialized;
40 value = serialized ==
"KeepRotation" ? PatrolOrientationMode::KeepRotation : PatrolOrientationMode::FaceMovement;
47 EntityId route_entity = EntityId::Invalid();
48 float move_speed = 1.5f;
49 float arrive_distance = 0.1f;
50 PatrolOrientationMode orientation_mode = PatrolOrientationMode::FaceMovement;
57 node[
"enabled"] << component.enabled;
58 if (component.route_entity)
60 node[
"routeEntity"] << component.route_entity.Raw();
62 node[
"moveSpeed"] << component.move_speed;
63 node[
"arriveDistance"] << component.arrive_distance;
64 node[
"orientationMode"] << component.orientation_mode;
70 if (node.HasProperty(
"enabled"))
72 node[
"enabled"] >> component.enabled;
76 component.enabled =
true;
79 if (node.HasProperty(
"routeEntity"))
81 EntityId::ValueType raw_value = 0u;
82 node[
"routeEntity"] >> raw_value;
83 component.route_entity = EntityId::FromRaw(raw_value);
87 component.route_entity = EntityId::Invalid();
90 if (node.HasProperty(
"moveSpeed"))
92 node[
"moveSpeed"] >> component.move_speed;
96 component.move_speed = 1.5f;
99 if (node.HasProperty(
"arriveDistance"))
101 node[
"arriveDistance"] >> component.arrive_distance;
105 component.arrive_distance = 0.1f;
108 if (node.HasProperty(
"orientationMode"))
110 node[
"orientationMode"] >> component.orientation_mode;
114 component.orientation_mode = PatrolOrientationMode::FaceMovement;
117 component.move_speed = std::max(component.move_speed, 0.0f);
118 component.arrive_distance = std::max(component.arrive_distance, 0.0001f);
Definition entity_id.h:11
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition patrol_agent_component.h:45