process triggers on leave world
authorhgn <hgodden00@gmail.com>
Sun, 19 Nov 2023 08:14:09 +0000 (08:14 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 19 Nov 2023 08:14:09 +0000 (08:14 +0000)
ent_miniworld.c
maps_src/dev_hub/main.mdl
player.c
skaterift.c
world.c
world.h

index 54ce8ae5c6782752897d639da0014fbad417430e..cd79b4552626ca5dda89aac1bbcd0b7d1ef63419 100644 (file)
@@ -1,6 +1,7 @@
 #include "entity.h"
 #include "ent_miniworld.h"
 #include "world_render.h"
+#include "input.h"
 
 static void ent_miniworld_call( world_instance *world, ent_call *call ){
    ent_miniworld *miniworld = mdl_arritm( &world->ent_miniworld, 
@@ -63,3 +64,12 @@ static void ent_miniworld_render( world_instance *host_world ){
 
    //render_world_routes( , &skaterift.cam, 1 );
 }
+
+static void ent_miniworld_preupdate(void){
+   if( !global_miniworld.active_id )
+      return;
+
+   if( button_down( k_srbind_use ) ){
+      
+   }
+}
index deae0e2fd6a1888498422b2e5643d600e58ae432..44881ec7bc8479d5396fa4b862340299f7b9df14 100644 (file)
Binary files a/maps_src/dev_hub/main.mdl and b/maps_src/dev_hub/main.mdl differ
index 348bb744d540b8ec4d0c3814a72c864a86c5b208..fce9c488aaabf58f4e341881d497de9ede7c296e 100644 (file)
--- a/player.c
+++ b/player.c
@@ -251,7 +251,6 @@ static void player__reset(void){
    world_static.focused_entity = 0;
    world_static.active_trigger_volume_count = 0;
    world_static.last_use = 0.0;
-   global_miniworld.active_id = 0;
    world_entity_unfocus();
 
    localplayer.boundary_hash ^= NETMSG_BOUNDARY_BIT;
index 8ed749ceb324087ed31b773be3fd4d6e49636715..a2b8347ecb673802e1d02eb3ede6d292934c07e8 100644 (file)
@@ -337,6 +337,7 @@ static void vg_pre_update(void){
    world_entity_focus_preupdate();
    skaterift_replay_pre_update();
    remote_sfx_pre_update();
+   ent_miniworld_preupdate();
 
    world_update( world_current_instance(), localplayer.rb.co );
    audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co );
diff --git a/world.c b/world.c
index def59a36b3edec09d1fe06aa2a9e1a2c4dd34886..ad0372389a54eaff63cdbdb0011098a1877c2915 100644 (file)
--- a/world.c
+++ b/world.c
@@ -41,18 +41,33 @@ static void world_switch_instance( u32 index ){
       return;
    }
 
+   world_instance *current = 
+      &world_static.instances[ world_static.active_instance ];
+
    if( index != world_static.active_instance ){
-      world_instance *current = 
-         &world_static.instances[ world_static.active_instance ];
       v3_copy( localplayer.rb.co, current->player_co );
       v3_copy( localplayer.angles, current->player_angles );
+      v3_copy( localplayer.cam.pos, current->cam_co );
       current->player_angles[3] = player_get_heading_yaw();
    }
 
    v3_copy( new->player_co, localplayer.rb.co );
    v3_copy( new->player_angles, localplayer.angles );
+   v3_copy( new->cam_co, localplayer.cam.pos );
    q_axis_angle( localplayer.rb.q, (v3f){0,1,0}, new->player_angles[3] );
 
+   /* run exit events on triggers */
+   for( u32 i=0; i<world_static.active_trigger_volume_count; i++ ){
+      i32 idx = world_static.active_trigger_volumes[i];
+      ent_volume *volume = mdl_arritm( &current->ent_volume, idx );
+
+      ent_call basecall;
+      basecall.function = k_ent_function_trigger_leave;
+      basecall.id = mdl_entity_id( k_ent_volume, idx );
+      basecall.data = NULL;
+      entity_call( current, &basecall );
+   }
+
    world_static.active_instance = index;
 
    player__reset();
diff --git a/world.h b/world.h
index dde9aea83048a93f26a4f0227c0464df69132fb7..0efe185087d5b5087098117ad86397a5a2eeb6e3 100644 (file)
--- a/world.h
+++ b/world.h
@@ -64,6 +64,7 @@ struct world_instance {
     */
 
    v4f player_co, player_angles;
+   v3f cam_co;
 
    void *heap;
    enum world_status{