You've already forked HackerSM64
mirror of
https://github.com/HackerN64/HackerSM64.git
synced 2026-01-21 10:35:32 -08:00
Replace gEnteredPaintingObject with a MarioState field
This commit is contained in:
@@ -473,6 +473,7 @@ struct MarioState {
|
||||
/*0xC0*/ f32 quicksandDepth;
|
||||
/*0xC4*/ f32 windGravity;
|
||||
// -- HackerSM64 MarioState fields begin --
|
||||
struct Object *paintingObj;
|
||||
#ifdef BREATH_METER
|
||||
s16 breath;
|
||||
u8 breathCounter;
|
||||
|
||||
@@ -4,21 +4,23 @@
|
||||
* Main loop of the hour and minute hands of the Tick Tock Clock painting.
|
||||
*/
|
||||
void bhv_rotating_clock_arm_loop(void) {
|
||||
u16 rollAngle = o->oFaceAngleRoll;
|
||||
struct Object *paintingObj = gMarioState->paintingObj;
|
||||
|
||||
if (o->oAction == TTC_PAINTING_CLOCK_ARM_WAIT) {
|
||||
// Make sure Mario not in a painting & 3 frames pass before allowing him to
|
||||
// change the Tick Tock Clock speed setting.
|
||||
// Probably a safety check for when you leave the level through the painting
|
||||
// to make sure the setting isn't accidentally locked in as you fly out.
|
||||
if (gEnteredPaintingObject == NULL && o->oTimer > 3) {
|
||||
if (paintingObj == NULL && o->oTimer > 3) {
|
||||
o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_MOVING
|
||||
}
|
||||
} else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_MOVING) {
|
||||
// If Mario is entering the Tick Tock Clock painting...
|
||||
if (gEnteredPaintingObject != NULL && GET_BPARAM1(gEnteredPaintingObject->oBehParams) == PAINTING_ID_CASTLE_TTC) {
|
||||
if (paintingObj != NULL && GET_BPARAM1(paintingObj->oBehParams) == PAINTING_ID_CASTLE_TTC) {
|
||||
// And this is the minute hand...
|
||||
if (cur_obj_has_behavior(bhvClockMinuteHand)) {
|
||||
u16 rollAngle = o->oFaceAngleRoll;
|
||||
|
||||
// Set Tick Tick Clock's speed based on the angle of the hand.
|
||||
// The angle actually counting down from 0xFFFF to 0 so
|
||||
// 11 o'clock is a small value and 1 o'clock is a large value.
|
||||
@@ -40,7 +42,7 @@ void bhv_rotating_clock_arm_loop(void) {
|
||||
o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_STOPPED
|
||||
}
|
||||
} else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_STOPPED) {
|
||||
if (gEnteredPaintingObject == NULL) {
|
||||
if (paintingObj == NULL) {
|
||||
o->oAction = TTC_PAINTING_CLOCK_ARM_ACT_MOVING;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,10 +637,10 @@ s8 gPaintingEjectSoundPlayed = FALSE;
|
||||
* Check is Mario has entered a painting, and if so, initiate a warp.
|
||||
*/
|
||||
void initiate_painting_warp(void) {
|
||||
struct ObjectWarpNode *warpNode = NULL;
|
||||
struct Object *paintingObj = gMarioState->paintingObj;
|
||||
|
||||
if (gEnteredPaintingObject != NULL) {
|
||||
warpNode = area_get_warp_node(GET_BPARAM2(gEnteredPaintingObject->oBehParams));
|
||||
if (paintingObj != NULL) {
|
||||
struct ObjectWarpNode *warpNode = area_get_warp_node(GET_BPARAM2(paintingObj->oBehParams));
|
||||
|
||||
if (warpNode != NULL) {
|
||||
if (gMarioState->action & ACT_FLAG_INTANGIBLE) {
|
||||
@@ -673,7 +673,7 @@ void initiate_painting_warp(void) {
|
||||
queue_rumble_data(80, 70);
|
||||
queue_rumble_decay(1);
|
||||
#endif
|
||||
cutscene_object(CUTSCENE_ENTER_PAINTING, gEnteredPaintingObject);
|
||||
cutscene_object(CUTSCENE_ENTER_PAINTING, paintingObj);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1824,6 +1824,8 @@ void init_mario(void) {
|
||||
gMarioState->riddenObj = NULL;
|
||||
gMarioState->usedObj = NULL;
|
||||
|
||||
gMarioState->paintingObj = NULL;
|
||||
|
||||
gMarioState->waterLevel = find_water_level(gMarioSpawnInfo->startPos[0], gMarioSpawnInfo->startPos[2]);
|
||||
|
||||
gMarioState->area = gCurrentArea;
|
||||
|
||||
@@ -526,7 +526,6 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) {
|
||||
void clear_objects(void) {
|
||||
s32 i;
|
||||
|
||||
gEnteredPaintingObject = NULL;
|
||||
gTHIWaterDrained = 0;
|
||||
gTimeStopState = 0;
|
||||
gMarioObject = NULL;
|
||||
|
||||
@@ -78,11 +78,6 @@ const struct Painting *sPaintings[] = {
|
||||
/* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting,
|
||||
};
|
||||
|
||||
/**
|
||||
* The id of the painting Mario has entered.
|
||||
*/
|
||||
struct Object *gEnteredPaintingObject = NULL;
|
||||
|
||||
/**
|
||||
* When a painting is rippling, this mesh is generated each frame using the Painting's parameters.
|
||||
*
|
||||
@@ -807,7 +802,7 @@ void bhv_painting_init(void) {
|
||||
/**
|
||||
* Check for Mario entering the painting.
|
||||
*/
|
||||
void painting_update_mario_pos(struct Object *obj) {
|
||||
void painting_update_mario_pos_and_flags(struct Object *obj) {
|
||||
if (!gMarioObject) {
|
||||
return;
|
||||
}
|
||||
@@ -846,6 +841,9 @@ void painting_update_mario_pos(struct Object *obj) {
|
||||
rippleFlags |= RIPPLE_FLAG_ENTER;
|
||||
}
|
||||
}
|
||||
|
||||
obj->oPaintingLocalMarioPosX = marioLocalPos[0];
|
||||
obj->oPaintingLocalMarioPosY = marioLocalPos[1];
|
||||
|
||||
s16 lastFlags = obj->oPaintingCurrFlags;
|
||||
|
||||
@@ -855,9 +853,15 @@ void painting_update_mario_pos(struct Object *obj) {
|
||||
// changedFlags is true if currFlags is true and lastFlags is false
|
||||
// (Mario just entered the floor on this frame).
|
||||
obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags);
|
||||
|
||||
obj->oPaintingLocalMarioPosX = marioLocalPos[0];
|
||||
obj->oPaintingLocalMarioPosY = marioLocalPos[1];
|
||||
|
||||
// Detect whether Mario is entering this painting, and set paintingObj accordingly
|
||||
if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) {
|
||||
// Mario has entered the painting.
|
||||
gMarioState->paintingObj = obj;
|
||||
} else if (gMarioState->paintingObj == obj) {
|
||||
// Reset gMarioState->paintingObj if it's this painting and this painting is not entered.
|
||||
gMarioState->paintingObj = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1022,7 +1026,7 @@ void bhv_painting_loop(void) {
|
||||
const struct Painting *painting = obj->oPaintingData;
|
||||
|
||||
// Update the painting info.
|
||||
painting_update_mario_pos(obj);
|
||||
painting_update_mario_pos_and_flags(obj);
|
||||
|
||||
// Update the ripple, may automatically reset the painting's state.
|
||||
painting_update_ripple_state(obj);
|
||||
@@ -1049,12 +1053,4 @@ void bhv_painting_loop(void) {
|
||||
painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE ); // Idle
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) {
|
||||
// Mario has entered the painting.
|
||||
gEnteredPaintingObject = obj;
|
||||
} else if (gEnteredPaintingObject == obj) {
|
||||
// Reset gEnteredPaintingObject if it's this painting and this painting is not entered.
|
||||
gEnteredPaintingObject = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,9 +149,6 @@ struct PaintingMeshVertex {
|
||||
}; /*0x0C*/
|
||||
|
||||
|
||||
extern struct Object *gEnteredPaintingObject;
|
||||
|
||||
|
||||
Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context);
|
||||
|
||||
void bhv_painting_init(void);
|
||||
|
||||
Reference in New Issue
Block a user