feat: better reflection code

This commit is contained in:
Skye Chappelle 2022-05-24 13:52:18 +00:00
parent 5408877964
commit d152a71e58

View File

@ -318,6 +318,21 @@ static u8 ObjectEventCB2_NoMovement2(void)
return 0;
}
static void TryHidePlayerReflection(void)
{
if (gObjectEvents[gPlayerAvatar.objectEventId].hasReflection) {
s16 x, y;
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
x = playerObjEvent->currentCoords.x;
y = playerObjEvent->currentCoords.y;
MoveCoords(DIR_SOUTH, &x, &y);
if (!MetatileBehavior_IsReflective(MapGridGetMetatileBehaviorAt(x, y)))
playerObjEvent->hideReflection = TRUE;
else
playerObjEvent->hideReflection = FALSE;
}
}
void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
{
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
@ -325,6 +340,7 @@ void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
HideShowWarpArrow(playerObjEvent);
if (gPlayerAvatar.preventStep == FALSE)
{
TryHidePlayerReflection();
Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys);
if (TryInterruptObjectEventSpecialAnim(playerObjEvent, direction) == 0)
{
@ -335,6 +351,8 @@ void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys);
PlayerAllowForcedMovementIfMovingSameDirection();
}
TryHidePlayerReflection();
}
}
}