This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Luxusio/develop
Release 1.2.0
- Loading branch information
Showing
19 changed files
with
2,125 additions
and
289 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.