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 #3 from Luxusio/develop
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
Luxusio authored Jun 19, 2021
2 parents 8836d0e + e6bd61f commit 0c9a2f3
Show file tree
Hide file tree
Showing 19 changed files with 2,125 additions and 289 deletions.
148 changes: 0 additions & 148 deletions AsyncInput/AsyncInputManager.cs

This file was deleted.

14 changes: 7 additions & 7 deletions GarbageCollection/GCManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ namespace NoStopMod.GarbageCollection
public class GCManager
{

private bool gcEnabled = true;
private static bool gcEnabled = true;

public GCManager()
public static void Init()
{
NoStopMod.onToggleListeners.Add(OnToggle);
NoStopMod.onToggleListener.Add(OnToggle);
}

private void OnToggle(bool enabled)
private static void OnToggle(bool enabled)
{
EnableGC();
}

public bool GetDisableAutoSave()
public static bool GetDisableAutoSave()
{
return !gcEnabled;
}

public void DisableGC()
public static void DisableGC()
{
try
{
Expand All @@ -39,7 +39,7 @@ public void DisableGC()
}
}

public void EnableGC()
public static void EnableGC()
{
try
{
Expand Down
25 changes: 12 additions & 13 deletions GarbageCollection/GCPatches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using HarmonyLib;
using UnityEngine;
using HarmonyLib;
using NoStopMod.GarbageCollection;

namespace NoStopMod.Patches
{
Expand All @@ -12,7 +11,7 @@ private static class CustomLevel_Play_Patch
private static void Prefix(CustomLevel __instance)
{
//NoStopMod.mod.Logger.Log("Play");
NoStopMod.gcManager.DisableGC();
GCManager.DisableGC();
}
}

Expand All @@ -22,7 +21,7 @@ private static class scnEditor_ResetScene_Patch
private static void Postfix(scnEditor __instance)
{
//NoStopMod.mod.Logger.Log("ResetScene");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -32,7 +31,7 @@ private static class scnEditor_SaveBackup_Patch
private static bool Prefix(scnEditor __instance)
{
//NoStopMod.mod.Logger.Log("SaveBackup");
if (NoStopMod.gcManager.GetDisableAutoSave())
if (GCManager.GetDisableAutoSave())
{
//NoStopMod.mod.Logger.Log("Cancel AutoSave");
return false;
Expand All @@ -48,7 +47,7 @@ private static class scrController_Awake_Patch
public static void Postfix(scrController __instance)
{
//NoStopMod.mod.Logger.Log("Awake");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -57,7 +56,7 @@ private static class scrController_FailAction_Patch
{
private static void Prefix(scrController __instance)
{
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -67,7 +66,7 @@ private static class scrController_QuitToMainMenu_Patch
private static void Postfix(scrController __instance)
{
//NoStopMod.mod.Logger.Log("StartLoadingScene");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -77,7 +76,7 @@ private static class scrController_ResetCustomLevel_Patch
private static void Postfix(scrController __instance)
{
//NoStopMod.mod.Logger.Log("ResetCustomLevel");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -87,7 +86,7 @@ private static class scrController_Restart_Patch
private static void Prefix(scrController __instance)
{
//NoStopMod.mod.Logger.Log("Restart");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -97,7 +96,7 @@ private static class scrController_StartLoadingScene_Patch
private static void Postfix(scrController __instance)
{
//NoStopMod.mod.Logger.Log("StartLoadingScene");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand All @@ -108,7 +107,7 @@ private static class scrUIController_WipeToBlack_Patch
private static void Postfix(scrUIController __instance)
{
//NoStopMod.mod.Logger.Log("WipeToBlack");
NoStopMod.gcManager.EnableGC();
GCManager.EnableGC();
}
}

Expand Down
17 changes: 17 additions & 0 deletions Helper/Abstraction/SettingsBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SimpleJSON;

namespace NoStopMod.Helper.Abstraction
{
interface SettingsBase
{
void Load(ref JSONNode json);

void Save(ref JSONNode json);

}
}
39 changes: 39 additions & 0 deletions Helper/EventListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;

namespace NoStopMod.Helper
{
class EventListener<T>
{

public readonly List<Action<T>> listeners = new List<Action<T>>();

private readonly string errorMessage;

public EventListener(string errorMessage)
{
this.errorMessage = errorMessage;
}

public void Add(Action<T> listener)
{
listeners.Add(listener);
}

public void Invoke(T value)
{
for (int i = 0; i < listeners.Count; i++)
{
try
{
listeners[i].Invoke(value);
}
catch (Exception e)
{
NoStopMod.mod.Logger.Error("Error on " + errorMessage + " : " + e.Message + ", " + e.StackTrace);
}
}
}

}
}
48 changes: 48 additions & 0 deletions Helper/JSONHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using SimpleJSON;
using System;
using System.Collections.Generic;

namespace NoStopMod.Helper
{
class JSONHelper
{

public static JSONNode CreateEmptyNode()
{
return JSON.Parse("{}");
}

public static long ConvertLong(JSONNode node)
{
return node.AsLong;
}

public static int ConvertInt(JSONNode node)
{
return node.AsInt;
}

public static List<T> ReadArray<T>(ref JSONNode node, string name, Func<JSONNode, T> converter)
{
JSONArray array = node[name].AsArray;

List<T> results = new List<T>(array.Count);
for (int i = 0; i < array.Count; i++)
{
results.Add(converter.Invoke(array[i]));
}
return results;
}

public static JSONArray WriteArray<T>(List<T> list, Func<T, JSONNode> converter)
{
JSONArray array = new JSONArray();
for (int i = 0; i < list.Count; i++)
{
array.Add(converter.Invoke(list[i]));
}
return array;
}

}
}
Loading

0 comments on commit 0c9a2f3

Please sign in to comment.