| 1 | #include "Enemy/SenobiLeaf.h" |
| 2 | |
| 3 | #include <math/seadMathCalcCommon.h> |
| 4 | |
| 5 | #include "Library/Joint/JointControllerKeeper.h" |
| 6 | #include "Library/LiveActor/ActorClippingFunction.h" |
| 7 | #include "Library/LiveActor/ActorInitFunction.h" |
| 8 | #include "Library/LiveActor/ActorInitInfo.h" |
| 9 | #include "Library/LiveActor/ActorInitUtil.h" |
| 10 | #include "Library/LiveActor/ActorModelFunction.h" |
| 11 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 12 | #include "Library/LiveActor/LiveActorFunction.h" |
| 13 | #include "Library/Math/MathUtil.h" |
| 14 | |
| 15 | SenobiLeaf::SenobiLeaf(const char* actorName) : al::LiveActor(actorName) {} |
| 16 | |
| 17 | void SenobiLeaf::init(const al::ActorInitInfo& info) { |
| 18 | al::initActorWithArchiveName(actor: this, initInfo: info, archiveName: "SenobiLeaf" , suffix: 0); |
| 19 | al::initJointControllerKeeper(this, 1); |
| 20 | al::initJointLocalZRotator(this, &mLocalZRotator, "Leaf1" ); |
| 21 | makeActorDead(); |
| 22 | } |
| 23 | |
| 24 | void SenobiLeaf::calcAnim() { |
| 25 | updatePose(); |
| 26 | al::LiveActor::calcAnim(); |
| 27 | } |
| 28 | |
| 29 | void SenobiLeaf::updatePose() { |
| 30 | sead::Vector3f frontDir; |
| 31 | al::calcJointFrontDir(&frontDir, actor: mHostActor, "AllRoot" ); |
| 32 | |
| 33 | sead::Quatf targetQuat = sead::Quatf::unit; |
| 34 | al::makeQuatUpFront(outQuat: &targetQuat, up: mUp, front: frontDir); |
| 35 | al::rotateQuatRadian(&targetQuat, targetQuat, mUp, sead::Mathf::deg2rad(deg: mYDegree)); |
| 36 | al::updatePoseQuat(actor: this, quat: targetQuat); |
| 37 | |
| 38 | sead::Vector3f newFrontDir; |
| 39 | al::calcQuatFront(out: &newFrontDir, quat: targetQuat); |
| 40 | al::updatePoseTrans(actor: this, trans: al::getTrans(actor: this) - newFrontDir * 15.0f); |
| 41 | } |
| 42 | |
| 43 | void SenobiLeaf::registerToHost(al::LiveActor* host, bool flip) { |
| 44 | mHostActor = host; |
| 45 | getName(); // unused |
| 46 | al::invalidateClipping(actor: this); |
| 47 | al::registerSubActorSyncClipping(host, this); |
| 48 | al::onSyncHideSubActor(actor: host, subActor: this); |
| 49 | |
| 50 | if (flip) |
| 51 | mYDegree = al::getRandom(min: -60.0f, max: 60.0f) - 90.0f; |
| 52 | else |
| 53 | mYDegree = al::getRandom(min: -60.0f, max: 60.0f) + 90.0f; |
| 54 | } |
| 55 | |