77#include " zRenderState.h"
88#include " zEntPlayerBungeeState.h"
99#include " zEntCruiseBubble.h"
10+ #include " zGameState.h"
11+ #include " xScrFx.h"
1012
1113#include < types.h>
1214#include < rwplcore.h>
@@ -1109,11 +1111,100 @@ namespace oob_state
11091111
11101112 state_enum grab_state_type::update (xScene& scene, F32& dt)
11111113 {
1112- return STATE_DROP;
1114+ if (shared.model == NULL )
1115+ {
1116+ return STATE_DROP;
1117+ }
1118+
1119+ F32 movedt = dt;
1120+ while (this ->move_substate != SS_INVALID)
1121+ {
1122+ substate_enum newstate = this ->updatess [this ->move_substate ](*this , scene, movedt);
1123+ if (newstate == this ->move_substate )
1124+ {
1125+ break ;
1126+ }
1127+
1128+ this ->move_substate = newstate;
1129+ }
1130+
1131+ F32 fadedt = dt;
1132+ while (this ->fade_substate != SS_INVALID)
1133+ {
1134+ substate_enum newstate = this ->updatess [this ->fade_substate ](*this , scene, fadedt);
1135+ if (newstate == this ->fade_substate )
1136+ {
1137+ break ;
1138+ }
1139+
1140+ this ->fade_substate = newstate;
1141+ }
1142+
1143+ if (this ->move_substate == SS_INVALID && this ->fade_substate == SS_INVALID)
1144+ {
1145+ if (this ->scene_reset )
1146+ {
1147+ return STATE_DROP;
1148+ }
1149+
1150+ this ->scene_reset = TRUE ;
1151+ zGameStateSwitch (0x2 );
1152+ }
1153+
1154+ if (this ->move_substate == SS_STARTING || this ->move_substate == SS_MOVING_OUT)
1155+ {
1156+ xMat4x3& pm = *(xMat4x3*)globals.player .ent .model ->Mat ;
1157+ pm.pos = this ->player_start ;
1158+
1159+ move_up (pm.pos , fixed.in_loc .y - shared.loc .y );
1160+ move_right (pm.pos , fixed.in_loc .x - shared.loc .x );
1161+ }
1162+
1163+ xModelEval (globals.player .ent .model );
1164+ zEntPlayerUpdateModel ();
1165+ return STATE_GRAB;
11131166 }
11141167
11151168 void drop_state_type::start ()
11161169 {
1170+ this ->player_start = globals.player .cp .pos ;
1171+ this ->move_substate = shared.model != NULL ? SS_MOVING_IN : SS_INVALID;
1172+
1173+ shared.vel = fixed.drop .in_vel ;
1174+ shared.accel = 0 .0f ;
1175+ shared.loc .x = fixed.in_loc .x ;
1176+ shared.loc .y = fixed.in_loc .y ;
1177+
1178+ this ->fade_substate = SS_START_FADE_IN;
1179+ this ->fade_start_time = fixed.drop .fade_start_time ;
1180+ this ->fade_time = fixed.drop .fade_time ;
1181+
1182+ xEnt& p = globals.player .ent ;
1183+ zEntPlayerReset (&p);
1184+ zEntPlayerUpdateModel ();
1185+ zEntPlayerControlOff (CONTROL_OWNER_OOB);
1186+ globals.player .ControlOffTimer = FLOAT_MAX;
1187+ xScrFxStopFade ();
1188+ zCameraDisableInput ();
1189+
1190+ xModelInstance& m = *p.model ;
1191+ xEntFrame& f = *p.frame ;
1192+
1193+ f.rot .axis = g_Y3;
1194+ f.rot .angle = globals.player .cp .rot ;
1195+ f.vel = g_O3;
1196+
1197+ xMat3x3Euler (&f.mat , f.rot .angle , 0 .0f , 0 .0f );
1198+ f.mat .pos = globals.player .cp .pos ;
1199+ *(xMat4x3*)m.Mat = f.mat ;
1200+
1201+ shared_target.pos = *(xVec3*)&m.Mat ->pos ;
1202+
1203+ set_camera (true );
1204+ globals.camera .tgt_mat = &shared_target;
1205+ globals.camera .tgt_omat = &shared_target;
1206+ xCameraMove (&globals.camera , 0x20 , fixed.cam_dist , fixed.cam_height , PI + globals.player .cp .rot , 0 .0f , 0 .0f , 0 .0f );
1207+ xCameraLookYPR (&globals.camera , 0x0 , globals.player .cp .rot , fixed.cam_pitch , 0 .0f , 0 .0f , 0 .0f , 0 .0f );
11171208 }
11181209
11191210 void drop_state_type::stop ()
@@ -1130,6 +1221,54 @@ namespace oob_state
11301221
11311222 state_enum drop_state_type::update (xScene& scene, F32& dt)
11321223 {
1224+ if (shared.model == NULL )
1225+ {
1226+ return STATE_IN;
1227+ }
1228+
1229+ F32 movedt = dt;
1230+ while (this ->move_substate != SS_INVALID)
1231+ {
1232+ substate_enum newstate = this ->updatess [this ->move_substate ](*this , scene, movedt);
1233+ if (newstate == this ->move_substate )
1234+ {
1235+ break ;
1236+ }
1237+
1238+ this ->move_substate = newstate;
1239+ }
1240+
1241+ F32 fadedt = dt;
1242+ while (this ->fade_substate != SS_INVALID)
1243+ {
1244+ substate_enum newstate = this ->updatess [this ->fade_substate ](*this , scene, fadedt);
1245+ if (newstate == this ->fade_substate )
1246+ {
1247+ break ;
1248+ }
1249+
1250+ this ->fade_substate = newstate;
1251+ }
1252+
1253+ if (this ->move_substate == SS_INVALID && this ->fade_substate == SS_INVALID)
1254+ {
1255+ return STATE_IN;
1256+ }
1257+
1258+ if (this ->move_substate == SS_MOVING_IN || this ->move_substate == SS_STOPPING)
1259+ {
1260+ xMat4x3& pm = *(xMat4x3*)globals.player .ent .model ->Mat ;
1261+ pm.pos = this ->player_start ;
1262+
1263+ move_up (pm.pos , fixed.in_loc .y - shared.loc .y );
1264+ move_right (pm.pos , fixed.in_loc .x - shared.loc .x );
1265+ }
1266+
1267+ if (shared.control )
1268+ {
1269+ xModelEval (globals.player .ent .model );
1270+ }
1271+
11331272 return STATE_DROP;
11341273 }
11351274 } // namespace
0 commit comments