feat: better reflection code

This commit is contained in:
Jess 2022-05-24 13:52:18 +00:00
parent 5408877964
commit d152a71e58
1 changed files with 18 additions and 0 deletions

View File

@ -318,6 +318,21 @@ static u8 ObjectEventCB2_NoMovement2(void)
return 0; 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) void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
{ {
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
@ -325,6 +340,7 @@ void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
HideShowWarpArrow(playerObjEvent); HideShowWarpArrow(playerObjEvent);
if (gPlayerAvatar.preventStep == FALSE) if (gPlayerAvatar.preventStep == FALSE)
{ {
TryHidePlayerReflection();
Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys); Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys);
if (TryInterruptObjectEventSpecialAnim(playerObjEvent, direction) == 0) if (TryInterruptObjectEventSpecialAnim(playerObjEvent, direction) == 0)
{ {
@ -335,6 +351,8 @@ void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys); MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys);
PlayerAllowForcedMovementIfMovingSameDirection(); PlayerAllowForcedMovementIfMovingSameDirection();
} }
TryHidePlayerReflection();
} }
} }
} }