+ struct logic_relay *relay = &world.logic_relays[ uid ];
+
+ for( int i=0; i<relay->target_count; i++ )
+ {
+ world_run_relay( &relay->targets[i] );
+ }
+}
+
+VG_STATIC void world_trigger_audio( u32 uid )
+{
+ struct world_audio_thing *wat = &world.audio_things[ uid ];
+
+ audio_lock();
+ audio_player_playclip( &wat->player,
+ &wat->temp_embedded_clip );
+ audio_unlock();
+}
+
+VG_STATIC void world_run_relay( struct relay_target *rt )
+{
+ struct entity_instruction
+ {
+ enum classtype classtype;
+ void (*p_trigger)( u32 uid );
+ }
+ entity_instructions[] =
+ {
+ { k_classtype_logic_achievement, world_trigger_achievement },
+ { k_classtype_logic_relay, world_trigger_relay },
+ { k_classtype_audio, world_trigger_audio }
+ };
+
+ for( int i=0; i<vg_list_size(entity_instructions); i++ )
+ {
+ struct entity_instruction *instr = &entity_instructions[i];
+
+ if( instr->classtype == rt->classtype )
+ {
+ instr->p_trigger( rt->sub_id );
+ return;
+ }
+ }
+
+ vg_error( "Don't know how to trigger classtype %d\n", rt->classtype );
+}
+
+VG_STATIC void world_update( v3f pos )
+{
+ if( world.switching_to_new_world )
+ {
+ int all_stopped = 1;
+
+ audio_lock();
+ for( int i=0; i<world.audio_things_count; i++ )
+ {
+ struct world_audio_thing *at = &world.audio_things[i];
+
+ if( audio_player_is_playing( &at->player ) )
+ {
+ all_stopped = 0;
+ break;
+ }
+ }
+ audio_unlock();
+
+ if( all_stopped )
+ {
+ world.switching_to_new_world = 0;
+ world_unload();
+ vg_loader_start( world_load );
+ return;
+ }
+ }
+