target_event_leave: bpy.props.IntProperty( name="Leave Ev", default=-1 )
@staticmethod
- def inspect_target( layout, data, propname, evs = ['_event'] ):#{
+ def inspect_target( layout, data, propname, evs = ['_event'], text='' ):#{
box = layout.box()
- box.prop( data[0], propname )
+ box.prop( data[0], propname, text=text )
for evname in evs:#{
row = box.row()
water_safe: bpy.props.BoolProperty(name="Water is Safe")
no_skating: bpy.props.BoolProperty(name="No Skating")
+ no_rewind: bpy.props.BoolProperty(name="No Rewinding")
@staticmethod
def sr_inspector( layout, data ):
layout.prop( data[0], 'water_safe' )
layout.prop( data[0], 'no_skating' )
+ layout.prop( data[0], 'no_rewind' )
layout.prop( data[0], 'wind_scale' )
layout.prop( data[0], 'skybox' )
#}
first: bpy.props.PointerProperty( \
type=bpy.types.Object, name="First Objective", \
- poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective']))
+ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective','ent_prop']))
camera: bpy.props.PointerProperty( \
type=bpy.types.Object, name="Camera", \
- poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera']))
+ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera','ent_objective']))
@staticmethod
def sr_inspector( layout, data ):#{
layout.prop( data[0], 'alias' )
- layout.prop( data[0], 'camera' )
- layout.prop( data[0], 'first' )
+ layout.prop( data[0], 'camera', text=("Camera" if not data[0].is_story else "Related Objective") )
+ layout.prop( data[0], 'first', text=("First Objective" if not data[0].is_story else "Indicator Prop") )
layout.prop( data[0], 'time_limit' )
layout.prop( data[0], 'is_story' )
- SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target' )
- SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'reset' )
+ SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target', text=("On Activate" if data[0].is_story else "On Complete") )
+ SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'reset', text=("On Finish" if data[0].is_story else "On Reset") )
#}
#}
if obj_data.no_skating:
flags |= 0x4
+ if obj_data.no_rewind:
+ flags |= 0x8
+
worldinfo.flags = flags
worldinfo.pstr_skybox = _af_pack_string( obj_data.skybox )
worldinfo.wind_scale = obj_data.wind_scale
if( press_dpad_e )
render_overlay_mesh( ov_dpad_e );
- colorize( press_dpad_w, !(_world.main.info.flags & k_world_flag_no_skating) );
+ colorize( press_dpad_w, !(_world.main.info.flags & k_world_flag_no_rewind) );
render_overlay_mesh( ov_text_dw_rewind );
if( press_dpad_w )
render_overlay_mesh( ov_dpad_w );
shader_model_menu_uColour( cnorm );
shader_model_menu_uMdl( mmdl );
- colorize( press_r, !(_world.main.info.flags & k_world_flag_no_skating) );
+ colorize( press_r, !(_world.main.info.flags & k_world_flag_no_rewind) );
draw_key( press_r, 0 );
render_overlay_mesh( ov_text_rewind );
vg_info( "challenge( '%s' )\n", af_str( &world->meta.af, challenge->pstr_alias) );
ent_call call;
call.data = NULL;
- call.function = challenge->target_event;
- call.id = challenge->target;
+ call.function = challenge->on_complete_event;
+ call.id = challenge->on_complete_id;
entity_call( world, &call );
}
challenge->status = 1;
gui_helper_reset( 1 );
vg_str text;
if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
- vg_strcat( &text, "View Challenge" );
+ vg_strcat( &text, (challenge->flags & k_ent_challenge_is_story)? "Play video": "View Challenge" );
}
}
return k_entity_call_result_unhandled;
}
+void ent_challenge_visibility( ent_challenge *challenge, bool visible )
+{
+ world_instance *world = &_world.main;
+ if( challenge->indicator_prop_id )
+ {
+ ent_prop *prop = af_arritm( &world->ent_prop, mdl_entity_id_id( challenge->indicator_prop_id ) );
+
+ if( visible ) prop->flags &= ~((u32)k_prop_flag_hidden);
+ else prop->flags |= k_prop_flag_hidden;
+ }
+
+ if( challenge->objective_id )
+ {
+ ent_objective *objective = af_arritm( &world->ent_objective, mdl_entity_id_id( challenge->objective_id ) );
+
+ if( visible ) objective->flags &= ~((u32)k_ent_objective_hidden);
+ else objective->flags |= k_ent_objective_hidden;
+ }
+}
+
void ent_challenge_update(void)
{
+ world_instance *world = &_world.main;
+ for( u32 i=0; i<af_arrcount( &world->ent_challenge); i ++ )
+ {
+ ent_challenge *challenge = af_arritm( &world->ent_challenge, i );
+ if( challenge->flags & k_ent_challenge_is_story )
+ {
+ if( challenge->indicator_prop_id )
+ {
+ ent_prop *prop = af_arritm( &world->ent_prop, mdl_entity_id_id( challenge->indicator_prop_id ) );
+ q_axis_angle( prop->transform.q, (v3f){0,1,0}, vg.time );
+ }
+ }
+ }
+
if( _world.event != k_world_event_challenge )
return;
- world_instance *world = &_world.main;
-
u32 index = mdl_entity_id_id( _world.active_challenge_id );
ent_challenge *challenge = af_arritm( &world->ent_challenge, index );
if( _world.challenge_state == k_challenge_state_viewing )
{
- if( challenge->camera )
+ if( challenge->camera_id )
{
vg_camera temp;
- ent_camera_unpack( af_arritm( &world->ent_camera, mdl_entity_id_id(challenge->camera) ), &temp );
+ ent_camera_unpack( af_arritm( &world->ent_camera, mdl_entity_id_id(challenge->camera_id) ), &temp );
world_set_entity_driven_camera( &temp );
}
menu.disable_open = 0;
srinput.state = k_input_state_resume;
- u32 first_objective_index = mdl_entity_id_id( challenge->first );
+ u32 first_objective_index = mdl_entity_id_id( challenge->first_objective_id );
_world.challenge_target = af_arritm( &world->ent_objective, first_objective_index );
_world.challenge_timer = 0.0f;
- u32 next = challenge->first;
+ u32 next = challenge->first_objective_id;
while( mdl_entity_id_type(next) == k_ent_objective )
{
u32 index = mdl_entity_id_id( next );
{
f32 min_dist2 = 999999.9f;
- if( mdl_entity_id_type( challenge->first ) == k_ent_objective )
+ if( mdl_entity_id_type( challenge->first_objective_id ) == k_ent_objective )
{
- u32 next = challenge->first;
+ u32 next = challenge->first_objective_id;
while( mdl_entity_id_type(next) == k_ent_objective )
{
u32 index = mdl_entity_id_id( next );
gui_helper_reset( k_gui_helper_mode_clear );
ent_call call;
call.data = NULL;
- call.function = challenge->target_event;
- call.id = challenge->target;
+ call.function = challenge->on_activate_event;
+ call.id = challenge->on_activate_id;
entity_call( &_world.main, &call );
}
}
#include "entity.h"
entity_call_result ent_challenge_call( world_instance *world, ent_call *call );
+void ent_challenge_visibility( ent_challenge *challenge, bool visible );
{
k_world_flag_fixed_time = 0x1,
k_world_flag_water_is_safe = 0x2,
- k_world_flag_no_skating = 0x4
+ k_world_flag_no_skating = 0x4,
+ k_world_flag_no_rewind = 0x8
};
struct ent_worldinfo
struct ent_challenge{
mdl_transform transform;
u32 pstr_alias,
- flags,
- target;
- i32 target_event;
+ flags;
+
+ union
+ {
+ u32 on_complete_id,
+ on_activate_id;
+ };
+ union
+ {
+ i32 on_complete_event,
+ on_activate_event;
+ };
+
u32 reset;
i32 reset_event;
- u32 first,
- camera,
- status;
+
+ union
+ {
+ u32 first_objective_id,
+ indicator_prop_id;
+ };
+
+ union
+ {
+ u32 camera_id,
+ objective_id;
+ };
+
+ u32 status;
};
struct ent_relay {
u32 proxy;
};
+enum prop_flag
+{
+ k_prop_flag_hidden = 0x1
+};
+
struct ent_prop {
mdl_transform transform;
u32 submesh_start, submesh_count, flags, pstr_alias;
/* capture the current resume frame at the very last point */
if( button_down( k_srbind_reset ) )
{
- if( _world.main.info.flags & k_world_flag_no_skating )
+ if( _world.main.info.flags & k_world_flag_no_rewind )
{
gui_location_print_ccmd( 1, (const char *[]){ KRED "Rewind is not allowed here.." } );
}
k_script_action_play
};
-static void _skaterift_script_hook_apply_action( u32 script_id,
- enum script_action action )
+static void _skaterift_script_hook_apply_action( u32 script_id, enum script_action action )
{
struct script_info *info = &_script_infos[ script_id ];
info->availible = 1;
if( info->linked_challenge )
+ {
info->linked_challenge->flags &= ~((u32)k_ent_challenge_locked);
+ ent_challenge_visibility( info->linked_challenge, 1 );
+ }
}
if( action == k_script_action_reset )
info->viewed_time = 0;
if( info->linked_challenge )
+ {
info->linked_challenge->flags |= (u32)k_ent_challenge_locked;
+ ent_challenge_visibility( info->linked_challenge, 0 );
+ }
}
if( action == k_script_action_play )
_script.script_id = k_escript_script_id_max;
info->viewed_time = 9999; /* TODO */
+
+ if( info->linked_challenge )
+ ent_challenge_visibility( info->linked_challenge, 0 );
}
if( action == k_script_action_info )
{
script->linked_challenge = challenge;
+ bool hide_linked = 0;
+
if( !script->availible )
{
+ hide_linked = 1;
challenge->flags |= k_ent_challenge_locked;
}
+
+ if( script->viewed_time )
+ hide_linked = 1;
+
+ if( hide_linked )
+ ent_challenge_visibility( challenge, 0 );
}
}
else
{
+ world->events[i].story_script = NULL;
+
u32 result;
vg_msg_getkvintg( sav, alias, k_vg_msg_u32, &result, NULL );
for( u32 j=0; j<af_arrcount( &world->ent_prop ); j++ )
{
ent_prop *prop = af_arritm( &world->ent_prop, j );
- if( prop->flags & k_world_flag_fixed_time )
+ if( prop->flags & k_prop_flag_hidden )
continue;
world_render_submeshes( world, pass, &prop->transform, prop->submesh_start, prop->submesh_count, material_id );
shader_scene_fxglow_uUvOffset( (v2f){ 8.0f/256.0f, 0.0f } );
challenge_list[ challenge_count ++ ] = challenge_index;
- u32 next = challenge->first;
+ u32 next = challenge->first_objective_id;
while( mdl_entity_id_type(next) == k_ent_objective )
{
u32 index = mdl_entity_id_id( next );
/* render texts */
font3d_bind( &gui.font, k_font_shader_world, 0, world, &g_render.cam );
- u32 count = 0;
+ u32 count = 0, total = 0;
for( u32 i=0; i<af_arrcount(&world->ent_challenge); i++ )
{
ent_challenge *challenge = af_arritm( &world->ent_challenge, i );
- if( challenge->status )
- count ++;
+ if( !(challenge->flags & k_ent_challenge_is_story) )
+ {
+ if( challenge->status )
+ count ++;
+ total ++;
+ }
}
char buf[32];
vg_strnull( &str, buf, sizeof(buf) );
vg_strcati32( &str, count );
vg_strcatch( &str, '/' );
- vg_strcati32( &str, af_arrcount(&world->ent_challenge) );
+ vg_strcati32( &str, total );
f32 w = font3d_string_width( 1, buf );
m4x3f mlocal;
for( u32 i=0; i<challenge_count; i++ )
{
u32 index = challenge_list[ i ];
-
ent_challenge *challenge = af_arritm( &world->ent_challenge, index );
+
+ if( challenge->flags & k_ent_challenge_is_story )
+ continue;
+
m4x3f mmdl;
mdl_transform_m4x3( &challenge->transform, mmdl );
m4x3_mul( mmdl, mlocal, mmdl );