PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
patrol_waypoint_component.h
1#pragma once
2
3#include "pixelbullet/serialization/node.h"
4
5#include <algorithm>
6
7namespace pixelbullet
8{
10{
11 bool enabled = true;
12 float dwell_seconds = 0.0f;
13
14 [[nodiscard]] bool operator==(const PatrolWaypointComponent&) const noexcept = default;
15};
16
17inline Node& operator<<(Node& node, const PatrolWaypointComponent& component)
18{
19 node["enabled"] << component.enabled;
20 node["dwellSeconds"] << component.dwell_seconds;
21 return node;
22}
23
24inline const Node& operator>>(const Node& node, PatrolWaypointComponent& component)
25{
26 if (node.HasProperty("enabled"))
27 {
28 node["enabled"] >> component.enabled;
29 }
30 else
31 {
32 component.enabled = true;
33 }
34
35 if (node.HasProperty("dwellSeconds"))
36 {
37 node["dwellSeconds"] >> component.dwell_seconds;
38 }
39 else
40 {
41 component.dwell_seconds = 0.0f;
42 }
43
44 component.dwell_seconds = std::max(component.dwell_seconds, 0.0f);
45 return node;
46}
47} // namespace pixelbullet
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition patrol_waypoint_component.h:10