Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AnimationHelpers.h
Go to the documentation of this file.
1/**
2 * @file AnimationHelpers.h
3 * @brief Helper functions for manipulating VisualAnimation_data components
4 * @author Olympe Engine - Animation System
5 * @date 2025
6 *
7 * Provides utility functions to set/get animation graph parameters
8 * without violating ECS principles (components remain pure data).
9 */
10
11#pragma once
12
13#include "../ECS_Components.h"
14#include <string>
15
16namespace Olympe
17{
18namespace AnimationHelpers
19{
20 // ========================================================================
21 // Parameter Setters (overloaded)
22 // ========================================================================
23
24 /**
25 * @brief Set float parameter value
26 */
27 inline void SetParameter(VisualAnimation_data& animData, const std::string& name, float value)
28 {
29 animData.floatParams[name] = value;
30 }
31
32 /**
33 * @brief Set bool parameter value
34 */
35 inline void SetParameter(VisualAnimation_data& animData, const std::string& name, bool value)
36 {
37 animData.boolParams[name] = value;
38 }
39
40 /**
41 * @brief Set int parameter value
42 */
43 inline void SetParameter(VisualAnimation_data& animData, const std::string& name, int value)
44 {
45 animData.intParams[name] = value;
46 }
47
48 // ========================================================================
49 // Parameter Getters
50 // ========================================================================
51
52 /**
53 * @brief Get float parameter value with default
54 */
55 inline float GetFloatParameter(const VisualAnimation_data& animData, const std::string& name, float defaultValue = 0.0f)
56 {
57 auto it = animData.floatParams.find(name);
58 return (it != animData.floatParams.end()) ? it->second : defaultValue;
59 }
60
61 /**
62 * @brief Get bool parameter value with default
63 */
64 inline bool GetBoolParameter(const VisualAnimation_data& animData, const std::string& name, bool defaultValue = false)
65 {
66 auto it = animData.boolParams.find(name);
67 return (it != animData.boolParams.end()) ? it->second : defaultValue;
68 }
69
70 /**
71 * @brief Get int parameter value with default
72 */
73 inline int GetIntParameter(const VisualAnimation_data& animData, const std::string& name, int defaultValue = 0)
74 {
75 auto it = animData.intParams.find(name);
76 return (it != animData.intParams.end()) ? it->second : defaultValue;
77 }
78
79 // ========================================================================
80 // Parameter Management
81 // ========================================================================
82
83 /**
84 * @brief Check if parameter exists (any type)
85 */
86 inline bool HasParameter(const VisualAnimation_data& animData, const std::string& name)
87 {
88 return animData.floatParams.count(name) > 0 ||
89 animData.boolParams.count(name) > 0 ||
90 animData.intParams.count(name) > 0;
91 }
92
93 /**
94 * @brief Clear all parameters
95 */
97 {
98 animData.floatParams.clear();
99 animData.boolParams.clear();
100 animData.intParams.clear();
101 }
102
103} // namespace AnimationHelpers
104} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
bool GetBoolParameter(const VisualAnimation_data &animData, const std::string &name, bool defaultValue=false)
Get bool parameter value with default.
int GetIntParameter(const VisualAnimation_data &animData, const std::string &name, int defaultValue=0)
Get int parameter value with default.
void ClearParameters(VisualAnimation_data &animData)
Clear all parameters.
float GetFloatParameter(const VisualAnimation_data &animData, const std::string &name, float defaultValue=0.0f)
Get float parameter value with default.
void SetParameter(VisualAnimation_data &animData, const std::string &name, float value)
Set float parameter value.
bool HasParameter(const VisualAnimation_data &animData, const std::string &name)
Check if parameter exists (any type)
ECS component for animated sprites.