X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_water.c;h=dc8206b57218ec989891930351bb1266256e0412;hb=bf13ef74cc454e1e820928484204ac67eb98a308;hp=970ea22a8096111f7064eb16ecc7e8234f1ff1c1;hpb=bececcbb7b2e886e72425e7c070e1fdc3aa126dc;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_water.c b/world_water.c index 970ea22..dc8206b 100644 --- a/world_water.c +++ b/world_water.c @@ -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; +}