Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from Luxusio/develop
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
Luxusio authored Jun 12, 2021
2 parents f968bb4 + 4a7852f commit 8836d0e
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 40 deletions.
26 changes: 7 additions & 19 deletions AsyncInput/AsyncInputManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using NoStopMod.AsyncInput.HitIgnore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand All @@ -9,6 +10,8 @@ namespace NoStopMod.AsyncInput
class AsyncInputManager
{

public HitIgnoreManager hitIgnoreManager;

private Thread thread;
public Queue<Tuple<long, List<KeyCode>>> keyQueue = new Queue<Tuple<long, List<KeyCode>>>();

Expand All @@ -21,7 +24,6 @@ class AsyncInputManager
public bool jumpToOtherClass = false;

private bool[] mask;
private bool[] disable;

public AsyncInputManager()
{
Expand All @@ -31,15 +33,8 @@ public AsyncInputManager()
currTick = prevTick;

mask = Enumerable.Repeat(false, 1024).ToArray();
disable = Enumerable.Repeat(false, 1024).ToArray();
disable[(int)KeyCode.BackQuote] = true;
disable[(int)KeyCode.Alpha1] = true;
disable[(int)KeyCode.Alpha2] = true;
disable[(int)KeyCode.Alpha3] = true;
disable[(int)KeyCode.Alpha4] = true;
disable[(int)KeyCode.Alpha5] = true;
disable[(int)KeyCode.Alpha6] = true;
disable[(int)KeyCode.Alpha7] = true;

hitIgnoreManager = new HitIgnoreManager();
}

private void OnToggle(bool enabled)
Expand Down Expand Up @@ -72,7 +67,6 @@ public void Stop()

private bool GetKeyDown(int idx)
{
if (disable[idx]) return false;
if (mask[idx])
{
if (!Input.GetKey((KeyCode)idx))
Expand Down Expand Up @@ -121,13 +115,7 @@ private void Run()

if (keyCodes.Any())
{
//String str = "press " + keyCodes.Count();
//foreach (KeyCode code in keyCodes)
//{
// str += code + "(" + ((int)code) + "), ";
//}
//NoStopMod.mod.Logger.Log(str);
keyQueue.Enqueue(new Tuple<long, List<KeyCode>>(currTick, keyCodes.GetRange(0, Math.Min(4, keyCodes.Count()))));
keyQueue.Enqueue(new Tuple<long, List<KeyCode>>(currTick, keyCodes));
}
}
}
Expand Down
31 changes: 15 additions & 16 deletions AsyncInput/AsyncInputPatches.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DG.Tweening;
using HarmonyLib;
using NoStopMod.AsyncInput.HitIgnore;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -58,39 +59,37 @@ public static void Postfix(scrConductor __instance, double ___dspTimeSong)
NoStopMod.asyncInputManager.adjustOffsetTick(__instance, ___dspTimeSong);
}

if (__instance.controller.GetState().CompareTo(scrController.States.PlayerControl) != 0)
{
//NoStopMod.mod.Logger.Log("Update " + __instance.controller.GetState() + ", " + ((Enum)scrController.States.PlayerControl) + " : " + (__instance.controller.GetState() != (Enum)scrController.States.PlayerControl));
NoStopMod.asyncInputManager.keyQueue.Clear();
}

}
}

[HarmonyPatch(typeof(scrController), "PlayerControl_Update")]
private static class scrController_PlayerControl_Update_Patch
{
public static void Prefix(scrController __instance)
{
bool pause = AudioListener.pause || RDC.auto;
while (NoStopMod.asyncInputManager.keyQueue.Any())
{
long tick;
List<KeyCode> keyCodes;
NoStopMod.asyncInputManager.keyQueue.Dequeue().Deconstruct(out tick, out keyCodes);

if (pause) continue;
if (AudioListener.pause || RDC.auto) continue;

NoStopMod.asyncInputManager.currPressTick = tick - NoStopMod.asyncInputManager.offsetTick;
//NoStopMod.mod.Logger.Log("Hit:" + keyCodes.Count() + "(" + GCS.sceneToLoad + "), " + NoStopMod.asyncInputManager.hitIgnoreManager.scrController_state + ", " + __instance.controller.GetState());

scrController controller = __instance.controller;
HitIgnoreManager hitDisableManager = NoStopMod.asyncInputManager.hitIgnoreManager;
int count = 0;
for (int i = 0; i < keyCodes.Count(); i++)
{
if (hitDisableManager.shouldBeIgnored(keyCodes[i])) continue;
if (++count > 4) break;
//NoStopMod.mod.Logger.Log("Hit " + keyCodes[i] + ", " + GCS.sceneToLoad + ", ");
}
controller.keyBufferCount += count;
while (controller.keyBufferCount > 0)
{
controller.keyBufferCount--;
NoStopMod.asyncInputManager.jumpToOtherClass = true;
controller.chosenplanet.Update_RefreshAngles();
controller.Hit();
}

}

}
}

