3#include "pixelbullet/serialization/node.h"
13 int respawn_health = 3;
14 float post_respawn_invulnerability_seconds = 1.0f;
21 node[
"enabled"] << component.enabled;
22 node[
"maxHealth"] << component.max_health;
23 node[
"respawnHealth"] << component.respawn_health;
24 node[
"postRespawnInvulnerabilitySeconds"] << component.post_respawn_invulnerability_seconds;
28inline const Node& operator>>(
const Node& node, PawnVitalityComponent& component)
30 if (node.HasProperty(
"enabled"))
32 node[
"enabled"] >> component.enabled;
36 component.enabled =
true;
39 if (node.HasProperty(
"maxHealth"))
41 node[
"maxHealth"] >> component.max_health;
45 component.max_health = 3;
48 if (node.HasProperty(
"respawnHealth"))
50 node[
"respawnHealth"] >> component.respawn_health;
54 component.respawn_health = component.max_health;
57 if (node.HasProperty(
"postRespawnInvulnerabilitySeconds"))
59 node[
"postRespawnInvulnerabilitySeconds"] >> component.post_respawn_invulnerability_seconds;
63 component.post_respawn_invulnerability_seconds = 1.0f;
66 component.max_health = std::max(component.max_health, 1);
67 component.respawn_health = std::clamp(component.respawn_health, 1, component.max_health);
68 component.post_respawn_invulnerability_seconds = std::max(component.post_respawn_invulnerability_seconds, 0.0f);
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition pawn_vitality_component.h:10