2023-12-13 00:40:16 -05:00
|
|
|
#include "Game/MapObj/MapParts.hpp"
|
|
|
|
|
#include "JSystem/JMath/JMath.hpp"
|
|
|
|
|
#include "math_types.hpp"
|
2022-01-20 03:36:29 -05:00
|
|
|
|
2024-03-23 13:59:50 -04:00
|
|
|
namespace {
|
|
|
|
|
const char* cFollowjointName = "Move";
|
|
|
|
|
};
|
|
|
|
|
|
2022-01-20 03:55:49 -05:00
|
|
|
MapParts::~MapParts() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-20 03:36:29 -05:00
|
|
|
MapParts::MapParts(const char *pName) : LiveActor(pName) {
|
|
|
|
|
_8C.setZero();
|
2022-01-20 03:55:49 -05:00
|
|
|
}
|
|
|
|
|
|
2022-06-20 13:45:08 -04:00
|
|
|
void MapParts::init(const JMapInfoIter &rIter) {
|
|
|
|
|
if (MR::isConnectedWithRail(rIter)) {
|
|
|
|
|
initRailRider(rIter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MR::initDefaultPosNoRepeat(this, rIter);
|
|
|
|
|
initModelAndCollision(rIter);
|
|
|
|
|
connectToScene();
|
|
|
|
|
MR::initMapPartsClipping(this, rIter, &_8C, false);
|
|
|
|
|
MR::joinToGroupArray(this, rIter, "MapParts", 0x40);
|
|
|
|
|
initSound(4, false);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-20 03:55:49 -05:00
|
|
|
void MapParts::appear() {
|
|
|
|
|
LiveActor::appear();
|
|
|
|
|
MR::tryStartAllAnim(this, MR::getModelResName(this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s32 MapParts::getSensorNumMax() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s32 MapParts::getMoveStartSignalTime() {
|
|
|
|
|
return 0x32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MapParts::connectToScene() {
|
|
|
|
|
MR::connectToSceneMapParts(this);
|
2022-06-20 13:45:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MapParts::initModelAndCollision(const JMapInfoIter &rIter) {
|
|
|
|
|
char name[0x30];
|
|
|
|
|
MR::getMapPartsObjectName(name, 0x30, rIter);
|
2023-02-13 03:33:10 -05:00
|
|
|
initModelManagerWithAnm(name, nullptr, false);
|
2022-06-20 13:45:08 -04:00
|
|
|
initHitSensor(2);
|
|
|
|
|
TVec3f dist;
|
|
|
|
|
TVec3f lerpVec;
|
|
|
|
|
TVec3f sensor_offs;
|
|
|
|
|
sensor_offs.x = 0.0f;
|
|
|
|
|
sensor_offs.y = 0.0f;
|
|
|
|
|
sensor_offs.z = 0.0f;
|
|
|
|
|
u32 sensorNum = getSensorNumMax();
|
|
|
|
|
HitSensor* sensor = MR::addHitSensorMapObj(this, "body", sensorNum, 100.0f, sensor_offs);
|
|
|
|
|
if (MR::isExistJoint(this, cFollowjointName)) {
|
|
|
|
|
MtxPtr jointMtx = MR::getJointMtx(this, cFollowjointName);
|
|
|
|
|
MR::initCollisionParts(this, name, sensor, jointMtx);
|
2023-02-13 03:33:10 -05:00
|
|
|
MR::tryCreateCollisionAllOtherCategory(this, jointMtx, sensor, nullptr, nullptr, nullptr);
|
2022-06-20 13:45:08 -04:00
|
|
|
}
|
|
|
|
|
else {
|
2023-02-13 03:33:10 -05:00
|
|
|
MR::initCollisionParts(this, name, sensor, nullptr);
|
|
|
|
|
MR::tryCreateCollisionAllOtherCategory(this, sensor, nullptr, nullptr, nullptr);
|
2022-06-20 13:45:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
f32 sensorRange;
|
|
|
|
|
if (MR::getJ3DModel(this)) {
|
|
|
|
|
TBox3f box;
|
|
|
|
|
MR::calcModelBoundingBox(&box, this);
|
|
|
|
|
JMathInlineVEC::PSVECSubtract(box.mMax.toCVec(), box.mMin.toCVec(), dist.toVec());
|
|
|
|
|
sensorRange = 0.5f * PSVECMag(dist.toCVec());
|
|
|
|
|
JMAVECLerp(box.mMax.toCVec(), box.mMin.toCVec(), lerpVec.toVec(), 0.5f);
|
|
|
|
|
TVec3f trueSensorOffset;
|
|
|
|
|
trueSensorOffset.setInlinePS(lerpVec);
|
|
|
|
|
JMathInlineVEC::PSVECSubtract(trueSensorOffset.toCVec(), mPosition.toCVec(), trueSensorOffset.toVec());
|
|
|
|
|
MR::setSensorOffset(this, "body", trueSensorOffset);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sensorRange = MR::getCollisionBoundingSphereRange(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sensor->mRadius = sensorRange;
|
2022-01-20 03:36:29 -05:00
|
|
|
}
|