creature: move Creature_Effect to trx

This commit is contained in:
Marcin Kurczewski 2025-04-08 17:34:05 +02:00
parent 751e5c4cb5
commit 3d898a8844
5 changed files with 19 additions and 29 deletions

View file

@ -447,3 +447,14 @@ void Creature_Head(ITEM *const item, const int16_t required)
creature->head_rotation += change;
CLAMP(creature->head_rotation, -M_HEAD_ARC, M_HEAD_ARC);
}
int16_t Creature_Effect(
const ITEM *const item, const BITE *const bite,
int16_t (*const spawn)(
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot,
int16_t room_num))
{
XYZ_32 pos = { .x = bite->x, .y = bite->y, .z = bite->z };
Collide_GetJointAbsPosition(item, &pos, bite->mesh_num);
return spawn(pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_num);
}

View file

@ -18,7 +18,8 @@ extern bool Creature_IsHostile(const ITEM *item);
extern void Creature_Collision(
int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
extern bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt);
extern int16_t Creature_Effect(
int16_t Creature_Effect(
const ITEM *item, const BITE *bite,
int16_t (*spawn)(
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot,

View file

@ -37,7 +37,12 @@ typedef struct {
int32_t y;
int32_t z;
#else
XYZ_32 pos;
union {
struct {
int32_t x, y, z;
};
XYZ_32 pos;
};
#endif
int32_t mesh_num;
} BITE;

View file

@ -18,21 +18,6 @@
#include <libtrx/game/math.h>
#include <libtrx/log.h>
int16_t Creature_Effect(
const ITEM *const item, const BITE *const bite,
int16_t (*spawn)(
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t yrot,
int16_t room_num))
{
XYZ_32 pos = {
.x = bite->x,
.y = bite->y,
.z = bite->z,
};
Collide_GetJointAbsPosition(item, &pos, bite->mesh_num);
return spawn(pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_num);
}
bool Creature_CheckBaddieOverlap(int16_t item_num)
{
const ITEM *item = Item_Get(item_num);

View file

@ -414,18 +414,6 @@ void Creature_Underwater(ITEM *const item, const int32_t depth)
}
}
int16_t Creature_Effect(
const ITEM *const item, const BITE *const bite,
int16_t (*const spawn)(
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot,
int16_t room_num))
{
XYZ_32 pos = bite->pos;
Collide_GetJointAbsPosition(item, &pos, bite->mesh_num);
return (*spawn)(
pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_num);
}
int32_t Creature_Vault(
const int16_t item_num, const int16_t angle, int32_t vault,
const int32_t shift)