Library/MapObj: Implement BreakMapPartsBase (#134)

This commit is contained in:
Fuzzy2319 2024-07-22 20:59:48 +02:00 committed by GitHub
parent a8760d7858
commit 508445ef8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 273 additions and 22 deletions

View File

@ -13329,7 +13329,7 @@ Address,Quality,Size,Name
0x000000710021de1c,U,000324,_ZN9BlockHard10startBreakEPKN2al9SensorMsgEPNS0_9HitSensorES5_
0x000000710021df60,U,000008,_ZNK9BlockHard16getJudgeFunctionEPKc
0x000000710021df68,U,000012,_ZN9BlockHard24validateIncludeShineChipEv
0x000000710021df74,U,000008,_ZNK2al17BreakMapPartsBase16getJudgeFunctionEPKc
0x000000710021df74,O,000008,_ZNK2al17BreakMapPartsBase16getJudgeFunctionEPKc
0x000000710021df7c,U,000172,_ZN13BlockQuestionC2EPKc
0x000000710021e028,U,000184,_ZN13BlockQuestionC1EPKc
0x000000710021e0e0,U,000672,_ZN13BlockQuestion4initERKN2al13ActorInitInfoE
@ -54490,9 +54490,9 @@ Address,Quality,Size,Name
0x00000071008a5da8,U,000028,_ZNK2al10FunctorV0MIPNS_12FogRequesterEMS1_FvvEEclEv
0x00000071008a5dc4,U,000076,_ZNK2al10FunctorV0MIPNS_12FogRequesterEMS1_FvvEE5cloneEv
0x00000071008a5e10,U,000004,_ZN2al10FunctorV0MIPNS_12FogRequesterEMS1_FvvEED0Ev
0x00000071008a5e14,U,000028,_ZNK2al10FunctorV0MIPNS_9LiveActorEMS1_FvvEEclEv
0x00000071008a5e30,U,000076,_ZNK2al10FunctorV0MIPNS_9LiveActorEMS1_FvvEE5cloneEv
0x00000071008a5e7c,U,000004,_ZN2al10FunctorV0MIPNS_9LiveActorEMS1_FvvEED0Ev
0x00000071008a5e14,O,000028,_ZNK2al10FunctorV0MIPNS_9LiveActorEMS1_FvvEEclEv
0x00000071008a5e30,O,000076,_ZNK2al10FunctorV0MIPNS_9LiveActorEMS1_FvvEE5cloneEv
0x00000071008a5e7c,O,000004,_ZN2al10FunctorV0MIPNS_9LiveActorEMS1_FvvEED0Ev
0x00000071008a5e80,U,000004,gpuErrorCallback
0x00000071008a5e84,U,000136,_ZN2al15GameFrameworkNxC1ERKN4sead15GameFrameworkNx9CreateArgE
0x00000071008a5f0c,U,001148,_ZN2al15GameFrameworkNx19createControllerMgrEPN4sead8TaskBaseE
@ -56199,7 +56199,7 @@ Address,Quality,Size,Name
0x00000071008de464,U,000080,_ZN2al9initNerveEPNS_9LiveActorEPKNS_5NerveEi
0x00000071008de4b4,U,000164,_ZN2al15initNerveActionEPNS_9LiveActorEPKcPN15alNerveFunction20NerveActionCollectorEi
0x00000071008de558,U,000148,_ZN2al24trySyncStageSwitchAppearEPNS_9LiveActorE
0x00000071008de5ec,U,000128,_ZN2al22trySyncStageSwitchKillEPNS_9LiveActorE
0x00000071008de5ec,O,000128,_ZN2al22trySyncStageSwitchKillEPNS_9LiveActorE
0x00000071008de66c,U,000228,_ZN2al31trySyncStageSwitchAppearAndKillEPNS_9LiveActorE
0x00000071008de750,U,000128,_ZN2al26tryListenStageSwitchAppearEPNS_9LiveActorE
0x00000071008de7d0,U,000084,_ZN2al24tryListenStageSwitchKillEPNS_9LiveActorE
@ -58145,19 +58145,19 @@ Address,Quality,Size,Name
0x0000007100910c34,U,000136,_ZN2al13BackHidePartsC1EPKc
0x0000007100910cbc,U,000144,_ZN2al13BackHideParts4initERKNS_13ActorInitInfoE
0x0000007100910d4c,U,000036,_ZN2al22BackHideDitherAnimatorD0Ev
0x0000007100910d70,U,000140,_ZN2al17BreakMapPartsBaseC2EPKc
0x0000007100910dfc,U,000152,_ZN2al17BreakMapPartsBaseC1EPKc
0x0000007100910e94,U,000464,_ZN2al17BreakMapPartsBase4initERKNS_13ActorInitInfoE
0x0000007100911064,U,000028,_ZN2al17BreakMapPartsBase18initAfterPlacementEv
0x0000007100911080,U,000036,_ZN2al17BreakMapPartsBase4killEv
0x00000071009110a4,U,000140,_ZN2al17BreakMapPartsBase8movementEv
0x0000007100911130,U,000068,_ZN2al17BreakMapPartsBase8calcAnimEv
0x0000007100911174,U,000016,_ZN2al17BreakMapPartsBase7exeWaitEv
0x0000007100911184,U,000300,_ZN2al17BreakMapPartsBase8exeBreakEv
0x00000071009112b0,U,000056,_ZN2al17BreakMapPartsBase19startBreakByProgramEv
0x00000071009112e8,U,000140,_ZN2al17BreakMapPartsBase10receiveMsgEPKNS_9SensorMsgEPNS_9HitSensorES5_
0x0000007100911374,U,000020,
0x0000007100911388,U,000008,
0x0000007100910d70,O,000140,_ZN2al17BreakMapPartsBaseC2EPKc
0x0000007100910dfc,O,000152,_ZN2al17BreakMapPartsBaseC1EPKc
0x0000007100910e94,O,000464,_ZN2al17BreakMapPartsBase4initERKNS_13ActorInitInfoE
0x0000007100911064,O,000028,_ZN2al17BreakMapPartsBase18initAfterPlacementEv
0x0000007100911080,O,000036,_ZN2al17BreakMapPartsBase4killEv
0x00000071009110a4,O,000140,_ZN2al17BreakMapPartsBase8movementEv
0x0000007100911130,O,000068,_ZN2al17BreakMapPartsBase8calcAnimEv
0x0000007100911174,O,000016,_ZN2al17BreakMapPartsBase7exeWaitEv
0x0000007100911184,O,000300,_ZN2al17BreakMapPartsBase8exeBreakEv
0x00000071009112b0,O,000056,_ZN2al17BreakMapPartsBase19startBreakByProgramEv
0x00000071009112e8,O,000140,_ZN2al17BreakMapPartsBase10receiveMsgEPKNS_9SensorMsgEPNS_9HitSensorES5_
0x0000007100911374,O,000020,_ZNK12_GLOBAL__N_124BreakMapPartsBaseNrvWait7executeEPN2al11NerveKeeperE
0x0000007100911388,O,000008,_ZNK12_GLOBAL__N_125BreakMapPartsBaseNrvBreak7executeEPN2al11NerveKeeperE
0x0000007100911390,U,000160,_ZN2al9ChildStepC2EPKcPNS_9LiveActorE
0x0000007100911430,U,000164,_ZN2al9ChildStepC1EPKcPNS_9LiveActorE
0x00000071009114d4,U,000108,_ZN2al9ChildStep4initERKNS_13ActorInitInfoE

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

View File

@ -0,0 +1,20 @@
#pragma once
#include <basis/seadTypes.h>
namespace al {
class AudioDirector;
class LayoutInitInfo;
class SimpleAudioUser : public IUseAudioKeeper {
public:
SimpleAudioUser(const char* name, AudioDirector* director);
SimpleAudioUser(const char* name, const ActorInitInfo& info);
SimpleAudioUser(const char* name, const LayoutInitInfo& info);
AudioKeeper* getAudioKeeper() const override;
private:
u8 padding[0x10];
};
} // namespace al

View File

@ -43,6 +43,8 @@ public:
void findMtxPtr(const char*);
void tryFindEffect(const char*);
bool get_21() const { return field_21; }
private:
const char* mName;
u32 mEffectCount;

View File

@ -0,0 +1,8 @@
#pragma once
namespace al {
class LiveActor;
bool isExistItemKeeper(const LiveActor* actor);
void setAppearItemOffset(const LiveActor* actor, const sead::Vector3f& offset);
} // namespace al

View File

@ -0,0 +1,17 @@
#include "Library/LiveActor/ActorInitFunction.h"
#include "Library/LiveActor/LiveActor.h"
#include "Library/Stage/StageSwitchKeeper.h"
#include "Library/Thread/FunctorV0M.h"
namespace al {
bool trySyncStageSwitchKill(LiveActor* actor) {
using LiveActorFunctor = FunctorV0M<LiveActor*, void (LiveActor::*)()>;
bool result = listenStageSwitchOnOffKill(actor, LiveActorFunctor(actor, &LiveActor::kill),
LiveActorFunctor(actor, &LiveActor::appear));
actor->makeActorAlive();
return result;
}
} // namespace al

View File

@ -11,6 +11,7 @@ namespace al {
class LiveActor;
class Resource;
class HitSensor;
class ActorInitInfo;
LiveActor* createLinksActorFromFactory(const ActorInitInfo& info, const char* linkName,
s32 linkNum);
@ -36,4 +37,5 @@ void initExecutorUpdate(LiveActor* actor, const ActorInitInfo& info, const char*
void initNerveAction(LiveActor* actor, const char* actionName,
alNerveFunction::NerveActionCollector* collector, s32 step);
void initMapPartsActor(LiveActor* actor, const ActorInitInfo& info, const char* name);
bool trySyncStageSwitchKill(LiveActor* actor);
} // namespace al

View File

@ -1,6 +1,7 @@
#include "Library/LiveActor/SubActorKeeper.h"
#include "Library/Base/StringUtil.h"
#include "Library/LiveActor/ActorInitInfo.h"
#include "Library/LiveActor/ActorModelFunction.h"
#include "Library/LiveActor/ActorResourceFunction.h"
#include "Library/LiveActor/ActorSensorFunction.h"

View File

@ -2,8 +2,6 @@
#include <basis/seadTypes.h>
#include "Library/LiveActor/ActorInitInfo.h"
// TODO: bring this up to sanae
// temp solution to figure out a solution to bitflag enums (stole this right from nvn headers)
#define AL_BITS(CLASS) \
@ -75,6 +73,7 @@ private:
namespace al {
class LiveActor;
class ActorInitInfo;
struct SubActorSync {
enum Enum {
@ -119,8 +118,8 @@ private:
};
void isExistSubActorKeeper(const LiveActor*);
LiveActor* getSubActor(const LiveActor*, const char*);
void tryGetSubActor(const LiveActor*, const char*);
LiveActor* getSubActor(const LiveActor*, const char*); // NOTE: unknown return type
LiveActor* tryGetSubActor(const LiveActor* actor, const char* subActorName);
void getSubActor(const LiveActor*, s32);
void getSubActorNum(const LiveActor*);
void offSyncClippingSubActor(LiveActor*, const LiveActor*);

View File

@ -0,0 +1,167 @@
#include "Library/MapObj/BreakMapPartsBase.h"
#include "Library/Audio/System/SimpleAudioUser.h"
#include "Library/Base/StringUtil.h"
#include "Library/Collision/PartsConnector.h"
#include "Library/Effect/EffectKeeper.h"
#include "Library/Item/ItemUtil.h"
#include "Library/LiveActor/ActorActionFunction.h"
#include "Library/LiveActor/ActorClippingFunction.h"
#include "Library/LiveActor/ActorCollisionFunction.h"
#include "Library/LiveActor/ActorInitFunction.h"
#include "Library/LiveActor/ActorModelFunction.h"
#include "Library/LiveActor/ActorMovementFunction.h"
#include "Library/LiveActor/ActorResourceFunction.h"
#include "Library/LiveActor/SubActorKeeper.h"
#include "Library/Math/MathRandomUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Obj/PartsFunction.h"
#include "Library/Placement/PlacementFunction.h"
#include "Library/Se/SeFunction.h"
#include "Library/Stage/StageSwitchKeeper.h"
#include "Library/Thread/FunctorV0M.h"
#include "Library/Yaml/ByamlIter.h"
#include "Library/Yaml/ByamlUtil.h"
namespace {
using namespace al;
NERVE_IMPL(BreakMapPartsBase, Wait)
NERVE_IMPL(BreakMapPartsBase, Break)
NERVES_MAKE_STRUCT(BreakMapPartsBase, Wait, Break)
} // namespace
namespace al {
static void syncStageSwitchMakeActorDead(LiveActor* actor) {
using LiveActorFunctor = FunctorV0M<LiveActor*, void (LiveActor::*)()>;
listenStageSwitchOnOffKill(actor, LiveActorFunctor(actor, &LiveActor::makeActorDead),
LiveActorFunctor(actor, &LiveActor::makeActorAlive));
actor->makeActorAlive();
}
BreakMapPartsBase::BreakMapPartsBase(const char* name) : LiveActor(name) {}
void BreakMapPartsBase::init(const ActorInitInfo& info) {
const char* suffix = nullptr;
tryGetStringArg(&suffix, info, "SuffixName");
if (suffix != nullptr && isEqualString(suffix, "None"))
suffix = nullptr;
initMapPartsActor(this, info, suffix);
initNerve(this, &NrvBreakMapPartsBase.Wait, 0);
ByamlIter iter;
bool isExistInitFile = tryGetActorInitFileIter(&iter, this, "InitBreakMapParts", nullptr);
const char* breakType = nullptr;
if (isExistInitFile) {
breakType = tryGetByamlKeyStringOrNULL(iter, "BreakType");
tryGetByamlV3f(&mItemOffset, iter, "ItemOffset");
tryGetByamlBool(&mIsExistHitReactionBreak, iter, "IsExistHitReactionBreak");
}
mJudgeFunction = getJudgeFunction(breakType);
mMtxConnector = tryCreateMtxConnector(this, info);
syncStageSwitchMakeActorDead(this);
if (isExistItemKeeper(this))
setAppearItemOffset(this, mItemOffset);
bool isPlaySuccessSe = false;
if (tryGetArg(&isPlaySuccessSe, info, "IsPlaySuccessSe") && isPlaySuccessSe)
mAudioKeeper = new SimpleAudioUser("SuccessSeObj", info);
}
void BreakMapPartsBase::initAfterPlacement() {
if (mMtxConnector == nullptr)
return;
attachMtxConnectorToCollision(mMtxConnector, this, false);
}
void BreakMapPartsBase::kill() {
LiveActor::kill();
tryOnSwitchDeadOn(this);
}
void BreakMapPartsBase::movement() {
if (!isNerve(this, &NrvBreakMapPartsBase.Wait) || mMtxConnector != nullptr) {
LiveActor::movement();
return;
}
if (getEffectKeeper() != nullptr && getEffectKeeper()->get_21())
getEffectKeeper()->update();
}
void BreakMapPartsBase::calcAnim() {
if (isNerve(this, &NrvBreakMapPartsBase.Wait) && mMtxConnector == nullptr)
return;
LiveActor::calcAnim();
}
void BreakMapPartsBase::exeWait() {
if (mMtxConnector != nullptr)
connectPoseQT(this, mMtxConnector);
}
void BreakMapPartsBase::exeBreak() {
if (isFirstStep(this)) {
LiveActor* subActor = tryGetSubActor(this, "壊れモデル");
if (subActor != nullptr)
subActor->appear();
subActor = tryGetSubActor(this, "残留モデル");
if (subActor != nullptr) {
subActor->appear();
if (isTraceModelRandomRotate(subActor))
addRotateAndRepeatY(subActor, getRandomDegree());
}
if (mIsExistHitReactionBreak)
startHitReaction(this, "破壊");
if (mAudioKeeper != nullptr)
startSe(mAudioKeeper, "Riddle");
if (!isExistAction(this, "Break")) {
kill();
} else {
startAction(this, "Break");
hideModelIfShow(this);
}
return;
}
kill();
}
void BreakMapPartsBase::startBreakByProgram() {
invalidateClipping(this);
invalidateCollisionParts(this);
setNerve(this, &NrvBreakMapPartsBase.Break);
}
bool BreakMapPartsBase::receiveMsg(const SensorMsg* message, HitSensor* source, HitSensor* target) {
if (isNerve(this, &NrvBreakMapPartsBase.Wait) && mJudgeFunction(message, source, target)) {
startBreakByProgram();
return true;
}
return false;
}
JudgeFuncPtr BreakMapPartsBase::getJudgeFunction(const char* name) const {
return nullptr;
}
} // namespace al

View File

@ -0,0 +1,32 @@
#pragma once
#include "Library/LiveActor/LiveActor.h"
namespace al {
class MtxConnector;
using JudgeFuncPtr = bool (*)(const SensorMsg* message, HitSensor* source, HitSensor* target);
class BreakMapPartsBase : public LiveActor {
public:
BreakMapPartsBase(const char* name);
void init(const ActorInitInfo& info) override;
void initAfterPlacement() override;
void kill() override;
void movement() override;
void calcAnim() override;
void exeWait();
void exeBreak();
void startBreakByProgram();
bool receiveMsg(const SensorMsg* message, HitSensor* source, HitSensor* target) override;
virtual JudgeFuncPtr getJudgeFunction(const char* name) const;
private:
JudgeFuncPtr mJudgeFunction = nullptr;
MtxConnector* mMtxConnector = nullptr;
sead::Vector3f mItemOffset = {0.0f, 0.0f, 0.0f};
bool mIsExistHitReactionBreak = false;
IUseAudioKeeper* mAudioKeeper = nullptr;
};
} // namespace al

View File

@ -16,4 +16,5 @@ CollisionObj* createCollisionObjMtx(const LiveActor* parent, const ActorInitInfo
Resource* res, const char* collisionFileName,
HitSensor* hitSensor, const sead::Matrix34f* joinMtx,
const char* suffix);
bool isTraceModelRandomRotate(const LiveActor* actor);
} // namespace al

View File

@ -55,4 +55,6 @@ bool listenStageSwitchOnOff(IUseStageSwitch* stageSwitchHolder, const char* even
bool listenStageSwitchOnOffAppear(IUseStageSwitch* stageSwitchHolder, const FunctorBase& actionOnOn,
const FunctorBase& actionOnOff);
bool listenStageSwitchOnKill(IUseStageSwitch* stageSwitchHolder, const FunctorBase& actionOnOn);
bool listenStageSwitchOnOffKill(IUseStageSwitch* stageSwitchHolder, const FunctorBase& actionOnOn,
const FunctorBase& actionOnOff);
} // namespace al