@ -111,23 +111,10 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
| | game - > KEY_LEFT . Pressed ( ) | | game - > KEY_RIGHT . Pressed ( ) | | game - > KEY_UP . Pressed ( ) | | game - > KEY_DOWN . Pressed ( )
| | ( ! analogMove & & ( abs ( game - > KEY_SCROLLHORZ_L . Analog ( ) ) > = 0.2f | | abs ( game - > KEY_SCROLLVERT_L . Analog ( ) ) > = 0.2f ) ) ) {
bool mouseUsed = game - > GetMouse ( Mouse : : LEFT ) . bPressed & & geom2d : : overlaps ( game - > GetWorldMousePos ( ) , cp . rect ) ;
for ( int directionInd = 0 ; int neighborInd : currentConnectionPoint - > neighbors ) {
int targetDirection = - 1 ;
if ( game - > KEY_LEFT . Pressed ( ) | | game - > KEY_SCROLLHORZ_L . Analog ( ) < = - 0.2f ) targetDirection = ConnectionPoint : : WEST ;
if ( game - > KEY_RIGHT . Pressed ( ) | | game - > KEY_SCROLLHORZ_L . Analog ( ) > = 0.2f ) targetDirection = ConnectionPoint : : EAST ;
if ( game - > KEY_UP . Pressed ( ) | | game - > KEY_SCROLLVERT_L . Analog ( ) < = - 0.2f ) targetDirection = ConnectionPoint : : NORTH ;
if ( game - > KEY_DOWN . Pressed ( ) | | game - > KEY_SCROLLVERT_L . Analog ( ) > = 0.2f ) targetDirection = ConnectionPoint : : SOUTH ;
if ( neighborInd = = - 1 ) {
directionInd + + ;
continue ;
}
ConnectionPoint & neighbor = ConnectionPointFromIndex ( neighborInd ) ;
if ( Unlock : : IsUnlocked ( neighbor . unlockCondition ) & & & cp = = & neighbor
& & ( mouseUsed | | targetDirection = = directionInd ) ) {
UpdateCurrentConnectionPoint ( neighbor ) ;
if ( Unlock : : IsUnlocked ( cp ) ) {
if ( mouseUsed ) {
UpdateCurrentConnectionPoint ( cp ) ;
playerTargetPos = currentConnectionPoint - > rect . pos + currentConnectionPoint - > rect . size / 2 + vf2d { 0 , 16 } ;
float angleTo = util : : angleTo ( game - > GetPlayer ( ) - > GetPos ( ) , playerTargetPos ) ;
if ( angleTo > = - 3 * PI / 4 & & angleTo < - PI / 4 ) {
@ -143,8 +130,42 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
}
if ( abs ( game - > KEY_SCROLLHORZ_L . Analog ( ) ) > = 0.2f | | abs ( game - > KEY_SCROLLVERT_L . Analog ( ) > = 0.2f ) ) analogMove = true ;
goto doneNavigating ;
} else {
for ( int directionInd = 0 ; int neighborInd : currentConnectionPoint - > neighbors ) {
int targetDirection = - 1 ;
if ( game - > KEY_LEFT . Pressed ( ) | | game - > KEY_SCROLLHORZ_L . Analog ( ) < = - 0.2f ) targetDirection = ConnectionPoint : : WEST ;
if ( game - > KEY_RIGHT . Pressed ( ) | | game - > KEY_SCROLLHORZ_L . Analog ( ) > = 0.2f ) targetDirection = ConnectionPoint : : EAST ;
if ( game - > KEY_UP . Pressed ( ) | | game - > KEY_SCROLLVERT_L . Analog ( ) < = - 0.2f ) targetDirection = ConnectionPoint : : NORTH ;
if ( game - > KEY_DOWN . Pressed ( ) | | game - > KEY_SCROLLVERT_L . Analog ( ) > = 0.2f ) targetDirection = ConnectionPoint : : SOUTH ;
if ( neighborInd = = - 1 ) {
directionInd + + ;
continue ;
}
ConnectionPoint & neighbor = ConnectionPointFromIndex ( neighborInd ) ;
if ( Unlock : : IsUnlocked ( neighbor . unlockCondition ) & & targetDirection = = directionInd ) {
UpdateCurrentConnectionPoint ( neighbor ) ;
playerTargetPos = currentConnectionPoint - > rect . pos + currentConnectionPoint - > rect . size / 2 + vf2d { 0 , 16 } ;
float angleTo = util : : angleTo ( game - > GetPlayer ( ) - > GetPos ( ) , playerTargetPos ) ;
if ( angleTo > = - 3 * PI / 4 & & angleTo < - PI / 4 ) {
game - > GetPlayer ( ) - > UpdateWalkingAnimation ( UP ) ;
} else
if ( angleTo < PI / 4 & & angleTo > = - PI / 4 ) {
game - > GetPlayer ( ) - > UpdateWalkingAnimation ( RIGHT ) ;
} else
if ( angleTo > = PI / 4 & & angleTo < 3 * PI / 4 ) {
game - > GetPlayer ( ) - > UpdateWalkingAnimation ( DOWN ) ;
} else {
game - > GetPlayer ( ) - > UpdateWalkingAnimation ( LEFT ) ;
}
if ( abs ( game - > KEY_SCROLLHORZ_L . Analog ( ) ) > = 0.2f | | abs ( game - > KEY_SCROLLVERT_L . Analog ( ) > = 0.2f ) ) analogMove = true ;
goto doneNavigating ;
}
directionInd + + ;
}
}
directionInd + + ;
}
}
}
@ -172,7 +193,7 @@ void State_OverworldMap::Draw(AiL*game){
}
bool highlightedAStage = false ;
for ( ConnectionPoint & cp : connections ) {
if ( Unlock : : IsUnlocked ( cp ) & & geom2d : : overlaps ( game - > GetWorldMousePos ( ) , cp . rect ) & & ( & cp = = currentConnectionPoint | | cp . IsNeighbor ( * currentConnectionPoint ) ) ) {
if ( Unlock : : IsUnlocked ( cp ) & & geom2d : : overlaps ( game - > GetWorldMousePos ( ) , cp . rect ) ) {
drawutil : : DrawCrosshairDecalTransformedView ( game - > view , cp . rect , currentTime ) ;
highlightedAStage = true ;
break ;