2 #include "ent_miniworld.h"
3 #include "world_render.h"
4 #include "world_load.h"
10 struct global_miniworld global_miniworld
;
12 void ent_miniworld_call( world_instance
*world
, ent_call
*call
)
14 ent_miniworld
*miniworld
= mdl_arritm( &world
->ent_miniworld
,
15 mdl_entity_id_id(call
->id
) );
17 int world_id
= world
- world_static
.instances
;
19 if( call
->function
== 0 ){ /* zone() */
20 const char *uid
= mdl_pstr( &world
->meta
, miniworld
->pstr_world
);
21 skaterift_load_world_command( 1, (const char *[]){ uid
} );
23 mdl_transform_m4x3( &miniworld
->transform
, global_miniworld
.mmdl
);
24 global_miniworld
.active
= miniworld
;
29 if( gui_new_helper( input_button_list
[k_srbind_miniworld_resume
], &text
))
30 vg_strcat( &text
, "Enter World" );
32 else if( call
->function
== 1 ){
33 global_miniworld
.active
= NULL
;
36 if( miniworld
->proxy
){
37 ent_prop
*prop
= mdl_arritm( &world
->ent_prop
,
38 mdl_entity_id_id(miniworld
->proxy
) );
44 static void miniworld_icon( vg_camera
*cam
, enum gui_icon icon
,
48 v3_copy( cam
->transform
[2], mmdl
[2] );
50 v3_normalize( mmdl
[2] );
51 v3_copy( (v3f
){0,1,0}, mmdl
[1] );
52 v3_cross( mmdl
[1], mmdl
[2], mmdl
[0] );
53 m4x3_mulv( global_miniworld
.mmdl
, pos
, mmdl
[3] );
55 shader_model_font_uMdl( mmdl
);
56 shader_model_font_uOffset( (v4f
){0,0,0,20.0f
*size
} );
59 m4x3_expand( mmdl
, m4mdl
);
60 m4x4_mul( cam
->mtx_prev
.pv
, m4mdl
, m4mdl
);
61 shader_model_font_uPvmPrev( m4mdl
);
63 mdl_submesh
*sm
= gui
.icons
[ icon
];
65 mdl_draw_submesh( sm
);
68 void ent_miniworld_render( world_instance
*host_world
, vg_camera
*cam
)
70 if( host_world
!= &world_static
.instances
[k_world_purpose_hub
] )
73 ent_miniworld
*miniworld
= global_miniworld
.active
;
78 world_instance
*dest_world
= &world_static
.instances
[k_world_purpose_client
];
81 if( dest_world
->status
!= k_world_status_loaded
)
84 if( miniworld
->proxy
){
85 ent_prop
*prop
= mdl_arritm( &host_world
->ent_prop
,
86 mdl_entity_id_id(miniworld
->proxy
) );
97 render_world_override( dest_world
, host_world
, global_miniworld
.mmdl
, cam
,
98 NULL
, (v4f
){dest_world
->tar_min
,10000.0f
,0.0f
,0.0f
} );
99 render_world_routes( dest_world
, host_world
,
100 global_miniworld
.mmdl
, cam
, 0, 1 );
103 * ---------------------*/
104 font3d_bind( &gui
.font
, k_font_shader_default
, 0, NULL
, cam
);
105 mesh_bind( &gui
.icons_mesh
);
107 glActiveTexture( GL_TEXTURE0
);
108 glBindTexture( GL_TEXTURE_2D
, gui
.icons_texture
);
109 shader_model_font_uTexMain( 0 );
110 shader_model_font_uColour( (v4f
){1,1,1,1} );
112 miniworld_icon( cam
, k_gui_icon_player
, dest_world
->player_co
,
113 1.0f
+ sinf(vg
.time
)*0.2f
);
115 for( u32 i
=0; i
<mdl_arrcount(&dest_world
->ent_challenge
); i
++ ){
116 ent_challenge
*challenge
= mdl_arritm( &dest_world
->ent_challenge
, i
);
118 enum gui_icon icon
= k_gui_icon_exclaim
;
119 if( challenge
->status
)
120 icon
= k_gui_icon_tick
;
122 miniworld_icon( cam
, icon
, challenge
->transform
.co
, 1.0f
);
125 for( u32 i
=0; i
<mdl_arrcount(&dest_world
->ent_route
); i
++ ){
126 ent_route
*route
= mdl_arritm( &dest_world
->ent_route
, i
);
128 if( route
->flags
& k_ent_route_flag_achieve_gold
){
129 miniworld_icon( cam
, k_gui_icon_rift_run_gold
,
130 route
->board_transform
[3],1.0f
);
132 else if( route
->flags
& k_ent_route_flag_achieve_silver
){
133 miniworld_icon( cam
, k_gui_icon_rift_run_silver
,
134 route
->board_transform
[3],1.0f
);
138 for( u32 i
=0; i
<mdl_arrcount(&dest_world
->ent_route
); i
++ ){
139 ent_route
*route
= mdl_arritm( &dest_world
->ent_route
, i
);
142 v4_copy( route
->colour
, colour
);
143 v3_muls( colour
, 1.6666f
, colour
);
144 shader_model_font_uColour( colour
);
145 miniworld_icon( cam
, k_gui_icon_rift_run
, route
->board_transform
[3],1.0f
);
149 void ent_miniworld_preupdate(void)
151 world_instance
*hub
= world_current_instance(),
152 *dest
= &world_static
.instances
[k_world_purpose_client
];
154 ent_miniworld
*miniworld
= global_miniworld
.active
;
156 if( (localplayer
.subsystem
!= k_player_subsystem_walk
) ||
157 (global_miniworld
.transition
) ||
158 (world_static
.active_instance
!= k_world_purpose_hub
) ||
160 (dest
->status
!= k_world_status_loaded
) ||
161 (skaterift
.activity
!= k_skaterift_default
)) {
165 if( button_down( k_srbind_miniworld_resume
) ){
166 if( skaterift
.demo_mode
){
167 if( world_static
.instance_addons
[1]->flags
& ADDON_REG_PREMIUM
){
168 skaterift
.activity
= k_skaterift_menu
;
169 menu
.page
= 0xffffffff;
170 menu_open_page( "Premium", k_ent_menuitem_stack_append
);
175 global_miniworld
.transition
= 1;
176 global_miniworld
.t
= 0.0f
;
177 global_miniworld
.cam
= skaterift
.cam
;
179 world_switch_instance(1);
180 srinput
.state
= k_input_state_resume
;
181 menu
.disable_open
= 0;
184 audio_oneshot( &audio_ui
[2], 1.0f
, 0.0f
);
189 void ent_miniworld_goback(void)
192 audio_oneshot( &audio_ui
[2], 1.0f
, 0.0f
);
195 global_miniworld
.transition
= -1;
196 global_miniworld
.t
= 1.0f
;
198 global_miniworld
.cam
= skaterift
.cam
;
199 vg_m4x3_transform_camera( global_miniworld
.mmdl
, &global_miniworld
.cam
);
200 world_switch_instance(0);