spawns[32];
u32 spawn_count;
+ struct world_audio_thing
+ {
+ v3f pos;
+ float volume;
+ u32 flags;
+
+ audio_player player;
+ audio_clip temp_embedded_clip;
+ }
+ * audio_things;
+
+ u32 audio_things_count,
+ audio_things_cap;
+
+ struct achievement_zone
+ {
+ m4x3f transform, inv_transform;
+ char name[32];
+ int triggered;
+
+ union
+ {
+ mdl_node *ptarget_delegated;
+ struct world_audio_thing *ptarget;
+ };
+ }
+ * achievement_zones;
+
+ u32 achievement_zones_count,
+ achievement_zones_cap;
+
struct subworld_routes
{
struct route_node
}
*routes;
- double last_interaction;
+ double time, rewind_from, rewind_to, last_use;
u32 route_count,
route_cap;
#if 0
traffic_driver van_man[6];
#endif
+
+ double sky_time, sky_rate, sky_target_rate;
/* Physics */
v3f render_gate_pos;
int active_route_board;
}
-world;
+world ;
/*
* API
static void world_init(void)
{
+ world.sky_rate = 1.0;
+ world.sky_target_rate = 1.0;
+
shader_terrain_register();
shader_sky_register();
shader_planeinf_register();
{
mesh_free( &world.cars );
mesh_free( &world.skydome );
+ vg_free( world.achievement_zones );
+
+ /* FIXME: This fucks with the audio player. Use-after-free */
+#if 0
+ vg_free( world.audio_things );
+#endif
}
static void world_update( v3f pos )
{
+ world.sky_time += world.sky_rate * vg.time_delta;
+ world.sky_rate = vg_lerp( world.sky_rate, world.sky_target_rate,
+ vg.time_delta * 5.0 );
+
world_routes_update();
#if 0
world_routes_debug();
}
}
}
+
+ static int in_zone = 0;
+
+ int in_zone_this_time = 0;
+
+ for( int i=0; i<world.achievement_zones_count; i++ )
+ {
+ struct achievement_zone *zone = &world.achievement_zones[i];
+
+ v3f local;
+ m4x3_mulv( zone->inv_transform, pos, local );
+
+ if( (fabsf(local[0]) <= 1.0f) &&
+ (fabsf(local[1]) <= 1.0f) &&
+ (fabsf(local[2]) <= 1.0f) )
+ {
+ in_zone_this_time = 1;
+
+ if( !in_zone && zone->ptarget )
+ {
+ audio_lock();
+ audio_player_playclip( &zone->ptarget->player,
+ &zone->ptarget->temp_embedded_clip );
+ audio_unlock();
+ }
+
+ if( !zone->triggered )
+ {
+ steam_set_achievement( zone->name );
+ steam_store_achievements();
+ }
+
+ zone->triggered = 1;
+ }
+
+ vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f},
+ { 1.0f, 1.0f, 1.0f}},
+ 0xff00ff00 );
+ }
+
+ in_zone = in_zone_this_time;
sfd_update( &world.sfd.tester );
}