src/behavior.c

changeset 148
9f030f402699
parent 114
5b91bbab1ac0
--- a/src/behavior.c	Fri Jun 13 17:45:19 2025 +0200
+++ b/src/behavior.c	Fri Jun 13 18:09:49 2025 +0200
@@ -26,6 +26,7 @@
  */
 
 #include "ascension/behavior.h"
+#include "ascension/context.h"
 #include "ascension/error.h"
 #include "ascension/scene.h"
 
@@ -61,5 +62,15 @@
     behavior->func = args.func;
     behavior->destroy_func = args.destroy_func;
     behavior->data = args.data;
+    behavior->interval = args.interval;
+    behavior->last_execution = 0;
     return behavior;
 }
+
+void asc_behavior_trigger(AscBehavior *behavior) {
+    if (!behavior->enabled) return;
+    if (behavior->last_execution + behavior->interval > asc_context.total_nanos) return;
+
+    behavior->func(behavior);
+    behavior->last_execution = asc_context.total_nanos;
+}
\ No newline at end of file

mercurial