Modularize custom skeleton hooks (#5931)
This commit is contained in:
37
soh/soh/Enhancements/CustomSkeletons.cpp
Normal file
37
soh/soh/Enhancements/CustomSkeletons.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||||
|
#include "soh/resource/type/Skeleton.h"
|
||||||
|
#include "soh/ShipInit.hpp"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "macros.h"
|
||||||
|
#include "variables.h"
|
||||||
|
extern PlayState* gPlayState;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UpdateCustomSkeletonOnEquipTunic() {
|
||||||
|
if (!GameInteractor::IsSaveLoaded() || gPlayState == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int8_t previousTunic = -1;
|
||||||
|
int8_t equippedTunic = CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC);
|
||||||
|
if (equippedTunic != previousTunic) {
|
||||||
|
SOH::SkeletonPatcher::UpdateCustomSkeletons();
|
||||||
|
previousTunic = equippedTunic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UpdateCustomSkeletonOnAssetAltChange() {
|
||||||
|
if (!GameInteractor::IsSaveLoaded() || gPlayState == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SOH::SkeletonPatcher::UpdateCustomSkeletons();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RegisterCustomSkeletons() {
|
||||||
|
COND_HOOK(OnGameFrameUpdate, true, UpdateCustomSkeletonOnEquipTunic);
|
||||||
|
COND_HOOK(OnAssetAltChange, true, UpdateCustomSkeletonOnAssetAltChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initFunc(RegisterCustomSkeletons);
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
#include "soh/SaveManager.h"
|
#include "soh/SaveManager.h"
|
||||||
#include "soh/ResourceManagerHelpers.h"
|
#include "soh/ResourceManagerHelpers.h"
|
||||||
#include "soh/resource/type/Skeleton.h"
|
|
||||||
#include "soh/Enhancements/boss-rush/BossRush.h"
|
#include "soh/Enhancements/boss-rush/BossRush.h"
|
||||||
#include "soh/Enhancements/enhancementTypes.h"
|
#include "soh/Enhancements/enhancementTypes.h"
|
||||||
#include <soh/Enhancements/item-tables/ItemTableManager.h>
|
#include <soh/Enhancements/item-tables/ItemTableManager.h>
|
||||||
@@ -657,29 +656,6 @@ void RegisterRandomizedEnemySizes() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterCustomSkeletons() {
|
|
||||||
static int8_t previousTunic = -1;
|
|
||||||
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
|
||||||
if (!GameInteractor::IsSaveLoaded() || gPlayState == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) != previousTunic) {
|
|
||||||
SOH::SkeletonPatcher::UpdateCustomSkeletons();
|
|
||||||
}
|
|
||||||
previousTunic = CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC);
|
|
||||||
});
|
|
||||||
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnAssetAltChange>([]() {
|
|
||||||
if (!GameInteractor::IsSaveLoaded() || gPlayState == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SOH::SkeletonPatcher::UpdateCustomSkeletons();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitMods() {
|
void InitMods() {
|
||||||
RandomizerRegisterHooks();
|
RandomizerRegisterHooks();
|
||||||
TimeSaverRegisterHooks();
|
TimeSaverRegisterHooks();
|
||||||
@@ -695,5 +671,4 @@ void InitMods() {
|
|||||||
RegisterPatchHandHandler();
|
RegisterPatchHandHandler();
|
||||||
RegisterHurtContainerModeHandler();
|
RegisterHurtContainerModeHandler();
|
||||||
RandoKaleido_RegisterHooks();
|
RandoKaleido_RegisterHooks();
|
||||||
RegisterCustomSkeletons();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user