player: Add PlayerPainPartsKeeper

This commit is contained in:
MonsterDruide1 2021-09-03 16:38:53 +02:00
parent aae2a4c112
commit 8d74df619e
6 changed files with 163 additions and 8 deletions

View File

@ -28131,14 +28131,14 @@ Address,Quality,Size,Name
0x000000710045ec88,U,000084,_ZN12PlayerOxygen6reduceEv
0x000000710045ecdc,U,000040,_ZN12PlayerOxygen8recoveryEv
0x000000710045ed04,U,000040,_ZNK12PlayerOxygen15isTriggerDamageEv
0x000000710045ed2c,U,000032,_ZN21PlayerPainPartsKeeperC2EPKN2al9LiveActorEPK17PlayerCostumeInfo
0x000000710045ed4c,U,000004,_ZN21PlayerPainPartsKeeper6updateEv
0x000000710045ed50,U,000164,_ZN21PlayerPainPartsKeeper12updateNeedleEv
0x000000710045edf4,U,000060,_ZN21PlayerPainPartsKeeper13resetPositionEv
0x000000710045ee30,U,000064,_ZNK21PlayerPainPartsKeeper16isEnableNosePainEv
0x000000710045ee70,U,000016,_ZNK21PlayerPainPartsKeeper21isInvalidNoseDynamicsEv
0x000000710045ee80,U,000272,_ZN21PlayerPainPartsKeeper16createNoseNeedleEPK17PlayerModelHolderRKN2al13ActorInitInfoE
0x000000710045ef90,U,000112,_ZN21PlayerPainPartsKeeper12appearNeedleEv
0x000000710045ed2c,O,000032,_ZN21PlayerPainPartsKeeperC2EPKN2al9LiveActorEPK17PlayerCostumeInfo
0x000000710045ed4c,O,000004,_ZN21PlayerPainPartsKeeper6updateEv
0x000000710045ed50,O,000164,_ZN21PlayerPainPartsKeeper12updateNeedleEv
0x000000710045edf4,O,000060,_ZN21PlayerPainPartsKeeper13resetPositionEv
0x000000710045ee30,O,000064,_ZNK21PlayerPainPartsKeeper16isEnableNosePainEv
0x000000710045ee70,O,000016,_ZNK21PlayerPainPartsKeeper21isInvalidNoseDynamicsEv
0x000000710045ee80,m,000272,_ZN21PlayerPainPartsKeeper16createNoseNeedleEPK17PlayerModelHolderRKN2al13ActorInitInfoE
0x000000710045ef90,m,000112,_ZN21PlayerPainPartsKeeper12appearNeedleEv
0x000000710045f000,U,000084,_ZN19PlayerPlayRecordMtxC2Ev
0x000000710045f054,U,000032,_ZN19PlayerPlayRecordMtx11startRecordERKN4sead8Matrix34IfEE
0x000000710045f074,U,000068,_ZN19PlayerPlayRecordMtx13recordViewMtxERKN4sead8Matrix34IfEE

Can't render this file because it is too large.

38
lib/al/model/PartsModel.h Normal file
View File

@ -0,0 +1,38 @@
#pragma once
#include <math/seadMatrix.h>
#include <math/seadVector.h>
#include "al/LiveActor/LiveActor.h"
namespace al {
class PartsModel : public al::LiveActor {
public:
PartsModel(const char*);
void initPartsDirect(al::LiveActor*, const al::ActorInitInfo&, char const*, const sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, bool);
void initPartsSuffix(al::LiveActor*, const al::ActorInitInfo&, char const*, char const*, const sead::Matrix34f*, bool);
void initPartsMtx(al::LiveActor*, const al::ActorInitInfo&, char const*, const sead::Matrix34f*, bool);
void initPartsFixFile(al::LiveActor*, const al::ActorInitInfo&, char const*, char const*, char const*);
void initPartsFixFileNoRegister(al::LiveActor*, const al::ActorInitInfo&, char const*, char const*, char const*);
void endClipped() override;
void updatePose();
void calcAnim() override;
void attackSensor(al::HitSensor*, al::HitSensor*) override;
bool receiveMsg(const al::SensorMsg*, al::HitSensor*, al::HitSensor*) override;
void offSyncAppearAndHide();
void onSyncAppearAndHide();
private:
al::LiveActor *mLiveActor;
sead::Matrix34f *_110;
bool mUseLocalTransforms;
sead::Vector3f mLocalTrans;
sead::Vector3f mLocalRotate;
sead::Vector3f mLocalScale;
bool mUseFollowMtxScale;
bool mUseLocalScale;
bool mUpdate;
};
}

View File

