Skip to content

Commit

Permalink
MapObj: Implement ChurchDoor
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsterDruide1 committed Oct 19, 2024
1 parent 1859701 commit 1a6feeb
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 26 deletions.
50 changes: 25 additions & 25 deletions data/odyssey_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -14518,30 +14518,30 @@ Address,Quality,Size,Name
0x000000710024b30c,U,000004,_ZN21CheckpointFlagWatcherD0Ev
0x000000710024b310,U,000008,_ZNK21CheckpointFlagWatcher17getCameraDirectorEv
0x000000710024b318,U,000008,_ZThn8_NK21CheckpointFlagWatcher17getCameraDirectorEv
0x000000710024b320,U,000124,_ZN10ChurchDoorC2EPKc
0x000000710024b39c,U,000136,_ZN10ChurchDoorC1EPKc
0x000000710024b424,U,000200,_ZN10ChurchDoor4initERKN2al13ActorInitInfoE
0x000000710024b4ec,U,000324,_ZN10ChurchDoor10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_
0x000000710024b630,U,000016,_ZNK10ChurchDoor10isOpenWaitEv
0x000000710024b640,U,000012,_ZNK10ChurchDoor17isDemoEnterChurchEv
0x000000710024b64c,U,000012,_ZN10ChurchDoor20startDemoEnterChurchEv
0x000000710024b658,U,000016,_ZN10ChurchDoor18endDemoEnterChurchEv
0x000000710024b668,U,000060,_ZN10ChurchDoor13exeCloseWait1Ev
0x000000710024b6a4,U,000068,_ZN10ChurchDoor8exeOpen1Ev
0x000000710024b6e8,U,000060,_ZN10ChurchDoor13exeCloseWait2Ev
0x000000710024b724,U,000068,_ZN10ChurchDoor8exeOpen2Ev
0x000000710024b768,U,000060,_ZN10ChurchDoor13exeCloseWait3Ev
0x000000710024b7a4,U,000076,_ZN10ChurchDoor8exeOpen3Ev
0x000000710024b7f0,U,000108,_ZN10ChurchDoor11exeOpenWaitEv
0x000000710024b85c,U,000004,_ZN10ChurchDoor18exeDemoEnterChurchEv
0x000000710024b860,U,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait17executeEPN2al11NerveKeeperE
0x000000710024b8a0,U,000112,_ZNK12_GLOBAL__N_121ChurchDoorNrvOpenWait7executeEPN2al11NerveKeeperE
0x000000710024b910,U,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen17executeEPN2al11NerveKeeperE
0x000000710024b958,U,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen27executeEPN2al11NerveKeeperE
0x000000710024b9a0,U,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait27executeEPN2al11NerveKeeperE
0x000000710024b9e0,U,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait37executeEPN2al11NerveKeeperE
0x000000710024ba20,U,000080,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen37executeEPN2al11NerveKeeperE
0x000000710024ba70,U,000008,_ZNK12_GLOBAL__N_128ChurchDoorNrvDemoEnterChurch7executeEPN2al11NerveKeeperE
0x000000710024b320,O,000124,_ZN10ChurchDoorC2EPKc
0x000000710024b39c,O,000136,_ZN10ChurchDoorC1EPKc
0x000000710024b424,O,000200,_ZN10ChurchDoor4initERKN2al13ActorInitInfoE
0x000000710024b4ec,O,000324,_ZN10ChurchDoor10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_
0x000000710024b630,O,000016,_ZNK10ChurchDoor10isOpenWaitEv
0x000000710024b640,O,000012,_ZNK10ChurchDoor17isDemoEnterChurchEv
0x000000710024b64c,O,000012,_ZN10ChurchDoor20startDemoEnterChurchEv
0x000000710024b658,O,000016,_ZN10ChurchDoor18endDemoEnterChurchEv
0x000000710024b668,O,000060,_ZN10ChurchDoor13exeCloseWait1Ev
0x000000710024b6a4,O,000068,_ZN10ChurchDoor8exeOpen1Ev
0x000000710024b6e8,O,000060,_ZN10ChurchDoor13exeCloseWait2Ev
0x000000710024b724,O,000068,_ZN10ChurchDoor8exeOpen2Ev
0x000000710024b768,O,000060,_ZN10ChurchDoor13exeCloseWait3Ev
0x000000710024b7a4,O,000076,_ZN10ChurchDoor8exeOpen3Ev
0x000000710024b7f0,O,000108,_ZN10ChurchDoor11exeOpenWaitEv
0x000000710024b85c,O,000004,_ZN10ChurchDoor18exeDemoEnterChurchEv
0x000000710024b860,O,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait17executeEPN2al11NerveKeeperE
0x000000710024b8a0,O,000112,_ZNK12_GLOBAL__N_121ChurchDoorNrvOpenWait7executeEPN2al11NerveKeeperE
0x000000710024b910,O,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen17executeEPN2al11NerveKeeperE
0x000000710024b958,O,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen27executeEPN2al11NerveKeeperE
0x000000710024b9a0,O,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait27executeEPN2al11NerveKeeperE
0x000000710024b9e0,O,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait37executeEPN2al11NerveKeeperE
0x000000710024ba20,O,000080,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen37executeEPN2al11NerveKeeperE
0x000000710024ba70,O,000008,_ZNK12_GLOBAL__N_128ChurchDoorNrvDemoEnterChurch7executeEPN2al11NerveKeeperE
0x000000710024ba78,U,000124,_ZN12CityBuildingC2EPKc
0x000000710024baf4,U,000136,_ZN12CityBuildingC1EPKc
0x000000710024bb7c,U,000412,_ZN12CityBuilding4initERKN2al13ActorInitInfoE
Expand Down Expand Up @@ -30075,7 +30075,7 @@ Address,Quality,Size,Name
0x00000071004b71bc,U,000052,_ZN2al19createActorFunctionI5ChairEEPNS_9LiveActorEPKc
0x00000071004b71f0,U,000052,_ZN2al19createActorFunctionI14CheckpointFlagEEPNS_9LiveActorEPKc
0x00000071004b7224,U,000052,_ZN2al19createActorFunctionI14ChorobonHolderEEPNS_9LiveActorEPKc
0x00000071004b7258,U,000052,_ZN2al19createActorFunctionI10ChurchDoorEEPNS_9LiveActorEPKc
0x00000071004b7258,O,000052,_ZN2al19createActorFunctionI10ChurchDoorEEPNS_9LiveActorEPKc
0x00000071004b728c,U,000052,_ZN2al19createActorFunctionI12CityBuildingEEPNS_9LiveActorEPKc
0x00000071004b72c0,U,000052,_ZN2al19createActorFunctionI15CityStreetlightEEPNS_9LiveActorEPKc
0x00000071004b72f4,U,000052,_ZN2al19createActorFunctionI13CityWorldSignEEPNS_9LiveActorEPKc
Expand Down
3 changes: 3 additions & 0 deletions lib/al/Library/Bgm/BgmLineFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace al {
class Resource;
class IUseAudioKeeper;

class BgmDataBase {
public:
static BgmDataBase* create(const char*, const char*);

BgmDataBase(const Resource*, const Resource*);
};

void startBgmSituation(const IUseAudioKeeper*, const char*, bool, bool);
} // namespace al
143 changes: 143 additions & 0 deletions src/MapObj/ChurchDoor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#include "MapObj/ChurchDoor.h"