Expand Down
65 changes: 65 additions & 0 deletions AsyncInput/HitIgnore/HitIgnoreManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace NoStopMod.AsyncInput.HitIgnore
{
class HitIgnoreManager
{
private Dictionary<String, bool[]> dictionary;

public bool scnCLS_searchMode;
public scrController.States scrController_state;

public HitIgnoreManager()
{
if (GCS.sceneToLoad == null) GCS.sceneToLoad = "scnNewIntro";

dictionary = new Dictionary<string, bool[]>();

bool[] ignoreScnNewIntro = Enumerable.Repeat(false, 1024).ToArray();
dictionary["scnNewIntro"] = ignoreScnNewIntro;
ignoreScnNewIntro[(int)KeyCode.BackQuote] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha0] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha1] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha2] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha3] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha4] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha5] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha6] = true;
ignoreScnNewIntro[(int)KeyCode.Alpha7] = true;

bool[] ignoreScnCLS = Enumerable.Repeat(false, 1024).ToArray();
dictionary["scnCLS"] = ignoreScnCLS;
ignoreScnCLS[(int)KeyCode.S] = true;
ignoreScnCLS[(int)KeyCode.Delete] = true;
ignoreScnCLS[(int)KeyCode.F] = true;
ignoreScnCLS[(int)KeyCode.O] = true;
ignoreScnCLS[(int)KeyCode.Alpha7] = true;
ignoreScnCLS[(int)KeyCode.UpArrow] = true;
ignoreScnCLS[(int)KeyCode.DownArrow] = true;

scnCLS_searchMode = false;
}

public bool shouldBeIgnored(KeyCode keyCode)
{
if (keyCode == KeyCode.Escape) return true;
if (scrController_state != scrController.States.PlayerControl) return true;

bool[] ignoreScnCLS;
if (dictionary.TryGetValue(GCS.sceneToLoad, out ignoreScnCLS))
{
if (GCS.sceneToLoad == "scnCLS" && scnCLS_searchMode)
{
return true;
}
return ignoreScnCLS[(int) keyCode];
}
return false;
}


}
}
49 changes: 49 additions & 0 deletions AsyncInput/HitIgnore/HitIgnorePatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using HarmonyLib;
using MonsterLove.StateMachine;
using System;

namespace NoStopMod.AsyncInput.HitIgnore
{
class HitIgnorePatches
{

// scnCLS_serachMode ////////////////////////////////////
[HarmonyPatch(typeof(scnCLS), "Refresh")]
private static class scnCLS_Refresh_Patch
{
public static void Postfix(scnCLS __instance, ref bool ___searchMode)
{
NoStopMod.asyncInputManager.hitIgnoreManager.scnCLS_searchMode = ___searchMode;
}
}

[HarmonyPatch(typeof(scnCLS), "ToggleSearchMode")]
private static class scnCLS_ToggleSearchMode_Patch
{
public static void Postfix(scnCLS __instance, ref bool ___searchMode)
{
NoStopMod.asyncInputManager.hitIgnoreManager.scnCLS_searchMode = ___searchMode;
}
}

// scrController_state //////////////////////////
[HarmonyPatch(typeof(StateEngine), "ChangeState")]
private static class StateEngine_ChangeState_Patch
{
public static void Postfix(StateEngine __instance, Enum newState, StateTransition transition)
{
NoStopMod.asyncInputManager.hitIgnoreManager.scrController_state = (scrController.States) newState;
}
}

[HarmonyPatch(typeof(scrController), "OnLandOnPortal")]
private static class scrController_OnLandOnPortal_Patch
{
public static void Postfix(scrController __instance)
{
NoStopMod.asyncInputManager.hitIgnoreManager.scrController_state = scrController.States.Won;
}
}

}
}
49 changes: 49 additions & 0 deletions HyperRabbit/HyperRabbitManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityModManagerNet;

