Skip to content

Commit

Permalink
Disable PBs alongside leaderboard when mod loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
PandorasFox committed Jul 1, 2022
1 parent 2c6f3b3 commit c7b2a46
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Neon TAS/TAS tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,22 @@ public class TAS_tools : MelonMod {
public static bool level_hook_methods_patched = false;
public static bool input_write_methods_patched = false;

class DisablePBUpdating_Patch {
[HarmonyPatch(typeof(LevelStats), "UpdateTimeMicroseconds")]
[HarmonyPrefix]
static bool SkipUpdatingPb() {
return false;
}
}

static HarmonyLib.Harmony pb_disabling_instance;

public override void OnApplicationStart() {
GameDataManager.powerPrefs.dontUploadToLeaderboard = true;
pb_disabling_instance = new HarmonyLib.Harmony("PB Blocking");
pb_disabling_instance.PatchAll(typeof(DisablePBUpdating_Patch));


tas_config = MelonPreferences.CreateCategory("TAS Tools");

// replaying requires level start/finish patches that hook/unhook input method patches
Expand Down Expand Up @@ -524,13 +538,13 @@ public static void OnLevelStart_ReplaySetup() {

if (File.Exists(path)) {
string inputs = File.ReadAllText(path);
debug_string_to_write += "Read inputs from " + path + "\n";
MelonLogger.Msg("Read inputs from " + path + "\n");
frame_idx = 0;
buffer = new InputBuffer();
buffer.ParseString(inputs);
delayed_record = false;
} else {
debug_string_to_write += "No file found at [" + path + "]. Unhooking input replaying.\n";
MelonLogger.Msg("No file found at [" + path + "]. Unhooking input replaying.\n");
UnpatchInputMethods();
delayed_record = true;
}
Expand Down Expand Up @@ -584,16 +598,7 @@ public static void WriteStringToFile(string inputs) {
if (copy_replay_filename_to_clipboard.Value) {
GUIUtility.systemCopyBuffer = filename;
}
debug_string_to_write += "Recorded inputs to " + path + "\n";
}

public static string debug_string_to_write = "";

public override void OnUpdate() {
if (debug_string_to_write != "") {
LoggerInstance.Msg(debug_string_to_write);
debug_string_to_write = "";
}
MelonLogger.Msg("Recorded inputs to " + path + "\n");
}

static InputBuffer.InputTick last_tick = null;
Expand Down

0 comments on commit c7b2a46

Please sign in to comment.