Add time-moves-when-you-move mode (#536)

This commit is contained in:
Garrett Cox
2024-06-02 20:10:08 -05:00
committed by GitHub
parent 04e5ac449d
commit 53e76c5aeb
5 changed files with 43 additions and 0 deletions
+4
View File
@@ -10,6 +10,7 @@
#include "2s2h/Enhancements/Enhancements.h"
#include "2s2h/Enhancements/Graphics/MotionBlur.h"
#include "2s2h/Enhancements/Graphics/PlayAsKafei.h"
#include "2s2h/Enhancements/Modes/TimeMovesWhenYouMove.h"
#include "2s2h/DeveloperTools/DeveloperTools.h"
#include "2s2h/DeveloperTools/WarpPoint.h"
#include "HudEditor.h"
@@ -539,6 +540,9 @@ void DrawEnhancementsMenu() {
if (UIWidgets::BeginMenu("Modes")) {
UIWidgets::CVarCheckbox("Play As Kafei", "gModes.PlayAsKafei",
{ .tooltip = "Requires scene reload to take effect." });
if (UIWidgets::CVarCheckbox("Time Moves When You Move", "gModes.TimeMovesWhenYouMove")) {
RegisterTimeMovesWhenYouMove();
}
ImGui::EndMenu();
}
if (UIWidgets::BeginMenu("Player Movement")) {
+1
View File
@@ -42,6 +42,7 @@ void InitEnhancements() {
// Modes
RegisterPlayAsKafei();
RegisterTimeMovesWhenYouMove();
// Player Movement
RegisterClimbSpeed();
+1
View File
@@ -23,6 +23,7 @@
#include "PlayerMovement/ClimbSpeed.h"
#include "Songs/EnableSunsSong.h"
#include "Saving/SavingEnhancements.h"
#include "Modes/TimeMovesWhenYouMove.h"
enum AlwaysWinDoggyRaceOptions {
ALWAYS_WIN_DOGGY_RACE_OFF,
@@ -0,0 +1,31 @@
#include "TimeMovesWhenYouMove.h"
#include "libultraship/libultraship.h"
#include "2s2h/Enhancements/GameInteractor/GameInteractor.h"
extern "C" {
#include "macros.h"
#include "z64.h"
extern PlayState* gPlayState;
extern SaveContext gSaveContext;
}
static HOOK_ID onActorUpdateHookId = 0;
void RegisterTimeMovesWhenYouMove() {
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorUpdate>(onActorUpdateHookId);
onActorUpdateHookId = 0;
gSaveContext.save.timeSpeedOffset = 0;
if (CVarGetInteger("gModes.TimeMovesWhenYouMove", 0)) {
onActorUpdateHookId = GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorUpdate>(
ACTOR_PLAYER, [](Actor* actor) {
Player* player = GET_PLAYER(gPlayState);
gSaveContext.save.timeSpeedOffset = -R_TIME_SPEED;
if (player->linearVelocity != 0) {
gSaveContext.save.timeSpeedOffset =
CLAMP(player->linearVelocity / 2 - R_TIME_SPEED, -R_TIME_SPEED, 10);
}
});
}
}
@@ -0,0 +1,6 @@
#ifndef MODES_TIME_MOVES_WHEN_YOU_MOVE_H
#define MODES_TIME_MOVES_WHEN_YOU_MOVE_H
void RegisterTimeMovesWhenYouMove();
#endif // MODES_TIME_MOVES_WHEN_YOU_MOVE_H