|
1 | 1 | #include <libultraship.h> |
| 2 | +#include "port/hooks/list/PlayerEvent.h" |
2 | 3 |
|
3 | 4 | #include "sm64.h" |
4 | 5 | #include "behavior_data.h" |
@@ -984,20 +985,26 @@ void cur_obj_update(void) { |
984 | 985 | } |
985 | 986 |
|
986 | 987 | // Handle visibility of object |
987 | | - if (gCurrentObject->oRoom != -1) { |
988 | | - // If the object is in a room, only show it when Mario is in the room. |
989 | | - cur_obj_enable_rendering_if_mario_in_room(); |
990 | | - } else if ((objFlags & OBJ_FLAG_COMPUTE_DIST_TO_MARIO) && gCurrentObject->collisionData == NULL) { |
991 | | - if (!(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)) { |
992 | | - // If the object has a render distance, check if it should be shown. |
993 | | - if (distanceFromMario > gCurrentObject->oDrawingDistance) { |
994 | | - // Out of render distance, hide the object. |
995 | | - gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; |
996 | | - gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; |
997 | | - } else if (gCurrentObject->oHeldState == HELD_FREE) { |
998 | | - // In render distance (and not being held), show the object. |
999 | | - gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; |
1000 | | - gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; |
| 988 | + CALL_CANCELLABLE_EVENT(ModifyObjectVisibility, &gCurrentObject) { |
| 989 | + if (gCurrentObject->oRoom != -1) { |
| 990 | + // If the object is in a room, only show it when Mario is in the room. |
| 991 | + cur_obj_enable_rendering_if_mario_in_room(); |
| 992 | + } else if ((objFlags & OBJ_FLAG_COMPUTE_DIST_TO_MARIO) && gCurrentObject->collisionData == NULL) { |
| 993 | + if (!(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)) { |
| 994 | + bool visible = distanceFromMario <= gCurrentObject->oDrawingDistance; |
| 995 | + |
| 996 | + CALL_CANCELLABLE_EVENT(EntityDistanceRender, &visible) { |
| 997 | + // If the object has a render distance, check if it should be shown. |
| 998 | + if (!visible) { |
| 999 | + // Out of render distance, hide the object. |
| 1000 | + gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; |
| 1001 | + gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; |
| 1002 | + } else if (gCurrentObject->oHeldState == HELD_FREE) { |
| 1003 | + // In render distance (and not being held), show the object. |
| 1004 | + gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; |
| 1005 | + gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; |
| 1006 | + } |
| 1007 | + } |
1001 | 1008 | } |
1002 | 1009 | } |
1003 | 1010 | } |
|
0 commit comments