Skip to content

Commit

Permalink
Fix luma trial bubbles
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Sep 12, 2024
1 parent 0eb28d1 commit b3bfa6c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/Randomizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ set(
"game/behaviour_changes/teleporter_glades_identifier.cpp"
"game/behaviour_changes/teleporter_map_activation.cpp"
"game/behaviour_changes/teleporting_oob_fix.cpp"
"game/behaviour_changes/luma_trial_bubbles.cpp"
"game/behaviour_changes/trials_leaderboards.cpp"
"game/behaviour_changes/triple_jump_shockwave.cpp"
"game/condition_intercepts/day_night_logic.cpp"
Expand Down
37 changes: 37 additions & 0 deletions projects/Randomizer/game/behaviour_changes/luma_trial_bubbles.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <Modloader/modloader.h>
#include <Modloader/interception_macros.h>
#include <Modloader/app/methods/Bubble.h>
#include <Modloader/app/methods/Bubblemaker.h>

namespace {
IL2CPP_INTERCEPT(Bubble, void, OnPoolSpawned, (app::Bubble* this_ptr)) {
next::Bubble::OnPoolSpawned(this_ptr);

// Reset to default values so recycled bubbles don't have random values
this_ptr->fields.AccelerationY = this_ptr->fields.BaseAccelerationY;
il2cpp::unity::set_local_scale(this_ptr, this_ptr->fields.BaseLocalScale);
}

IL2CPP_INTERCEPT(Bubblemaker, void, SpawnBubble, (app::Bubblemaker* this_ptr)) {
// Prevent fake bubbles to spawn due to lazily resetting MoonTimelines
if (this_ptr->fields.RaceOverride && this_ptr->fields.m_raceTimeLastUpdate == 0.0) {
return;
}

next::Bubblemaker::SpawnBubble(this_ptr);
}

IL2CPP_INTERCEPT(Bubblemaker, void, OnSyncRaceTimer, (app::Bubblemaker* this_ptr, float time)) {
// Reset all timers on race restart, they forgot that...
// This isn't too important since it doesn't actually spawn bubbles,
// but it displays weird animations
if (time == 0.0) {
this_ptr->fields.m_raceTimeLastUpdate = 0.0;
this_ptr->fields.m_spawnOffsetTimer = 0.0;
this_ptr->fields.m_spawnTimer = 0.0;
return;
}

next::Bubblemaker::OnSyncRaceTimer(this_ptr, time);
}
} // namespace

0 comments on commit b3bfa6c

Please sign in to comment.