namespace NoStopMod.HyperRabbit
{
class HyperRabbitManager
{


public bool isEnabled;


enum Status
{
OFF,
FIXED_OTTO,
HYPER_RABBIT,
}

public HyperRabbitManager()
{
NoStopMod.onToggleListeners.Add(OnToggle);
NoStopMod.onGUIListeners.Add(OnGUI);
}

private void OnToggle(bool enabled)
{
this.isEnabled = enabled;
}

private void OnGUI(UnityModManager.ModEntry modEntry)
{
GUILayout.BeginHorizontal("HyperRabbit");
GUILayout.TextArea("HyperRabbit Status", 20);
//if (GUILayout.Button(tex))
//{

//}
//this.isEnabled = GUILayout.Toggle(isEnabled, "HyperRabbit");
GUILayout.EndHorizontal();
}

}
}
3 changes: 2 additions & 1 deletion HyperRabbit/HyperRabbitPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void Prefix(scrPlanet __instance)
}

[HarmonyPatch(typeof(scrController), "PlayerControl_Update")]
private static class scrController_PlayerControl_Update_Patch2
private static class scrController_PlayerControl_Update_Patch
{
public static void Postfix(scrController __instance)
{
Expand All @@ -30,6 +30,7 @@ public static void Postfix(scrController __instance)
__instance.chosenplanet.Update_RefreshAngles();
while (__instance.chosenplanet.AutoShouldHitNow())
{
__instance.keyBufferCount = 0;
__instance.Hit();
__instance.chosenplanet.Update_RefreshAngles();
}
Expand Down
40 changes: 36 additions & 4 deletions NoStopMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NoStopMod.GarbageCollection;
using System.Collections.Generic;
using NoStopMod.AsyncInput;
using NoStopMod.HyperRabbit;

namespace NoStopMod
{
Expand All @@ -13,22 +14,30 @@ class NoStopMod

public static UnityModManager.ModEntry mod;
public static Harmony harmony;
public static bool isEnabled = false;

public static List<Action<bool>> onToggleListeners;
public static List<Action<UnityModManager.ModEntry>> onGUIListeners;

public static GCManager gcManager;
public static AsyncInputManager asyncInputManager;
public static List<Action<bool>> onToggleListeners;
public static HyperRabbitManager hyperRabbitManager;


public static bool isEnabled = false;
//public static bool ready = false;

public static bool Load(UnityModManager.ModEntry modEntry)
{
modEntry.OnToggle = new Func<UnityModManager.ModEntry, bool, bool>(NoStopMod.OnToggle);
modEntry.OnToggle = NoStopMod.OnToggle;
//modEntry.OnGUI = NoStopMod.OnGUI;
NoStopMod.harmony = new Harmony(modEntry.Info.Id);
NoStopMod.mod = modEntry;
NoStopMod.onToggleListeners = new List<Action<bool>>();
NoStopMod.onGUIListeners = new List<Action<UnityModManager.ModEntry>>();

gcManager = new GCManager();
asyncInputManager = new AsyncInputManager();
hyperRabbitManager = new HyperRabbitManager();

return true;
}
Expand All @@ -49,11 +58,34 @@ public static bool OnToggle(UnityModManager.ModEntry modEntry, bool enabled)
isEnabled = enabled;
foreach (Action<bool> listener in onToggleListeners)
{
listener.Invoke(enabled);
try
{
listener.Invoke(enabled);
}
catch (Exception e)
{
mod.Logger.Error("Error on OnToggle : " + e.Message);
}
}

return true;
}

public static void OnGUI(UnityModManager.ModEntry modEntry)
{
NoStopMod.mod = modEntry;
foreach (Action<UnityModManager.ModEntry> listener in onGUIListeners)
{
try
{
listener.Invoke(modEntry);
}
catch (Exception e)
{
mod.Logger.Error("Error on ONGUI : " + e.Message);
}
}
}

}
}
3 changes: 3 additions & 0 deletions NoStopMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@
<ItemGroup>
<Compile Include="AsyncInput\AsyncInputManager.cs" />
<Compile Include="AsyncInput\AsyncInputPatches.cs" />
<Compile Include="AsyncInput\HitIgnore\HitIgnoreManager.cs" />
<Compile Include="AsyncInput\HitIgnore\HitIgnorePatches.cs" />
<Compile Include="GarbageCollection\GCManager.cs" />
<Compile Include="GarbageCollection\GCPatches.cs" />
<Compile Include="HyperRabbit\HyperRabbitManager.cs" />
<Compile Include="HyperRabbit\HyperRabbitPatches.cs" />
<Compile Include="NoStopMod.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down

0 comments on commit 8836d0e

Please sign in to comment.