#include "Library/Bgm/BgmLineFunction.h"
#include "Library/LiveActor/ActorActionFunction.h"
#include "Library/LiveActor/ActorCollisionFunction.h"
#include "Library/LiveActor/ActorInitInfo.h"
#include "Library/LiveActor/ActorSensorFunction.h"
#include "Library/LiveActor/ActorSensorMsgFunction.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Nerve/NerveUtil.h"

#include "Util/Sensor.h"
#include "Util/StageSensorMsgFunction.h"

namespace {
NERVE_IMPL(ChurchDoor, DemoEnterChurch);
NERVE_IMPL(ChurchDoor, CloseWait1);
NERVE_IMPL(ChurchDoor, OpenWait);
NERVE_IMPL(ChurchDoor, Open1);
NERVE_IMPL(ChurchDoor, Open2);
NERVE_IMPL(ChurchDoor, CloseWait2);
NERVE_IMPL(ChurchDoor, CloseWait3);
NERVE_IMPL(ChurchDoor, Open3);

NERVES_MAKE_NOSTRUCT(ChurchDoor, DemoEnterChurch, CloseWait1, OpenWait, Open1, Open2, CloseWait2,
CloseWait3, Open3);
} // namespace

ChurchDoor::ChurchDoor(const char* name) : al::LiveActor(name) {}

