option between water plane / water trigger
[carveJwlIkooP6JGAAIwe30JlM.git] / world_water.c
index 970ea22a8096111f7064eb16ecc7e8234f1ff1c1..dc8206b57218ec989891930351bb1266256e0412 100644 (file)
@@ -2,15 +2,15 @@
  * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
  */
 
-#ifndef WATER_C
-#define WATER_C
-
 #include "world_water.h"
 #include "world_render.h"
 #include "render.h"
 #include "shaders/scene_water.h"
 #include "shaders/scene_water_fast.h"
 #include "scene.h"
+#include "player.h"
+#include "player_walk.h"
+#include "player_dead.h"
 
 struct world_water world_water;
 
@@ -225,4 +225,36 @@ void render_water_surface( world_instance *world, vg_camera *cam )
    }
 }
 
-#endif /* WATER_C */
+static void world_water_drown(void)
+{
+   player__networked_sfx( k_player_subsystem_walk, 32, 
+                          k_player_walk_soundeffect_splash,
+                          localplayer.rb.co, 1.0f );
+   vg_info( "player fell of due to walking into walker\n" );
+   player__dead_transition( k_player_die_type_generic );
+}
+
+bool world_water_player_safe( world_instance *world, f32 allowance )
+{
+   if( !world->water.enabled ) return 1;
+   if( world->info.flags & 0x2 ) return 1;
+
+   if( localplayer.rb.co[1]+allowance < world->water.height )
+   {
+      world_water_drown();
+      return 0;
+   }
+
+   return 1;
+}
+
+entity_call_result ent_water_call( world_instance *world, ent_call *call )
+{
+   if( call->function == 0 )
+   {
+      world_water_drown();
+      return k_entity_call_result_OK;
+   }
+
+   return k_entity_call_result_unhandled;
+}