Skip to content

Commit

Permalink
Implement hide beat effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernthedev committed Dec 24, 2022
1 parent 6c03692 commit 29663cc
Showing 1 changed file with 43 additions and 27 deletions.
70 changes: 43 additions & 27 deletions src/hooks/BeatEffectSpawner.cpp
Original file line number Diff line number Diff line change
@@ -1,59 +1,75 @@
#include "Chroma.hpp"

#include "hooks/colorizer/Note/ColorManager.hpp"

#include "ChromaController.hpp"
#include "ChromaObjectData.hpp"
#include "utils/ChromaUtils.hpp"

#include "colorizer/BombColorizer.hpp"
#include "colorizer/NoteColorizer.hpp"

#include "GlobalNamespace/ColorExtensions.hpp"
#include "hooks/colorizer/Note/ColorManager.hpp"
#include "GlobalNamespace/BeatEffectSpawner.hpp"
#include "GlobalNamespace/BeatEffectSpawner_InitData.hpp"
#include "GlobalNamespace/MemoryPoolContainer_1.hpp"
#include "GlobalNamespace/LazyCopyHashSet_1.hpp"

#include "custom-json-data/shared/CustomBeatmapData.h"
#include "GlobalNamespace/AudioTimeSyncController.hpp"

#include "colorizer/BombColorizer.hpp"
#include "colorizer/NoteColorizer.hpp"
#include "ChromaObjectData.hpp"
#include "custom-json-data/shared/CustomBeatmapData.h"

using namespace Chroma;
using namespace GlobalNamespace;

MAKE_HOOK_MATCH(BeatEffectSpawner_HandleNoteDidStartJump, &BeatEffectSpawner::HandleNoteDidStartJump, void, BeatEffectSpawner* self, NoteController* noteController) {
// Do nothing if Chroma shouldn't run
if (!ChromaController::DoChromaHooks()) {
BeatEffectSpawner_HandleNoteDidStartJump(self, noteController);
return;
}


// TODO: Transpile to force beat effect
inline bool BeatEffectForce(bool hideNoteSpawnEffect, NoteController* noteController)
{
auto it = ChromaObjectDataManager::ChromaObjectDatas.find(noteController->noteData);

if (it != ChromaObjectDataManager::ChromaObjectDatas.end()) {
auto const& chromaData = it->second;
std::optional<bool> disable = chromaData.DisableSpawnEffect;

if (disable && disable.value()) {
return;
if (disable) {
return !disable.value();
}
}

return hideNoteSpawnEffect;
}

Sombrero::FastColor oldBombColorEffect = self->bombColorEffect;
if (noteController->noteData->colorType == ColorType::None) {
self->bombColorEffect = BombColorizer::GetBombColorizer(noteController)->getColor().Alpha(0.5f);
} else {
ColorManagerColorForType::EnableColorOverride(noteController);
}
BeatEffectSpawner_HandleNoteDidStartJump(self, noteController);
if (noteController->noteData->colorType == ColorType::None) {
self->bombColorEffect = oldBombColorEffect;
MAKE_HOOK_MATCH(BeatEffectSpawner_HandleNoteDidStartJump, &BeatEffectSpawner::HandleNoteDidStartJump, void, BeatEffectSpawner* self, NoteController* noteController) {
// Do nothing if Chroma shouldn't run
if (!ChromaController::DoChromaHooks()) {
BeatEffectSpawner_HandleNoteDidStartJump(self, noteController);
return;
}

ColorManagerColorForType::DisableColorOverride();
/// TRANSPILE HERE
// if (self->initData->hideNoteSpawnEffect)
if (BeatEffectForce(self->initData->hideNoteSpawnEffect, noteController))
{
return;
}
if (noteController->hidden)
{
return;
}
if (noteController->noteData->time + 0.1f < self->audioTimeSyncController->songTime)
{
return;
}
ColorType colorType = noteController->noteData->colorType;
Sombrero::FastColor a = (colorType != ColorType::None) ? self->colorManager->ColorForType(colorType) : self->bombColorEffect;
auto beatEffect = self->beatEffectPoolContainer->Spawn();
beatEffect->didFinishEvent->Add(self->i_IBeatEffectDidFinishEvent());
beatEffect->get_transform()->SetPositionAndRotation(noteController->get_worldRotation() * noteController->get_jumpStartPos() - Sombrero::FastVector3(0.f, 0.15f, 0.f), Sombrero::FastQuaternion::identity());
beatEffect->Init(a * 1.f, self->effectDuration, noteController->get_worldRotation());
}

void BeatEffectSpawnerHook(Logger& logger) {
// TODO: DO TODO ABOVE
// INSTALL_HOOK(logger, BeatEffectSpawner_HandleNoteDidStartJump);
INSTALL_HOOK_ORIG(logger, BeatEffectSpawner_HandleNoteDidStartJump);
}

ChromaInstallHooks(BeatEffectSpawnerHook)

0 comments on commit 29663cc

Please sign in to comment.