Thu, 09 Oct 2025 19:03:32 +0200
add asc_behavior_find()
src/ascension/behavior.h | file | annotate | diff | comparison | revisions | |
src/behavior.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/behavior.h Fri Sep 26 22:44:42 2025 +0200 +++ b/src/ascension/behavior.h Thu Oct 09 19:03:32 2025 +0200 @@ -31,6 +31,8 @@ #include "scene_node.h" +#include <cx/string.h> + typedef struct asc_behavior_s AscBehavior; typedef void(*asc_behavior_func)(AscBehavior*); @@ -117,6 +119,17 @@ */ cxstring asc_behavior_get_name(const AscBehavior *behavior); +AscBehavior *asc_behavior_find_(const AscSceneNode *node, cxstring name); + +/** + * Finds a behavior with the specified name. + * + * @param node the node with the expected behavior + * @param name the name of the behavior + * @return the behavior or @c NULL when the node has no behavior with that name + */ +#define asc_behavior_find(node, name) asc_behavior_find_(node, cx_strcast(name)) + /** * Enables a behavior *
--- a/src/behavior.c Fri Sep 26 22:44:42 2025 +0200 +++ b/src/behavior.c Thu Oct 09 19:03:32 2025 +0200 @@ -95,7 +95,9 @@ return cx_strcast(behavior->name); } -// TODO: add asc_behavior_find() and asc_behavior_find_global() +AscBehavior *asc_behavior_find_(const AscSceneNode *node, cxstring name) { + return cxMapGet(node->behaviors, name); +} void asc_behavior_enable_all(AscSceneNode *node) { CxMapIterator iter = cxMapIteratorValues(node->behaviors);