unlockables basics
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_unlock.c
diff --git a/ent_unlock.c b/ent_unlock.c
new file mode 100644 (file)
index 0000000..8a266ae
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef ENT_UNLOCK_C
+#define ENT_UNLOCK_C
+
+#include "entity.h"
+
+VG_STATIC void ent_unlock_call( world_instance *world, ent_call *call ){
+   u32 index = mdl_entity_id_id( call->id );
+   ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+
+   if( call->function == 0 ){ /* unlock() */
+      if( !unlock->status ){
+         vg_info( "unlock( '%s' )\n", 
+                  mdl_pstr( &world->meta, unlock->pstr_alias) );
+         ent_call call;
+         call.data = NULL;
+         call.function = unlock->target_event;
+         call.id = unlock->target;
+         entity_call( world, &call );
+      }
+      unlock->status = 1;
+   }
+   else {
+      vg_print_backtrace();
+      vg_error( "Unhandled function id: %u\n", call->function );
+   }
+}
+
+#endif /* ENT_UNLOCK_C */