unlockables basics
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_relay.c
diff --git a/ent_relay.c b/ent_relay.c
new file mode 100644 (file)
index 0000000..60144ab
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef ENT_RELAY_C
+#define ENT_RELAY_C
+
+#include "entity.h"
+
+VG_STATIC void ent_relay_call( world_instance *world, ent_call *call ){
+   u32 index = mdl_entity_id_id( call->id );
+   ent_relay *relay = mdl_arritm( &world->ent_relay, index );
+
+   if( call->function == 0 ){
+      for( u32 i=0; i<vg_list_size(relay->targets); i++ ){
+         if( relay->targets[i][0] ){
+            ent_call call;
+            call.data = NULL;
+            call.function = relay->targets[i][1];
+            call.id = relay->targets[i][0];
+            entity_call( world, &call );
+         }
+      }
+   }
+   else {
+      vg_print_backtrace();
+      vg_error( "Unhandled function id: %u\n", call->function );
+   }
+}
+
+#endif /* ENT_RELAY_C */