src/behavior.c

changeset 176
cb2f60f48337
parent 162
d3598c834f9b
--- a/src/behavior.c	Wed Jul 02 23:55:50 2025 +0200
+++ b/src/behavior.c	Thu Jul 03 23:01:52 2025 +0200
@@ -55,6 +55,7 @@
     AscBehavior *behavior = cxListEmplace(node->behaviors);
     assert(behavior != NULL);
     behavior->enabled = true;
+    behavior->killed = false;
     behavior->node = node;
     behavior->func = args.func;
     behavior->destroy_func = args.destroy_func;
@@ -64,8 +65,14 @@
     return behavior;
 }
 
+void asc_behavior_remove(AscBehavior *behavior) {
+    // TODO: implement some sort of ID for behaviors which can also be used for logging
+    behavior->killed = true;
+    behavior->enabled = false;
+}
+
 void asc_behavior_trigger(AscBehavior *behavior) {
-    if (!behavior->enabled) return;
+    assert(behavior->enabled);
     if (behavior->last_execution + behavior->interval > asc_context.total_nanos) return;
 
     behavior->func(behavior);

mercurial