diff --git a/Source/Helpers/Helper.cs b/Source/Helpers/Helper.cs index 3aa6eb3f..5ba4f2a3 100644 --- a/Source/Helpers/Helper.cs +++ b/Source/Helpers/Helper.cs @@ -96,7 +96,7 @@ internal const string /// /// The item to check the type for. /// is either , , or . - public static bool IsIterator(this object item) => item is string or IEnumerable or IEnumerator; + public static bool IsIterator(this T item) => item is string or IEnumerable or IEnumerator; /// /// Determines if the string is null or empty. @@ -329,7 +329,7 @@ public static long BaseToLong(this string value, string baseChars = Binary) /// /// The which returns the object you want the name of. /// The name of the variable, or if it cannot find it, . - public static string NameOfVariable(this Expression> e) + public static string NameOfVariable(this Expression> e) { try { @@ -405,7 +405,7 @@ public static string LongToBase(this long value, string baseChars = Alphanumeric /// Whether it should search recursively inside the variable and yield return the elements inside . /// The characters in-between each element. /// A string consisting of all values from . - public static string UnwrapToString(this object item, bool getVariables = false, string delimiter = ", ") => string.Join(delimiter, Unwrap(item, getVariables).Select(o => o.ToString()).ToArray()); + public static string UnwrapToString(this T item, bool getVariables = false, string delimiter = ", ") => string.Join(delimiter, Unwrap(item, getVariables).Select(o => o.ToString()).ToArray()); /// /// Unwraps any object, whether it be a class, list, tuple, or any other data. @@ -465,7 +465,7 @@ public static IEnumerable AsEnumerable(this IEnumerator source) /// /// The item to get all fields and properties. /// All fields and properties of . - public static IEnumerable GetAllValues(this object source) => source?.GetType()?.GetFields(Helper.Flags).Select(f => $"\n{f} (Field): {f?.GetValue(source).UnwrapToString()}").Concat(source?.GetType()?.GetProperties(Helper.Flags).Select(p => $"\n{p} (Property): {p?.GetValue(source, null).UnwrapToString()}")); + public static IEnumerable GetAllValues(this T source) => source?.GetType()?.GetFields(Flags).Select(f => $"\n{f} (Field): {f?.GetValue(source).UnwrapToString()}").Concat(source?.GetType()?.GetProperties(Flags).Select(p => $"\n{p} (Property): {p?.GetValue(source, null).UnwrapToString()}")); /// /// Unwraps any of type , which ends up flattening it as a of type . diff --git a/Source/Instances/BigInteger.cs b/Source/Instances/BigInteger.cs index 6c759ae7..dd559797 100644 --- a/Source/Instances/BigInteger.cs +++ b/Source/Instances/BigInteger.cs @@ -443,7 +443,7 @@ public override int GetHashCode() /// The minimum value accepted. /// The maximum value accepted. /// True if is smaller or equal itself and is greater or equal itself. - public bool IsInRange(object min, object max) => this >= min && this <= max; + public bool IsInRange(T min, T max) => this >= min && this <= max; /// /// Converts the BigInteger to a . @@ -493,7 +493,7 @@ public override int GetHashCode() /// /// The right-hand side operator. /// Itself mod . - public BigInteger Modulo(object obj) => ((this % obj) + obj) % obj; + public BigInteger Modulo(T obj) => ((this % obj) + obj) % obj; private enum Operator { Add, Subtract, Multiply, Divide, Modulo } @@ -691,7 +691,7 @@ private static sbyte[] Multiplication(sbyte[] left, sbyte[] right) private static sbyte[] InvertConditional(in sbyte[] vs, bool b) => b ? vs.Select(s => (sbyte)(-1 * s)).ToArray() : vs; - private sbyte[] ObjectToBytes(in object obj) + private sbyte[] ObjectToBytes(in T obj) { obj.NullCheck("You cannot construct a BigInteger out of null."); diff --git a/Source/MonoBehaviours/ModuleScript.cs b/Source/MonoBehaviours/ModuleScript.cs index b6474ac6..5bf1c0b0 100644 --- a/Source/MonoBehaviours/ModuleScript.cs +++ b/Source/MonoBehaviours/ModuleScript.cs @@ -105,7 +105,6 @@ protected virtual void OnTimerTick() { } /// protected void Awake() { - Debug.Log("test" + ModBundleName); _setActive = () => { if (Get(allowNull: true) is KMBombInfo bombInfo) @@ -115,7 +114,7 @@ protected void Awake() }; _components = new Dictionary() { { typeof(ModuleScript), new[] { this } } }; - + ModBundleName.NullOrEmptyCheck("The public field \"ModBundleName\" is empty! This means that when compiled it won't be able to run! Please set this field to your Mod ID located at Keep Talking ModKit -> Configure Mod. Refer to this link for more details: https://github.com/Emik03/KeepCoding/wiki/Chapter-2.1:-ModuleScript#version-string"); Module = new ModuleContainer(Get(), Get()); @@ -174,7 +173,7 @@ public void Dump(bool getVariables = false) { int index = 0; - string Format(string name, object value) => Helper.VariableTemplate.Form(index++, name, value?.GetType().ToString() ?? Helper.Null, string.Join(", ", value.Unwrap(getVariables).Select(o => o.ToString()).ToArray())); + string Format(string name, T value) => Helper.VariableTemplate.Form(index++, name, value?.GetType().ToString() ?? Helper.Null, string.Join(", ", value.Unwrap(getVariables).Select(o => o.ToString()).ToArray())); var type = GetType(); var values = new List(); @@ -275,7 +274,7 @@ public T[] Cache(Func func, bool allowNull = false) where T : Component /// /// The message to log. /// The type of logging. Different logging types have different icons within the editor. - public void Log(object message, LogType logType = LogType.Log) => GetLogMethod(logType)($"[{Module.ModuleDisplayName} #{ModuleId}] {message.UnwrapToString()}"); + public void Log(T message, LogType logType = LogType.Log) => GetLogMethod(logType)($"[{Module.ModuleDisplayName} #{ModuleId}] {message.UnwrapToString()}"); /// /// Logs multiple entries, but formats it to be compliant with the Logfile Analyzer. @@ -283,7 +282,7 @@ public T[] Cache(Func func, bool allowNull = false) where T : Component /// /// The message to log. /// All of the arguments to embed into . - public void Log(object message, params object[] args) => Log(message.UnwrapToString().Form(args)); + public void Log(T message, params object[] args) => Log(message.UnwrapToString().Form(args)); /// /// Plays a sound. Requires to be assigned. diff --git a/Source/MonoBehaviours/TPScript.cs b/Source/MonoBehaviours/TPScript.cs index 4b2f8b34..6983456f 100644 --- a/Source/MonoBehaviours/TPScript.cs +++ b/Source/MonoBehaviours/TPScript.cs @@ -154,11 +154,12 @@ protected IEnumerator OnInteractSequence(KMSelectable[] selectables, float wait, /// /// You can yield return this to send error messages or interactions by first checking for the condition. /// + /// The type of then condition. /// The boolean to check. /// The output to return if is true. /// The output to return if is false. /// or , depending on . - protected static object Evaluate(bool condition, object then, object otherwise = null) => condition ? then : otherwise; + protected static object Evaluate(bool condition, TThen then, object otherwise = null) => condition ? then : otherwise; /// /// Yield return this to allow you to tell the user why they got a strike if it isn't clear. diff --git a/Source/Statics/PathManager.cs b/Source/Statics/PathManager.cs index 05b0b249..bd284f32 100644 --- a/Source/Statics/PathManager.cs +++ b/Source/Statics/PathManager.cs @@ -106,7 +106,7 @@ public static void LoadLibrary(string bundleFileName, string libraryFileName) if (IsCached(in current)) return; - SetCache(current, null); + SetCache(current, null); string path = GetPath(FileFormat.Form(bundleFileName, FileExtensionWindows));