#include "ent_region.h"
#include "ent_glider.h"
#include "ent_npc.h"
+#include "world_water.h"
+
+#include <string.h>
void entity_call( world_instance *world, ent_call *call )
{
[k_ent_miniworld] = ent_miniworld_call,
[k_ent_region] = ent_region_call,
[k_ent_glider] = ent_glider_call,
- [k_ent_npc] = ent_npc_call
+ [k_ent_npc] = ent_npc_call,
+ [k_ent_water] = ent_water_call,
};
if( type >= vg_list_size(table) ){
ent_marker *ent_find_marker( mdl_context *mdl, mdl_array_ptr *arr,
const char *alias )
{
- for( u32 i=0; i<mdl_arrcount(arr); i++ ){
+ for( u32 i=0; i<mdl_arrcount(arr); i++ )
+ {
ent_marker *marker = mdl_arritm( arr, i );
- if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
+ if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) )
+ {
return marker;
}
}
v2f steer;
joystick_state( k_srjoystick_steer, steer );
- if( glider_physics( steer ) ){
+ if( glider_physics( steer ) )
+ {
vg_info( "player fell off due to glider hitting ground\n" );
player__dead_transition( k_player_die_type_generic );
localplayer.glider_orphan = 1;
}
+
+ if( !world_water_player_safe( world_current_instance(), 1.0f ) )
+ return;
}
void player_glide_post_update(void)
struct player_skate_state *state = &player_skate.state;
world_instance *world = world_current_instance();
- if( state->activity == k_skate_activity_handplant ){
+ if( state->activity == k_skate_activity_handplant )
return;
- }
- if( world->water.enabled ){
- if( localplayer.rb.co[1]+0.25f < world->water.height ){
- vg_info( "player fell off due to being in water\n" );
- player__networked_sfx( k_player_subsystem_walk, 32,
- k_player_walk_soundeffect_splash,
- localplayer.rb.co, 1.0f );
- player__dead_transition( k_player_die_type_generic );
- return;
- }
- }
+ if( !world_water_player_safe( world, 0.25f ) ) return;
v3_copy( localplayer.rb.co, state->prev_pos );
state->activity_prev = state->activity;
v3_zero( localplayer.rb.w );
world_instance *world = world_current_instance();
-
- if( world->water.enabled ){
- if( localplayer.rb.co[1]+0.4f < world->water.height ){
- 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 );
- return;
- }
- }
+ if( !world_water_player_safe( world, 0.4f ) ) return;
enum walk_activity prev_state = w->state.activity;
SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_challenge', \
'ent_relay', 'ent_skateshop', 'ent_objective', 'ent_route',\
'ent_miniworld', 'ent_region', 'ent_glider', 'ent_list',\
- 'ent_npc' ]
+ 'ent_npc', 'ent_water' ]
def get_entity_enum_id( alias ):
#{
("max_dist",c_float),
("reserved0",c_uint32),
("reserved1",c_uint32)]
+ sr_functions = { 0: "drown" }
#}
class volume_trigger(Structure):
else:
worldinfo.timezone = obj_data.timezone
+ if obj_data.water_safe:
+ flags |= 0x2
+
worldinfo.flags = flags
worldinfo.pstr_skybox = sr_compile_string( obj_data.skybox )
sr_ent_push( worldinfo )
timezone: bpy.props.FloatProperty(name="Timezone(hrs) (UTC0 +hrs)")
fixed_time: bpy.props.FloatProperty(name="Fixed Time (0-1)")
+ water_safe: bpy.props.BoolProperty(name="Water is Safe")
+
@staticmethod
- def sr_inspector( layout, data ):#{
+ def sr_inspector( layout, data ):
+ #{
layout.prop( data[0], 'name' )
layout.prop( data[0], 'desc' )
layout.prop( data[0], 'author' )
layout.prop( data[0], 'fixed_time' )
else:
layout.prop( data[0], 'timezone' )
+
+ layout.prop( data[0], 'water_safe' )
#}
#}
else return world->textures[ id ];
}
-#if 0
-static void bindpoint_diffuse_texture1( world_instance *world,
- struct world_surface *mat ){
- glActiveTexture( GL_TEXTURE1 );
- glBindTexture( GL_TEXTURE_2D,
- world_get_texture(world,mat->info.tex_diffuse) );
-}
-#endif
-
/*
* Passes Rendering
* ----------------------------------------------------------------------------
* 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;
}
}
-#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;
+}
void water_set_surface( world_instance *world, f32 height );
void render_water_texture( world_instance *world, vg_camera *cam );
void render_water_surface( world_instance *world, vg_camera *cam );
+entity_call_result ent_water_call( world_instance *world, ent_call *call );
+bool world_water_player_safe( world_instance *world, f32 allowance );