void ChurchDoor::init(const al::ActorInitInfo& info) {
al::initActor(this, info);
al::initNerve(this, &CloseWait1, 0);

if (isCurrentStageMoonWeddingRoom(this)) {
mSaveObjInfo = rs::createSaveObjInfoWriteSaveData(info);
if (rs::isOnSaveObjInfo(mSaveObjInfo)) {
al::invalidateCollisionParts(this);
al::setNerve(this, &OpenWait);
makeActorAlive();
return;
}
}

al::startBgmSituation(this, "CloseChurchDoor", true, true);
makeActorAlive();
}

bool ChurchDoor::receiveMsg(const al::SensorMsg* msg, al::HitSensor* source,
al::HitSensor* target) {
if (rs::isMsgPlayerDisregardTargetMarker(msg))
return true;

if (rs::isMsgCapTouchWall(msg)) {
if ((al::isNerve(this, &Open1) || al::isNerve(this, &Open2)) &&
al::isLessEqualStep(this, 10))
return true;

rs::requestHitReactionToAttacker(msg, source, al::getSensorPos(source));

if (al::isNerve(this, &CloseWait1)) {
al::startHitReaction(this, "ヒット1回目");
al::setNerve(this, &Open1);
} else if (al::isNerve(this, &CloseWait2) || al::isNerve(this, &Open1)) {
al::startHitReaction(this, "ヒット2回目");
al::setNerve(this, &Open2);
} else if (al::isNerve(this, &CloseWait3) || al::isNerve(this, &Open2)) {
al::startHitReaction(this, "ヒット3回目");
al::setNerve(this, &Open3);
}
return true;
}

return false;
}

bool ChurchDoor::isOpenWait() const {
return al::isNerve(this, &OpenWait);
}

bool ChurchDoor::isDemoEnterChurch() const {
return al::isNerve(this, &DemoEnterChurch);
}

void ChurchDoor::startDemoEnterChurch() {
al::setNerve(this, &DemoEnterChurch);
}

void ChurchDoor::endDemoEnterChurch() {
al::setNerve(this, &OpenWait);
}

void ChurchDoor::exeCloseWait1() {
if (al::isFirstStep(this))
al::startAction(this, "CloseWait1");
}

void ChurchDoor::exeOpen1() {
if (al::isFirstStep(this))
al::startAction(this, "Open1");

al::setNerveAtActionEnd(this, &CloseWait2);
}

void ChurchDoor::exeCloseWait2() {
if (al::isFirstStep(this))
al::startAction(this, "CloseWait2");
}

void ChurchDoor::exeOpen2() {
if (al::isFirstStep(this))
al::startAction(this, "Open2");

al::setNerveAtActionEnd(this, &CloseWait3);
}

void ChurchDoor::exeCloseWait3() {
if (al::isFirstStep(this))
al::startAction(this, "CloseWait3");
}

