@ -815,16 +815,15 @@ bool could_learn_from_scanner(Player *for_player, Entity *box)
return ( for_player - > box_unlocks | box - > blueprints_learned ) ! = for_player - > box_unlocks ;
return ( for_player - > box_unlocks | box - > blueprints_learned ) ! = for_player - > box_unlocks ;
}
}
bool box_enterable ( Entity * box )
{
return box - > box_type = = BoxMedbay | | box - > box_type = = BoxCockpit ;
}
bool box_interactible ( GameState * gs , Player * for_player , Entity * box )
bool box_interactible ( GameState * gs , Player * for_player , Entity * box )
{
{
flight_assert ( box - > is_box ) ;
flight_assert ( box - > is_box ) ;
if ( box - > box_type = = BoxCockpit | | box - > box_type = = BoxMedbay )
{
return true ;
}
else
{
if ( box - > box_type = = BoxMerge )
if ( box - > box_type = = BoxMerge )
{
{
return merge_box_is_merged ( gs , box ) ;
return merge_box_is_merged ( gs , box ) ;
@ -833,7 +832,6 @@ bool box_interactible(GameState *gs, Player *for_player, Entity *box)
{
{
return false ;
return false ;
}
}
}
}
}
// removes boxes from grid, then ensures that the rule that grids must not have
// removes boxes from grid, then ensures that the rule that grids must not have
@ -1399,6 +1397,7 @@ SerMaybeFailure ser_inputframe(SerState *ser, InputFrame *i)
SER_MAYBE_RETURN ( ser_entityid ( ser , & i - > invite_this_player ) ) ;
SER_MAYBE_RETURN ( ser_entityid ( ser , & i - > invite_this_player ) ) ;
SER_VAR ( & i - > seat_action ) ;
SER_VAR ( & i - > seat_action ) ;
SER_VAR ( & i - > interact_action ) ;
SER_MAYBE_RETURN ( ser_fV2 ( ser , & i - > hand_pos ) ) ;
SER_MAYBE_RETURN ( ser_fV2 ( ser , & i - > hand_pos ) ) ;
SER_VAR ( & i - > dobuild ) ;
SER_VAR ( & i - > dobuild ) ;
@ -2571,6 +2570,7 @@ void create_initial_world(GameState *gs)
# endif // debug world
# endif // debug world
}
}
// does not actually set seat in variables so can be used on respawn
void exit_seat ( GameState * gs , Entity * seat_in , Entity * p )
void exit_seat ( GameState * gs , Entity * seat_in , Entity * p )
{
{
cpVect pilot_seat_exit_spot = cpvadd ( entity_pos ( seat_in ) , cpvmult ( box_facing_vector ( seat_in ) , BOX_SIZE ) ) ;
cpVect pilot_seat_exit_spot = cpvadd ( entity_pos ( seat_in ) , cpvmult ( box_facing_vector ( seat_in ) , BOX_SIZE ) ) ;
@ -2727,13 +2727,11 @@ void process(struct GameState *gs, double dt)
p - > damage = 0.0 ;
p - > damage = 0.0 ;
# endif
# endif
# if 1
# if 1
cpVect world_hand_pos = get_world_hand_pos ( gs , & player - > input , p ) ;
cpVect world_hand_pos = get_world_hand_pos ( gs , & player - > input , p ) ;
if ( player - > input . seat_action )
if ( player - > input . interact_action )
{
player - > input . seat_action = false ; // "handle" the input
Entity * seat_maybe_in = get_entity ( gs , p - > currently_inside_of_box ) ;
if ( seat_maybe_in = = NULL ) // not in any seat
{
{
player - > input . interact_action = false ;
cpPointQueryInfo query_info = { 0 } ;
cpPointQueryInfo query_info = { 0 } ;
cpShape * result = cpSpacePointQueryNearest ( gs - > space , ( world_hand_pos ) , 0.1 , FILTER_ONLY_BOXES , & query_info ) ;
cpShape * result = cpSpacePointQueryNearest ( gs - > space , ( world_hand_pos ) , 0.1 , FILTER_ONLY_BOXES , & query_info ) ;
if ( result ! = NULL )
if ( result ! = NULL )
@ -2743,10 +2741,6 @@ void process(struct GameState *gs, double dt)
// IMPORTANT: if you update these, make sure you update box_interactible so
// IMPORTANT: if you update these, make sure you update box_interactible so
// the button prompt still works
// the button prompt still works
if ( potential_seat - > box_type = = BoxScanner ) // learn everything from the scanner
{
player - > box_unlocks | = potential_seat - > blueprints_learned ;
}
if ( potential_seat - > box_type = = BoxMerge ) // disconnect!
if ( potential_seat - > box_type = = BoxMerge ) // disconnect!
{
{
potential_seat - > wants_disconnect = true ;
potential_seat - > wants_disconnect = true ;
@ -2755,6 +2749,23 @@ void process(struct GameState *gs, double dt)
flight_assert ( potential_seat - > is_box ) ;
flight_assert ( potential_seat - > is_box ) ;
flight_assert ( potential_seat - > box_type = = BoxMerge ) ;
flight_assert ( potential_seat - > box_type = = BoxMerge ) ;
}
}
}
}
if ( player - > input . seat_action )
{
player - > input . seat_action = false ; // "handle" the input
Entity * seat_maybe_in = get_entity ( gs , p - > currently_inside_of_box ) ;
if ( seat_maybe_in = = NULL ) // not in any seat
{
cpPointQueryInfo query_info = { 0 } ;
cpShape * result = cpSpacePointQueryNearest ( gs - > space , ( world_hand_pos ) , 0.1 , FILTER_ONLY_BOXES , & query_info ) ;
if ( result ! = NULL )
{
Entity * potential_seat = cp_shape_entity ( result ) ;
flight_assert ( potential_seat - > is_box ) ;
// IMPORTANT: if you update these, make sure you update box_enterable so
// the button prompt still works
if ( potential_seat - > box_type = = BoxCockpit | | potential_seat - > box_type = = BoxMedbay )
if ( potential_seat - > box_type = = BoxCockpit | | potential_seat - > box_type = = BoxMedbay )
{
{
// don't let players get inside of cockpits that somebody else is already inside of
// don't let players get inside of cockpits that somebody else is already inside of