update helpers/location to 'frosted' ui
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_objective.c
index 97e33d8cb5c54caf922fc167348a3b595c6f10eb..6a8bbe5bef6a2afb3224cc388e1fd101fbbc97e7 100644 (file)
@@ -1,11 +1,11 @@
-#ifndef ENT_OBJECTIVE_C
-#define ENT_OBJECTIVE_C
-
 #include "world.h"
 #include "world_load.h"
 #include "entity.h"
 #include "audio.h"
 #include "steam.h"
+#include "ent_region.h"
+#include "player.h"
+#include "player_skate.h"
 
 static void ent_objective_pass( world_instance *world, 
                                    ent_objective *objective ){
@@ -44,23 +44,7 @@ static void ent_objective_pass( world_instance *world,
          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" );
-            steam_store_achievements();
-         }
-      }
+      ent_region_re_eval( world );
    }
 }
 
@@ -97,20 +81,26 @@ static int ent_objective_check_filter( ent_objective *objective ){
    }
 }
 
-static void ent_objective_call( world_instance *world, ent_call *call ){
+entity_call_result ent_objective_call( world_instance *world, ent_call *call )
+{
    u32 index = mdl_entity_id_id( call->id );
    ent_objective *objective = mdl_arritm( &world->ent_objective, index );
 
-   if( call->function == 0 ){
-      if( objective->flags & (k_ent_objective_hidden|
-                              k_ent_objective_passed)) return;
+   if( call->function == 0 )
+   {
+      if( objective->flags & (k_ent_objective_hidden|k_ent_objective_passed))
+      {
+         return k_entity_call_result_OK;
+      }
 
-      if( world_static.challenge_target ){
+      if( world_static.challenge_target )
+      {
          if( (world_static.challenge_target == objective) && 
               ent_objective_check_filter( objective )){
             ent_objective_pass( world, objective );
          }
-         else {
+         else 
+         {
             audio_lock();
             audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
                               30.0f, 1.0f );
@@ -121,27 +111,29 @@ static void ent_objective_call( world_instance *world, ent_call *call ){
             world_static.focused_entity = 0;
          }
       }
+
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 2 ){
+   else if( call->function == 2 )
+   {
       objective->flags &= ~k_ent_objective_hidden;
 
       if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
          call->id = objective->id_next;
          entity_call( world, call );
       }
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 3 ){
+   else if( call->function == 3 )
+   {
       objective->flags |=  k_ent_objective_hidden;
 
       if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
          call->id = objective->id_next;
          entity_call( world, call );
       }
+      return k_entity_call_result_OK;
    }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
+   else 
+      return k_entity_call_result_unhandled;
 }
-
-#endif /* ENT_OBJECTIVE_C */