Change customHitbox in InteractableObject to Rect*

This commit is contained in:
Catobat 2023-04-30 22:34:53 +02:00
parent 3a7f92e7c7
commit 8a7e928461
11 changed files with 23 additions and 38 deletions

View File

@ -258,12 +258,19 @@ typedef struct {
union SplitWord _4;
} struct_020227E8;
typedef struct {
s8 x;
s8 y;
s8 width;
s8 height;
} Rect;
typedef struct {
/*0x00*/ u8 ignoreLayer; /* if bit 0 set, skip layer check for collision */
/*0x01*/ u8 type;
/*0x02*/ u8 interactDirections; /* lower 4 bits determine Link's allowed facing directions to interact, 0 to allow (0000WSEN) */
/*0x03*/ u8 kinstoneId;
/*0x04*/ const s8* customHitbox; /* if set, array contains x, y, width and height */
/*0x04*/ const Rect* customHitbox; /* optional custom rectangle */
/*0x08*/ Entity* entity;
} InteractableObject;
@ -351,11 +358,4 @@ typedef struct {
u8 frame;
u8 frameIndex;
} PACKED FrameStruct;
typedef struct {
s8 x;
s8 y;
s8 width;
s8 height;
} Rect;
#endif // STRUCTURES_H

View File

@ -9,7 +9,7 @@
#include "item.h"
typedef struct {
s8 customHitbox[4];
Rect customHitbox;
s8 interactDirections;
u8 unused[3];
} InteractCollisionData;

View File

@ -77,11 +77,6 @@ void sub_0806C038(Entity* this) {
}
void sub_0806C09C(Entity* this) {
static const s8 gUnk_081133B4[] = {
0,
6,
8,
12,
};
static const Rect gUnk_081133B4 = { 0, 6, 8, 12 };
SetInteractableObjectCollision(this, 1, 0, &gUnk_081133B4);
}

View File

@ -38,14 +38,9 @@ void MayorHagen(Entity* this) {
}
void MayorHagen_MakeInteractable(Entity* this) {
static const s8 gUnk_08113F44[] = {
0,
8,
8,
16,
};
static const Rect gUnk_08113F44 = { 0, 8, 8, 16 };
AddInteractableWhenBigFuser(this, GetFusionToOffer(this));
SetInteractableObjectCollision(this, 1, 0, gUnk_08113F44);
SetInteractableObjectCollision(this, 1, 0, &gUnk_08113F44);
}
void sub_0806CE80(Entity* this) {

View File

@ -12,7 +12,7 @@
#include "sound.h"
typedef struct {
s8 customHitbox[4];
Rect customHitbox;
u8 interactDirections;
u8 unused[3];
} InteractCollisionData;

View File

@ -329,7 +329,7 @@ void sub_0806A914(Entity* this) {
}
void Rem_MakeInteractable(Entity* this) {
static const s8 gUnk_0811229C[] = { 0, 6, 10, 16 };
static const Rect gUnk_0811229C = { 0, 6, 10, 16 };
AddInteractableWhenBigObject(this);
SetInteractableObjectCollision(this, 0, 0, &gUnk_0811229C);
}

View File

@ -9,12 +9,12 @@
void SmallTownMinish(Entity* this) {
static const Hitbox gUnk_081142FC = { -2, 1, { 0, 0, 0, 0 }, 6, 6 };
static const s8 gUnk_08114304[] = { -2, 1, 6, 6 };
static const Rect gUnk_08114304 = { -2, 1, 6, 6 };
if (this->action == 0) {
this->action++;
this->hitbox = (Hitbox*)&gUnk_081142FC;
sub_0807DD50(this);
SetInteractableObjectCollision(this, 1, 0, gUnk_08114304);
SetInteractableObjectCollision(this, 1, 0, &gUnk_08114304);
} else {
sub_0807DD94(this, NULL);
}

View File

@ -206,12 +206,7 @@ void sub_08066258(void) {
}
void Smith_ChangeInteractableHitbox(Entity* this) {
static const s8 gUnk_081103E0[] = {
0,
6,
8,
12,
};
static const Rect gUnk_081103E0 = { 0, 6, 8, 12 };
SetInteractableObjectCollision(this, 1, 0, &gUnk_081103E0);
}

View File

@ -9,7 +9,7 @@
#include "game.h"
#ifndef EU
static const s8 gUnk_0810FDA0[] = { 0, 8, 10, 16 };
static const Rect gUnk_0810FDA0 = { 0, 8, 10, 16 };
#endif
extern u16 script_StockwellBuy[];

View File

@ -129,13 +129,13 @@ static const SpriteLoadData gUnk_08112674[][4] = {
{ 0x0, 0x0, 0x0 },
},
};
static const s8 gUnk_081126D4[][4] = {
static const Rect gUnk_081126D4[4] = {
{ 0, 8, 8, 16 },
{ -8, -2, 16, 8 },
{ 0, 8, 8, 16 },
{ 8, -2, 16, 8 },
};
static const u8 gUnk_081126E4[4] = { 14, 13, 11, 7 };
static const u8 gUnk_081126E4[4] = { 0x0e, 0x0d, 0x0b, 0x07 };
void TownMinish(Entity* this) {
static void (*const scriptedActionFuncs[])(Entity*) = {
@ -228,7 +228,7 @@ void sub_0806ACC4(Entity* this) {
}
if (this->type == 1) {
u8 idx = gPlayerEntity.animationState >> 1;
SetInteractableObjectCollision(this, 1, gUnk_081126E4[idx], gUnk_081126D4[idx]);
SetInteractableObjectCollision(this, 1, gUnk_081126E4[idx], &gUnk_081126D4[idx]);
}
}
break;

View File

@ -23,8 +23,8 @@ void Windcrest(Entity* this) {
}
void Windcrest_ChangeInteractableHitbox(Entity* this) {
static const s8 gUnk_08125010[] = { 0, 0, 12, 12 };
SetInteractableObjectCollision(this, 1, 0xe, gUnk_08125010);
static const Rect gUnk_08125010 = { 0, 0, 12, 12 };
SetInteractableObjectCollision(this, 1, 0xe, &gUnk_08125010);
}
void Windcrest_Unlock(Entity* this) {