minor performance stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_objective.c
index 68a3dd015f69882562201beadc2111940adeb19d..ff31c4f597beded3cf5a7d9822e8701f59c54b3c 100644 (file)
@@ -4,6 +4,8 @@
 #include "world.h"
 #include "world_load.h"
 #include "entity.h"
+#include "audio.h"
+#include "steam.h"
 
 VG_STATIC void ent_objective_pass( world_instance *world, 
                                    ent_objective *objective ){
@@ -17,13 +19,18 @@ VG_STATIC void ent_objective_pass( world_instance *world,
 
       if( next->filter & k_ent_objective_filter_passthrough )
          ent_objective_pass( world, next );
-      else
+      else{
          vg_info( "pass challenge point\n" );
+         audio_oneshot_3d( &audio_challenge[0], localplayer.rb.co,
+                           30.0f, 1.0f );
+      }
    }
    else {
-      vg_success( "NYU Film school graduate SUCKAH\n" );
+      vg_success( "challenge win\n" );
+      audio_oneshot( &audio_challenge[2], 1.0f, 0.0f );
       world_static.challenge_target = NULL;
       world_static.challenge_timer = 0.0f;
+      world_static.focused_entity = 0;
 
       if( objective->id_win ){
          ent_call call;
@@ -32,6 +39,23 @@ VG_STATIC void ent_objective_pass( world_instance *world,
          call.id = objective->id_win;
          entity_call( world, &call );
       }
+
+      u32 world_completed = 1;
+      for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+         ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+         if( !challenge->status ){
+            world_completed = 0;
+            break;
+         }
+      }
+
+      if( world_completed ){
+         const char *understate = "Understate DIY park";
+         if( mdl_pstreq( &world->meta, world->info.pstr_name, 
+                         understate, vg_strdjb2( understate ))){
+            steam_set_achievement( "CITY_COMPLETE" );
+         }
+      }
    }
 }
 
@@ -82,9 +106,12 @@ VG_STATIC void ent_objective_call( world_instance *world, ent_call *call ){
             ent_objective_pass( world, objective );
          }
          else {
-            vg_error( "womp womp\n" );
+            audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
+                              30.0f, 1.0f );
+            vg_error( "challenge failed\n" );
             world_static.challenge_target = NULL;
             world_static.challenge_timer = 0.0f;
+            world_static.focused_entity = 0;
          }
       }
    }