@ -111,6 +111,26 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
| | game - > KEY_LEFT . Pressed ( ) | | game - > KEY_RIGHT . Pressed ( ) | | game - > KEY_UP . Pressed ( ) | | game - > KEY_DOWN . Pressed ( )
| | 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 ) ) ) {
| | ( ! 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 ) ;
bool mouseUsed = game - > GetMouse ( Mouse : : LEFT ) . bPressed & & geom2d : : overlaps ( game - > GetWorldMousePos ( ) , cp . rect ) ;
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 ) {
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 ;
} else {
for ( int directionInd = 0 ; int neighborInd : currentConnectionPoint - > neighbors ) {
for ( int directionInd = 0 ; int neighborInd : currentConnectionPoint - > neighbors ) {
int targetDirection = - 1 ;
int targetDirection = - 1 ;
@ -125,8 +145,7 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
}
}
ConnectionPoint & neighbor = ConnectionPointFromIndex ( neighborInd ) ;
ConnectionPoint & neighbor = ConnectionPointFromIndex ( neighborInd ) ;
if ( Unlock : : IsUnlocked ( neighbor . unlockCondition ) & & & cp = = & neighbor
if ( Unlock : : IsUnlocked ( neighbor . unlockCondition ) & & targetDirection = = directionInd ) {
& & ( mouseUsed | | targetDirection = = directionInd ) ) {
UpdateCurrentConnectionPoint ( neighbor ) ;
UpdateCurrentConnectionPoint ( neighbor ) ;
playerTargetPos = currentConnectionPoint - > rect . pos + currentConnectionPoint - > rect . size / 2 + vf2d { 0 , 16 } ;
playerTargetPos = currentConnectionPoint - > rect . pos + currentConnectionPoint - > rect . size / 2 + vf2d { 0 , 16 } ;
float angleTo = util : : angleTo ( game - > GetPlayer ( ) - > GetPos ( ) , playerTargetPos ) ;
float angleTo = util : : angleTo ( game - > GetPlayer ( ) - > GetPos ( ) , playerTargetPos ) ;
@ -148,6 +167,8 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
}
}
}
}
}
}
}
}
# pragma endregion
# pragma endregion
doneNavigating :
doneNavigating :
if ( abs ( game - > KEY_SCROLLVERT_L . Analog ( ) ) < 0.2f & & abs ( game - > KEY_SCROLLHORZ_L . Analog ( ) ) < 0.2f ) {
if ( abs ( game - > KEY_SCROLLVERT_L . Analog ( ) ) < 0.2f & & abs ( game - > KEY_SCROLLHORZ_L . Analog ( ) ) < 0.2f ) {
@ -172,7 +193,7 @@ void State_OverworldMap::Draw(AiL*game){
}
}
bool highlightedAStage = false ;
bool highlightedAStage = false ;
for ( ConnectionPoint & cp : connections ) {
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 ) ;
drawutil : : DrawCrosshairDecalTransformedView ( game - > view , cp . rect , currentTime ) ;
highlightedAStage = true ;
highlightedAStage = true ;
break ;
break ;