3#include "pixelbullet/serialization/node.h"
9enum class MeleeAttackTimingMode
18 float attack_range = 1.25f;
19 float windup_seconds = 0.35f;
20 float cooldown_seconds = 0.85f;
21 int damage_amount = 1;
22 MeleeAttackTimingMode timing_mode = MeleeAttackTimingMode::Seconds;
23 std::string impact_notify_id;
28inline Node& operator<<(
Node& node,
const MeleeAttackTimingMode mode)
30 node << (mode == MeleeAttackTimingMode::AnimationNotify ?
"AnimationNotify" :
"Seconds");
34inline const Node& operator>>(
const Node& node, MeleeAttackTimingMode& mode)
38 mode = token ==
"AnimationNotify" ? MeleeAttackTimingMode::AnimationNotify : MeleeAttackTimingMode::Seconds;
44 node[
"enabled"] << component.enabled;
45 node[
"attackRange"] << component.attack_range;
46 node[
"windupSeconds"] << component.windup_seconds;
47 node[
"cooldownSeconds"] << component.cooldown_seconds;
48 node[
"damageAmount"] << component.damage_amount;
49 node[
"timingMode"] << component.timing_mode;
50 if (component.timing_mode == MeleeAttackTimingMode::AnimationNotify && !component.impact_notify_id.empty())
52 node[
"impactNotifyId"] << component.impact_notify_id;
59 if (node.HasProperty(
"enabled"))
61 node[
"enabled"] >> component.enabled;
65 component.enabled =
true;
68 if (node.HasProperty(
"attackRange"))
70 node[
"attackRange"] >> component.attack_range;
74 component.attack_range = 1.25f;
77 if (node.HasProperty(
"windupSeconds"))
79 node[
"windupSeconds"] >> component.windup_seconds;
83 component.windup_seconds = 0.35f;
86 if (node.HasProperty(
"cooldownSeconds"))
88 node[
"cooldownSeconds"] >> component.cooldown_seconds;
92 component.cooldown_seconds = 0.85f;
95 if (node.HasProperty(
"damageAmount"))
97 node[
"damageAmount"] >> component.damage_amount;
101 component.damage_amount = 1;
104 if (node.HasProperty(
"timingMode"))
106 node[
"timingMode"] >> component.timing_mode;
110 component.timing_mode = MeleeAttackTimingMode::Seconds;
113 if (node.HasProperty(
"impactNotifyId"))
115 node[
"impactNotifyId"] >> component.impact_notify_id;
119 component.impact_notify_id.clear();
122 component.attack_range = std::max(component.attack_range, 0.0001f);
123 component.windup_seconds = std::max(component.windup_seconds, 0.0f);
124 component.cooldown_seconds = std::max(component.cooldown_seconds, 0.0f);
125 component.damage_amount = std::max(component.damage_amount, 1);
126 if (component.timing_mode == MeleeAttackTimingMode::Seconds)
128 component.impact_notify_id.clear();
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition melee_attack_component.h:16