# HG changeset patch # User Mike Becker # Date 1760029412 -7200 # Node ID 9988e327176fe25f90e29449023c0ef1c259dbe2 # Parent 789215559ea82c39b5359082b22135cbef088ed0 add asc_behavior_find() diff -r 789215559ea8 -r 9988e327176f src/ascension/behavior.h --- 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 + 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 * diff -r 789215559ea8 -r 9988e327176f src/behavior.c --- 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);