Merge branch 'reflections' into 'main'

feat: better reflection code

See merge request tbld/game!6
This commit is contained in:
Skye Chappelle 2022-05-24 14:25:21 +00:00
commit 7e1b759681

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();
} }
} }
} }