void ChurchDoor::exeOpen3() {
if (al::isFirstStep(this)) {
al::startAction(this, "Open3");
al::invalidateCollisionParts(this);
}

al::setNerveAtActionEnd(this, &OpenWait);
}

void ChurchDoor::exeOpenWait() {
if (al::isFirstStep(this)) {
al::startAction(this, "OpenWait");

if (isCurrentStageMoonWeddingRoom(this))
rs::onSaveObjInfo(mSaveObjInfo);
}
}

void ChurchDoor::exeDemoEnterChurch() {
if (al::isFirstStep(this)) {
}
}
39 changes: 39 additions & 0 deletions src/MapObj/ChurchDoor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "Library/Base/StringUtil.h"
#include "Library/LiveActor/LiveActor.h"

#include "System/GameDataFunction.h"

class SaveObjInfo;

class ChurchDoor : public al::LiveActor {
public:
ChurchDoor(const char* name);

void init(const al::ActorInitInfo& info) override;
bool receiveMsg(const al::SensorMsg* msg, al::HitSensor* source,
al::HitSensor* target) override;

bool isOpenWait() const;
bool isDemoEnterChurch() const;
void startDemoEnterChurch();
void endDemoEnterChurch();

void exeCloseWait1();
void exeOpen1();
void exeCloseWait2();
void exeOpen2();
void exeCloseWait3();
void exeOpen3();
void exeOpenWait();
void exeDemoEnterChurch();

private:
SaveObjInfo* mSaveObjInfo = nullptr;
};

inline bool isCurrentStageMoonWeddingRoom(const al::LiveActor* actor) {
return al::isEqualString("MoonWorldWeddingRoomStage",
GameDataFunction::getCurrentStageName(actor));
}
3 changes: 2 additions & 1 deletion src/Scene/ProjectActorFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Library/Obj/AllDeadWatcher.h"

#include "MapObj/AnagramAlphabet.h"
#include "MapObj/ChurchDoor.h"
#include "MapObj/CitySignal.h"
#include "MapObj/FireDrum2D.h"
#include "MapObj/WorldMapEarth.h"
Expand Down Expand Up @@ -114,7 +115,7 @@ static al::NameToCreator<al::ActorCreatorFunction> sProjectActorFactoryEntries[]
{"Chair", nullptr},
{"CheckpointFlag", nullptr},
{"ChorobonHolder", nullptr},
{"ChurchDoor", nullptr},
{"ChurchDoor", al::createActorFunction<ChurchDoor>},
{"CityBuilding", nullptr},
{"CityStreetlight", nullptr},
{"CityWorldSign", nullptr},
Expand Down
6 changes: 6 additions & 0 deletions src/System/GameDataHolderAccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class IUseSceneObjHolder;
class SceneObjHolder;
class ISceneObj;
class LiveActor;
class ActorInitInfo;
} // namespace al
class SaveObjInfo;

class GameDataHolderAccessor : public GameDataHolderWriter { // maybe extends GameDataHolderWriter?
public:
Expand All @@ -18,4 +20,8 @@ class GameDataHolderAccessor : public GameDataHolderWriter { // maybe extends G
namespace rs {
bool isInvalidChangeStage(const al::LiveActor* actor);
bool isKidsMode(const al::LiveActor* actor);

SaveObjInfo* createSaveObjInfoWriteSaveData(const al::ActorInitInfo&);
void onSaveObjInfo(SaveObjInfo*);
bool isOnSaveObjInfo(const SaveObjInfo*);
} // namespace rs
17 changes: 17 additions & 0 deletions src/Util/StageSensorMsgFunction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <math/seadVector.h>

namespace al {
class HitSensor;
class SensorMsg;
} // namespace al

namespace rs {

bool isMsgPlayerDisregardTargetMarker(const al::SensorMsg* msg);

void requestHitReactionToAttacker(const al::SensorMsg*, const al::HitSensor*,
const sead::Vector3f&);

} // namespace rs

0 comments on commit 1a6feeb

Please sign in to comment.