| 1 | #pragma once |
| 2 | |
| 3 | #include <math/seadMatrix.h> |
| 4 | #include <math/seadVector.h> |
| 5 | |
| 6 | namespace al { |
| 7 | class LiveActor; |
| 8 | class HitSensorDirectror; |
| 9 | class HitSensorKeeper; |
| 10 | class SensorHitGroup; |
| 11 | class HitSensor; |
| 12 | |
| 13 | using SensorSortCmpFunc = bool (*)(HitSensor* a, HitSensor* b); |
| 14 | |
| 15 | enum class HitSensorType : u32 { |
| 16 | Eye = 0, |
| 17 | Player = 1, |
| 18 | PlayerAttack = 2, |
| 19 | = 3, |
| 20 | PlayerDecoration = 4, |
| 21 | PlayerEye = 5, |
| 22 | Npc = 6, |
| 23 | Ride = 7, |
| 24 | Enemy = 8, |
| 25 | EnemyBody = 9, |
| 26 | EnemyAttack = 10, |
| 27 | EnemySimple = 11, |
| 28 | MapObj = 12, |
| 29 | MapObjSimple = 13, |
| 30 | Bindable = 14, |
| 31 | CollisionParts = 15, |
| 32 | PlayerFireBall = 16, |
| 33 | HoldObj = 17, |
| 34 | LookAt = 18, |
| 35 | BindableGoal = 19, |
| 36 | BindableAllPlayer = 20, |
| 37 | BindableBubbleOutScreen = 21, |
| 38 | BindableKoura = 22, |
| 39 | BindableRouteDokan = 23, |
| 40 | BindableBubblePadInput = 24 |
| 41 | }; |
| 42 | |
| 43 | class HitSensor { |
| 44 | public: |
| 45 | HitSensor(LiveActor* parentActor, const char* name, u32 hitSensorType, f32 radius, |
| 46 | u16 maxSensorCount, const sead::Vector3f* followPos, |
| 47 | const sead::Matrix34f* followMatrix, const sead::Vector3f& offset); |
| 48 | |
| 49 | bool trySensorSort(); |
| 50 | void setFollowPosPtr(const sead::Vector3f*); |
| 51 | void setFollowMtxPtr(const sead::Matrix34f*); |
| 52 | void validate(); |
| 53 | void invalidate(); |
| 54 | void validateBySystem(); |
| 55 | void invalidateBySystem(); |
| 56 | void update(); |
| 57 | void addHitSensor(HitSensor*); |
| 58 | |
| 59 | void clearSensors() { mSensorCount = 0; } |
| 60 | |
| 61 | const sead::Vector3f& getFollowPosOffset() const { return mFollowPosOffset; } |
| 62 | |
| 63 | f32 getRadius() const { return mRadius; } |
| 64 | |
| 65 | void setFollowPosOffset(const sead::Vector3f& offset) { mFollowPosOffset.set(offset); } |
| 66 | |
| 67 | void setRadius(f32 radius) { mRadius = radius; } |
| 68 | |
| 69 | void scaleY(f32 scaleY) { |
| 70 | mRadius *= scaleY; |
| 71 | mFollowPosOffset.y *= scaleY; |
| 72 | } |
| 73 | |
| 74 | private: |
| 75 | const char* mName; |
| 76 | HitSensorType mSensorType; |
| 77 | sead::Vector3f mPos = {0.0f, 0.0f, 0.0f}; |
| 78 | f32 mRadius; |
| 79 | u16 mMaxSensorCount; |
| 80 | u16 mSensorCount = 0; |
| 81 | HitSensor** mSensors = nullptr; |
| 82 | SensorSortCmpFunc* mSortFunctionPtr = nullptr; |
| 83 | SensorHitGroup* mHitGroup = nullptr; |
| 84 | bool mIsValidBySystem = false; |
| 85 | bool mIsValid = true; |
| 86 | bool _3a[4]; |
| 87 | u16 _3e; |
| 88 | LiveActor* mParentActor; |
| 89 | const sead::Vector3f* mFollowPos; |
| 90 | const sead::Matrix34f* mFollowMtx; |
| 91 | sead::Vector3f mFollowPosOffset; |
| 92 | |
| 93 | friend class HitSensorDirector; |
| 94 | friend class HitSensorKeeper; |
| 95 | }; |
| 96 | } // namespace al |
| 97 | |