@ -0,0 +1,31 @@
#pragma once
namespace al {
class LiveActor;
class ActorInitInfo;
class PartsModel;
}
class PlayerCostumeInfo;
class PlayerModelHolder;
class PlayerPainPartsKeeper {
public:
PlayerPainPartsKeeper(const al::LiveActor*, const PlayerCostumeInfo*);
void update();
void updateNeedle();
void resetPosition();
bool isEnableNosePain() const;
bool isInvalidNoseDynamics() const;
void createNoseNeedle(const PlayerModelHolder*, const al::ActorInitInfo&);
void appearNeedle();
private:
const al::LiveActor *mLiveActor;
const PlayerCostumeInfo *mPlayerCostumeInfo;
float mModelAlphaMask = 1;
bool mEnableTimer = true;
al::LiveActor *mPlayerFaceActor = nullptr;
al::PartsModel *mNeedlesActor = nullptr;
int mTimer = 0;
};

View File

@ -1,5 +1,6 @@
#pragma once
#include <math/seadMatrix.h>
#include "al/LiveActor/LiveActor.h"
namespace al {
@ -14,5 +15,12 @@ namespace al {
void showModelIfHide(const LiveActor*);
void setModelAlphaMask(const LiveActor*, float);
void resetPosition(const LiveActor*);
const LiveActor* getSubActor(const LiveActor*, const char*); //NOTE: unknown return type
sead::Matrix34f* getJointMtxPtr(const LiveActor*, const char*); //return type might be const
void onSyncClippingSubActor(LiveActor*, const LiveActor*);
void onSyncHideSubActor(LiveActor*, const LiveActor*);
void onSyncAlphaMaskSubActor(LiveActor*, const LiveActor*);
void setMaterialProgrammable(al::LiveActor*);
void startAction(al::LiveActor*, char const*);
}

View File

@ -2,5 +2,6 @@ target_sources(odyssey PRIVATE
PlayerActorHakoniwa.cpp
PlayerCostumeInfo.cpp
PlayerModelHolder.cpp
PlayerPainPartsKeeper.cpp
PlayerTrigger.cpp
)

View File

@ -0,0 +1,77 @@
#include "al/player/PlayerPainPartsKeeper.h"
#include "al/model/PartsModel.h"
#include "al/player/PlayerCostumeInfo.h"
#include "al/player/PlayerModelHolder.h"
#include "al/player/rsPlayerState.h"
#include "al/util/LiveActorUtil.h"
PlayerPainPartsKeeper::PlayerPainPartsKeeper(const al::LiveActor* liveActor, const PlayerCostumeInfo* costumeInfo) : mLiveActor(liveActor), mPlayerCostumeInfo(costumeInfo) {}
void PlayerPainPartsKeeper::update() {
updateNeedle();
}
void PlayerPainPartsKeeper::updateNeedle() {
if(!mNeedlesActor || al::isDead(mNeedlesActor))
return;
if(!mPlayerCostumeInfo->isPreventHeadPain() || !rs::isGuardNosePainCap(mLiveActor)){
al::setModelAlphaMask(mNeedlesActor, mModelAlphaMask);
if(al::isHideModel(mPlayerFaceActor))
al::hideModelIfShow(mNeedlesActor);
else
al::showModelIfHide(mNeedlesActor);
if(mEnableTimer)
mTimer++;
if(mTimer < 3600)
return;
}
mNeedlesActor->kill();
}
void PlayerPainPartsKeeper::resetPosition() {
if(mNeedlesActor && al::isAlive(mNeedlesActor))
al::resetPosition(mNeedlesActor);
}
bool PlayerPainPartsKeeper::isEnableNosePain() const {
if(mPlayerCostumeInfo->isPreventHeadPain() && rs::isGuardNosePainCap(mLiveActor))
return false;
return true;
}
bool PlayerPainPartsKeeper::isInvalidNoseDynamics() const {
return mNeedlesActor && al::isAlive(mNeedlesActor);
}
static sead::Vector3f initialRotation = {0, 270, 180};
void PlayerPainPartsKeeper::createNoseNeedle(const PlayerModelHolder* playerModelHolder, const al::ActorInitInfo& actorInitInfo) {
auto* playerFaceActor = playerModelHolder->findModelActor("Normal");
auto* faceSubActor = al::getSubActor(playerFaceActor, "");
mPlayerFaceActor = playerFaceActor;
mNeedlesActor = new al::PartsModel("鼻のトゲ");
mNeedlesActor->initPartsDirect(playerFaceActor, actorInitInfo, "CactusMiniNeedle", al::getJointMtxPtr(faceSubActor, "Nose"), sead::Vector3f::zero, initialRotation, {1, 1, 1}, false);
al::onSyncClippingSubActor(playerFaceActor, mNeedlesActor);
al::onSyncHideSubActor(playerFaceActor, mNeedlesActor);
al::onSyncAlphaMaskSubActor(playerFaceActor, mNeedlesActor);
al::setMaterialProgrammable(mNeedlesActor);
mNeedlesActor->makeActorDead();
}
void PlayerPainPartsKeeper::appearNeedle(){
mTimer = 0;
if(al::isAlive(mNeedlesActor))
return;
mNeedlesActor->makeActorAlive();
const char* actionName;
if(mPlayerCostumeInfo->isHidePainNose())
actionName = "NoseOff";
else
actionName = "NoseOn";
al::startAction(mNeedlesActor, actionName);
}