diff --git a/data/file_list.yml b/data/file_list.yml index 64c53263..ee388011 100644 --- a/data/file_list.yml +++ b/data/file_list.yml @@ -66674,64 +66674,64 @@ MapObj/DoorCity.o: - offset: 0x25fe38 size: 120 label: _ZN8DoorCityC2EPKc - status: NotDecompiled + status: Matching - offset: 0x25feb0 size: 132 label: _ZN8DoorCityC1EPKc - status: NotDecompiled + status: Matching - offset: 0x25ff34 size: 304 label: _ZN8DoorCity4initERKN2al13ActorInitInfoE - status: NotDecompiled + status: Matching - offset: 0x260064 size: 12 label: _ZN8DoorCity13onStageSwitchEv - status: NotDecompiled + status: Matching - offset: 0x260070 size: 4 label: _ZN8DoorCity15listenSwitchOffEv - status: NotDecompiled + status: Matching - offset: 0x260074 size: 60 label: _ZN8DoorCity11exeWaitOpenEv - status: NotDecompiled + status: Matching - offset: 0x2600b0 size: 96 label: _ZN8DoorCity7exeOpenEv - status: NotDecompiled + status: Matching - offset: 0x260110 size: 88 label: _ZN8DoorCity12exeWaitCloseEv - status: NotDecompiled + status: Matching - offset: 0x260168 size: 64 label: _ZNK12_GLOBAL__N_119DoorCityNrvWaitOpen7executeEPN2al11NerveKeeperE - status: NotDecompiled + status: Matching guess: true - offset: 0x2601a8 size: 92 label: _ZNK12_GLOBAL__N_120DoorCityNrvWaitClose7executeEPN2al11NerveKeeperE - status: NotDecompiled + status: Matching guess: true - offset: 0x260204 size: 100 label: _ZNK12_GLOBAL__N_115DoorCityNrvOpen7executeEPN2al11NerveKeeperE - status: NotDecompiled + status: Matching guess: true - offset: 0x260268 size: 28 label: _ZNK2al10FunctorV0MIP8DoorCityMS1_FvvEEclEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x260284 size: 76 label: _ZNK2al10FunctorV0MIP8DoorCityMS1_FvvEE5cloneEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x2602d0 size: 4 label: _ZN2al10FunctorV0MIP8DoorCityMS1_FvvEED0Ev - status: NotDecompiled + status: Matching lazy: true MapObj/DoorSnow.o: '.text': @@ -134196,7 +134196,7 @@ Scene/ProjectActorFactory.o: - offset: 0x4b7dbc size: 52 label: _ZN2al19createActorFunctionI8DoorCityEEPNS_9LiveActorEPKc - status: NotDecompiled + status: Matching lazy: true - offset: 0x4b7df0 size: 52 diff --git a/src/MapObj/DoorCity.cpp b/src/MapObj/DoorCity.cpp new file mode 100644 index 00000000..c4757d39 --- /dev/null +++ b/src/MapObj/DoorCity.cpp @@ -0,0 +1,77 @@ +#include "MapObj/DoorCity.h" + +#include "Library/Base/StringUtil.h" +#include "Library/LiveActor/ActorActionFunction.h" +#include "Library/LiveActor/ActorCollisionFunction.h" +#include "Library/LiveActor/ActorInitUtil.h" +#include "Library/Nerve/NerveSetupUtil.h" +#include "Library/Nerve/NerveUtil.h" +#include "Library/Placement/PlacementFunction.h" +#include "Library/Stage/StageSwitchUtil.h" +#include "Library/Thread/FunctorV0M.h" + +#include "System/GameDataFunction.h" + +namespace { +NERVE_IMPL(DoorCity, Open); +NERVE_IMPL(DoorCity, WaitOpen); +NERVE_IMPL(DoorCity, WaitClose); + +NERVES_MAKE_NOSTRUCT(DoorCity, Open, WaitOpen, WaitClose); +} // namespace + +DoorCity::DoorCity(const char* name) : al::LiveActor(name) {} + +void DoorCity::init(const al::ActorInitInfo& info) { + using DoorCityFunctor = al::FunctorV0M; + + al::initActor(this, info); + const char* initState = nullptr; + al::getStringArg(&initState, info, "InitState"); + + if (al::isEqualString(initState, "Open")) { + al::initNerve(this, &WaitOpen, 0); + al::invalidateCollisionParts(this); + } else if (al::isEqualString(initState, "Close")) { + al::initNerve(this, &WaitClose, 0); + al::listenStageSwitchOnStart(this, DoorCityFunctor(this, &DoorCity::onStageSwitch)); + } else { + kill(); + return; + } + + makeActorAlive(); + + al::listenStageSwitchOn(this, "SwitchLightOff", + DoorCityFunctor(this, &DoorCity::listenSwitchOff)); +} + +void DoorCity::onStageSwitch() { + al::setNerve(this, &Open); +} + +void DoorCity::listenSwitchOff() {} + +void DoorCity::exeWaitOpen() { + if (al::isFirstStep(this)) + al::startAction(this, "OpenWait"); +} + +void DoorCity::exeOpen() { + if (al::isFirstStep(this)) + al::startAction(this, "Open"); + + if (al::isActionEnd(this)) { + al::invalidateCollisionParts(this); + al::setNerve(this, &WaitOpen); + } +} + +void DoorCity::exeWaitClose() { + if (al::isFirstStep(this)) { + if (GameDataFunction::getScenarioNo(this) == 1) + al::tryStartAction(this, "Blink"); + else + al::tryStartAction(this, "CloseWait"); + } +} diff --git a/src/MapObj/DoorCity.h b/src/MapObj/DoorCity.h new file mode 100644 index 00000000..c63eb95f --- /dev/null +++ b/src/MapObj/DoorCity.h @@ -0,0 +1,18 @@ +#pragma once + +#include "Library/LiveActor/LiveActor.h" + +class DoorCity : public al::LiveActor { +public: + DoorCity(const char* name); + + void init(const al::ActorInitInfo& info) override; + + void onStageSwitch(); + void listenSwitchOff(); + void exeWaitOpen(); + void exeOpen(); + void exeWaitClose(); +}; + +static_assert(sizeof(DoorCity) == 0x108); diff --git a/src/Scene/ProjectActorFactory.cpp b/src/Scene/ProjectActorFactory.cpp index 489fbab1..41bddf29 100644 --- a/src/Scene/ProjectActorFactory.cpp +++ b/src/Scene/ProjectActorFactory.cpp @@ -76,6 +76,7 @@ #include "MapObj/ChurchDoor.h" #include "MapObj/CitySignal.h" #include "MapObj/CoinCollectHintObj.h" +#include "MapObj/DoorCity.h" #include "MapObj/Doshi.h" #include "MapObj/ElectricWire/ElectricWire.h" #include "MapObj/FireDrum2D.h" @@ -275,7 +276,7 @@ const al::NameToCreator sProjectActorFactoryEntries[] {"Doshi", al::createActorFunction}, {"DoorAreaChange", nullptr}, {"DoorAreaChangeCap", nullptr}, - {"DoorCity", nullptr}, + {"DoorCity", al::createActorFunction}, {"DoorSnow", nullptr}, {"DoorWarp", nullptr}, {"DoorWarpStageChange", nullptr},