Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of Ability Api v0.1.0
AbilityApi.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using AbilityApi.Internal; using BepInEx; using BoplFixedMath; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("AbilityApi")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a84e6690eadc270b4f3fa750381255da3b32d6db")] [assembly: AssemblyProduct("AbilityApi")] [assembly: AssemblyTitle("AbilityApi")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MiniJSON { public static class Json { private sealed class Parser : IDisposable { private enum TOKEN { NONE, CURLY_OPEN, CURLY_CLOSE, SQUARED_OPEN, SQUARED_CLOSE, COLON, COMMA, STRING, NUMBER, TRUE, FALSE, NULL } private const string WORD_BREAK = "{}[],:\""; private const string HEX_DIGIT = "0123456789ABCDEFabcdef"; private StringReader json; private char PeekChar => Convert.ToChar(json.Peek()); private char NextChar => Convert.ToChar(json.Read()); private string NextWord { get { StringBuilder stringBuilder = new StringBuilder(); while (!IsWordBreak(PeekChar)) { stringBuilder.Append(NextChar); if (json.Peek() == -1) { break; } } return stringBuilder.ToString(); } } private TOKEN NextToken { get { EatWhitespace(); if (json.Peek() == -1) { return TOKEN.NONE; } switch (PeekChar) { case '{': return TOKEN.CURLY_OPEN; case '}': json.Read(); return TOKEN.CURLY_CLOSE; case '[': return TOKEN.SQUARED_OPEN; case ']': json.Read(); return TOKEN.SQUARED_CLOSE; case ',': json.Read(); return TOKEN.COMMA; case '"': return TOKEN.STRING; case ':': return TOKEN.COLON; case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return TOKEN.NUMBER; default: return NextWord switch { "false" => TOKEN.FALSE, "true" => TOKEN.TRUE, "null" => TOKEN.NULL, _ => TOKEN.NONE, }; } } } public static bool IsWordBreak(char c) { return char.IsWhiteSpace(c) || "{}[],:\"".IndexOf(c) != -1; } public static bool IsHexDigit(char c) { return "0123456789ABCDEFabcdef".IndexOf(c) != -1; } private Parser(string jsonString) { json = new StringReader(jsonString); } public static object Parse(string jsonString) { using Parser parser = new Parser(jsonString); return parser.ParseValue(); } public void Dispose() { json.Dispose(); json = null; } private Dictionary<string, object> ParseObject() { Dictionary<string, object> dictionary = new Dictionary<string, object>(); json.Read(); while (true) { string text; object obj; switch (NextToken) { case TOKEN.NONE: return null; case TOKEN.CURLY_CLOSE: return dictionary; case TOKEN.STRING: { text = ParseString(); if (text == null) { return null; } if (NextToken != TOKEN.COLON) { return null; } json.Read(); TOKEN nextToken = NextToken; obj = ParseByToken(nextToken); if (obj == null && nextToken != TOKEN.NULL) { return null; } goto IL_00ba; } default: return null; case TOKEN.COMMA: break; } continue; IL_00ba: dictionary[text] = obj; } } private List<object> ParseArray() { List<object> list = new List<object>(); json.Read(); bool flag = true; while (flag) { TOKEN nextToken = NextToken; switch (nextToken) { case TOKEN.NONE: return null; case TOKEN.SQUARED_CLOSE: flag = false; continue; case TOKEN.COMMA: continue; } object obj = ParseByToken(nextToken); if (obj == null && nextToken != TOKEN.NULL) { return null; } list.Add(obj); } return list; } private object ParseValue() { TOKEN nextToken = NextToken; return ParseByToken(nextToken); } private object ParseByToken(TOKEN token) { return token switch { TOKEN.STRING => ParseString(), TOKEN.NUMBER => ParseNumber(), TOKEN.CURLY_OPEN => ParseObject(), TOKEN.SQUARED_OPEN => ParseArray(), TOKEN.TRUE => true, TOKEN.FALSE => false, TOKEN.NULL => null, _ => null, }; } private string ParseString() { StringBuilder stringBuilder = new StringBuilder(); json.Read(); bool flag = true; while (flag) { if (json.Peek() == -1) { flag = false; break; } char nextChar = NextChar; switch (nextChar) { case '"': flag = false; break; case '\\': if (json.Peek() == -1) { flag = false; break; } nextChar = NextChar; switch (nextChar) { case '"': case '/': case '\\': stringBuilder.Append(nextChar); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'u': { char[] array = new char[4]; for (int i = 0; i < 4; i++) { array[i] = NextChar; if (!IsHexDigit(array[i])) { return null; } } stringBuilder.Append((char)Convert.ToInt32(new string(array), 16)); break; } } break; default: stringBuilder.Append(nextChar); break; } } return stringBuilder.ToString(); } private object ParseNumber() { string nextWord = NextWord; if (nextWord.IndexOf('.') == -1 && nextWord.IndexOf('E') == -1 && nextWord.IndexOf('e') == -1) { long.TryParse(nextWord, NumberStyles.Any, CultureInfo.InvariantCulture, out var result); return result; } double.TryParse(nextWord, NumberStyles.Any, CultureInfo.InvariantCulture, out var result2); return result2; } private void EatWhitespace() { while (char.IsWhiteSpace(PeekChar)) { json.Read(); if (json.Peek() == -1) { break; } } } } private sealed class Serializer { private StringBuilder builder; private Serializer() { builder = new StringBuilder(); } public static string Serialize(object obj) { Serializer serializer = new Serializer(); serializer.SerializeValue(obj); return serializer.builder.ToString(); } private void SerializeValue(object value) { if (value == null) { builder.Append("null"); } else if (value is string str) { SerializeString(str); } else if (value is bool) { builder.Append(((bool)value) ? "true" : "false"); } else if (value is IList anArray) { SerializeArray(anArray); } else if (value is IDictionary obj) { SerializeObject(obj); } else if (value is char) { SerializeString(new string((char)value, 1)); } else { SerializeOther(value); } } private void SerializeObject(IDictionary obj) { bool flag = true; builder.Append('{'); foreach (object key in obj.Keys) { if (!flag) { builder.Append(','); } SerializeString(key.ToString()); builder.Append(':'); SerializeValue(obj[key]); flag = false; } builder.Append('}'); } private void SerializeArray(IList anArray) { builder.Append('['); bool flag = true; for (int i = 0; i < anArray.Count; i++) { object value = anArray[i]; if (!flag) { builder.Append(','); } SerializeValue(value); flag = false; } builder.Append(']'); } private void SerializeString(string str) { builder.Append('"'); char[] array = str.ToCharArray(); foreach (char c in array) { switch (c) { case '"': builder.Append("\\\""); continue; case '\\': builder.Append("\\\\"); continue; case '\b': builder.Append("\\b"); continue; case '\f': builder.Append("\\f"); continue; case '\n': builder.Append("\\n"); continue; case '\r': builder.Append("\\r"); continue; case '\t': builder.Append("\\t"); continue; } int num = Convert.ToInt32(c); if (num >= 32 && num <= 126) { builder.Append(c); continue; } builder.Append("\\u"); builder.Append(num.ToString("x4")); } builder.Append('"'); } private void SerializeOther(object value) { if (value is float) { builder.Append(((float)value).ToString("R", CultureInfo.InvariantCulture)); } else if (value is int || value is uint || value is long || value is sbyte || value is byte || value is short || value is ushort || value is ulong) { builder.Append(value); } else if (value is double || value is decimal) { builder.Append(Convert.ToDouble(value).ToString("R", CultureInfo.InvariantCulture)); } else { SerializeString(value.ToString()); } } } public static object Deserialize(string json) { if (json == null) { return null; } return Parser.Parse(json); } public static string Serialize(object obj) { return Serializer.Serialize(obj); } } } namespace AbilityApi { public class Api { public class AbilityTextureMetaData { public Vector2 BackroundTopLeftCourner = default(Vector2); public Vector2 BackroundSize = default(Vector2); public Vector2 IconTopLeftCourner = default(Vector2); public Vector2 IconSize = default(Vector2); public Vector2 TotalSize = default(Vector2); } public static List<Texture2D> CustomAbilityTexstures = new List<Texture2D>(); public static Dictionary<NamedSprite, List<NamedSprite>> CustomAbilitySpritesWithBackrounds = new Dictionary<NamedSprite, List<NamedSprite>>(); public static List<NamedSprite> Sprites = new List<NamedSprite>(); public static AbilityGrid abilityGrid; public static T ConstructInstantAbility<T>(string name) where T : MonoUpdatable { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); Object.DontDestroyOnLoad((Object)(object)val); InstantAbility val2 = val.AddComponent<InstantAbility>(); val.AddComponent<FixTransform>(); MonoUpdatable val3 = (MonoUpdatable)(object)val.AddComponent<T>(); if ((Object)(object)val3 == (Object)null) { Object.Destroy((Object)(object)val); throw new MissingReferenceException("Invalid type was fed to ConstructInstantAbility"); } return (T)(object)val3; } public static Texture2D LoadImage(string path) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(1, 1); ImageConversion.LoadImage(val, array); return val; } public static void RegisterNamedSprites(NamedSprite namedSprite, bool IsOffensiveAbility) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) foreach (NamedSprite sprite in Sprites) { if (sprite.name == namedSprite.name) { throw new Exception("ERROR: ABILITY WITH NAME " + namedSprite.name + " ALREADY EXSITS! NOT CREATING ABILITY!"); } } ((Object)namedSprite.associatedGameObject).name = namedSprite.name; CustomAbilityTexstures.Add(namedSprite.sprite.texture); List<NamedSprite> list = new List<NamedSprite>(); NamedSprite item = default(NamedSprite); foreach (Texture2D backroundSprite in Plugin.BackroundSprites) { Texture2D val = OverlayBackround(namedSprite.sprite.texture, backroundSprite); Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((NamedSprite)(ref item))..ctor(namedSprite.name, val2, namedSprite.associatedGameObject, IsOffensiveAbility); list.Add(item); } CustomAbilitySpritesWithBackrounds.Add(namedSprite, list); Sprites.Add(namedSprite); } public static Texture2D OverlayBackround(Texture2D ability, Texture2D backround) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) Color32[,] array = Texture2DTo2DArray(ability); Color32[,] array2 = Texture2DTo2DArray(backround); Vector2Int val = default(Vector2Int); if (((Texture)ability).width > ((Texture)backround).width) { ((Vector2Int)(ref val)).x = ((Texture)ability).width; } else { ((Vector2Int)(ref val)).x = ((Texture)backround).width; } if (((Texture)ability).height > ((Texture)backround).height) { ((Vector2Int)(ref val)).y = ((Texture)ability).height; } else { ((Vector2Int)(ref val)).y = ((Texture)backround).height; } Vector2Int val2 = default(Vector2Int); ((Vector2Int)(ref val2))..ctor(((Vector2Int)(ref val)).x / 2, ((Vector2Int)(ref val)).y / 2); Vector2Int val3 = default(Vector2Int); ((Vector2Int)(ref val3))..ctor(((Vector2Int)(ref val2)).x - ((Texture)ability).width / 2, ((Vector2Int)(ref val2)).y - ((Texture)ability).height / 2); Vector2Int val4 = default(Vector2Int); ((Vector2Int)(ref val4))..ctor(((Vector2Int)(ref val2)).x - ((Texture)backround).width / 2, ((Vector2Int)(ref val2)).y - ((Texture)backround).height / 2); Color32[,] array3 = new Color32[((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y]; Color32[,] array4 = new Color32[((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y]; Color32[,] array5 = new Color32[((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y]; for (int i = 0; i < ((Texture)ability).width; i++) { for (int j = 0; j < ((Texture)ability).height; j++) { array4[i + ((Vector2Int)(ref val3)).x, j + ((Vector2Int)(ref val3)).y] = array[i, j]; } } for (int k = 0; k < ((Texture)backround).width; k++) { for (int l = 0; l < ((Texture)backround).height; l++) { array5[k + ((Vector2Int)(ref val4)).x, l + ((Vector2Int)(ref val4)).y] = array2[k, l]; } } for (int m = 0; m < ((Vector2Int)(ref val)).x; m++) { for (int n = 0; n < ((Vector2Int)(ref val)).y; n++) { Color32 val5 = array4[m, n]; Color32 val6 = array5[m, n]; if (val5.a >= 160) { array3[m, n] = val5; } else if (val6.a > 50) { array3[m, n] = MixColor32(val6, val5); } else { array3[m, n] = val6; } } } return TwoArrayToTexture2D(array3, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y); } private static Color32 MixColor32(Color32 background, Color32 overlay) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) float num = (float)(int)background.a / 255f; float num2 = (float)(int)overlay.a / 255f; float num3 = num + num2 * (1f - num); byte b = (byte)Mathf.Clamp(num3 * 255f, 0f, 255f); byte b2 = (byte)(((float)(int)overlay.r * num2 + (float)(int)background.r * num * (1f - num2)) / num3); byte b3 = (byte)(((float)(int)overlay.g * num2 + (float)(int)background.g * num * (1f - num2)) / num3); byte b4 = (byte)(((float)(int)overlay.b * num2 + (float)(int)background.b * num * (1f - num2)) / num3); return new Color32(b2, b3, b4, b); } private static Color32[,] Texture2DTo2DArray(Texture2D texture) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Color32[] pixels = texture.GetPixels32(); Color32[,] array = new Color32[((Texture)texture).width, ((Texture)texture).height]; for (int i = 0; i < ((Texture)texture).width; i++) { for (int j = 0; j < ((Texture)texture).height; j++) { array[i, j] = pixels[i + j * ((Texture)texture).width]; } } return array; } private static Texture2D TwoArrayToTexture2D(Color32[,] ColorData2D, int width, int height) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { array[i + j * width] = ColorData2D[i, j]; } } Texture2D val = new Texture2D(width, height, (TextureFormat)5, false); val.SetPixels32(array); val.Apply(); return val; } } internal class scroller { [HarmonyPatch(typeof(AbilityGrid), "Awake")] public static class AbilityGridPatch { public static void Postfix(AbilityGrid __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown Transform transform = ((Component)__instance).gameObject.transform; Transform val = transform.Find("bg"); if (!((Object)(object)transform.Find("scroller_content") == (Object)null)) { return; } RectTransform component = ((Component)val).GetComponent<RectTransform>(); RectTransform component2 = ((Component)__instance).gameObject.GetComponent<RectTransform>(); component2.sizeDelta = component.sizeDelta; component2.anchorMin = component.anchorMin; component2.anchorMax = component.anchorMax; component2.pivot = component.pivot; GameObject val2 = new GameObject("scroller_content"); RectTransform content = val2.AddComponent<RectTransform>(); ScrollRect val3 = val2.AddComponent<ScrollRect>(); val2.transform.SetParent(transform, false); IEnumerable<GameObject> enumerable = from child in ((Component)transform).GetComponentsInChildren<Transform>() where ((Object)((Component)child).gameObject).name == "AbilityGridEntry(Clone)" select ((Component)child).gameObject; foreach (GameObject item in enumerable) { item.transform.SetParent(val2.transform, false); } val2.SetActive(true); val3.content = content; val3.viewport = ((Component)transform).GetComponent<RectTransform>(); val3.scrollSensitivity = -5f; val3.horizontal = false; val3.movementType = (MovementType)1; val3.elasticity = 1f; } } } public class InstantTestAbility : MonoUpdatable { public void Awake() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Updater.RegisterUpdatable((MonoUpdatable)(object)this); InstantAbility component = ((Component)this).GetComponent<InstantAbility>(); if (component.funcOnEnter == null) { component.funcOnEnter = new UnityEvent(); } UnityEvent funcOnEnter = component.funcOnEnter; funcOnEnter.AddListener(new UnityAction(CastAbility)); } public void CastAbility() { AudioManager.Get().Play("startGame"); } public override void Init() { } public override void UpdateSim(Fix SimDeltaTime) { } } public static class PluginInfo { public const string PLUGIN_GUID = "AbilityApi"; public const string PLUGIN_NAME = "AbilityApi"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace AbilityApi.Internal { [BepInPlugin("com.David_Loves_JellyCar_Worlds.AbilityApi", "AbilityApi", "1.0.0")] public class Plugin : BaseUnityPlugin { public struct CircleEntry { public Sprite sprite; public Vector4 center; } [HarmonyPatch(typeof(AbilityReadyIndicator), "SetSprite")] public static class SpriteCirclePatch { public static void Postfix(AbilityReadyIndicator __instance, ref Sprite sprite) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (Api.CustomAbilityTexstures.Contains(sprite.texture)) { ((Renderer)__instance.spriteRen).material.SetVector("_CircleExtents", new Vector4(0f, 0f, 0f, 0f)); } else { ((Renderer)__instance.spriteRen).material.SetVector("_CircleExtents", defaultExtents); } } } [HarmonyPatch(typeof(AbilityGrid), "Awake")] public static class AbilityGridPatch { public static void Postfix(AbilityGrid __instance) { Api.abilityGrid = __instance; if (__instance.abilityIcons.sprites.Count == defaultAbilityCount) { Debug.Log((object)"adding"); __instance.abilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(AchievementHandler), "Awake")] public static class AchievementHandlerPatch { public static void Postfix(AchievementHandler __instance) { if (__instance.abilityIcons.sprites.Count == defaultAbilityCount) { __instance.abilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(CharacterStatsList), "TryStartNextLevel_online")] public static class CharacterStatsListPatch { public static void Prefix(CharacterStatsList __instance) { if (__instance.abilityIcons.sprites.Count == defaultAbilityCount) { __instance.abilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(DynamicAbilityPickup), "Awake")] public static class DynamicAbilityPickupPatch { public static void Postfix(DynamicAbilityPickup __instance) { if (__instance.abilityIcons.sprites.Count == defaultAbilityCount) { __instance.abilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(MidGameAbilitySelect), "Awake")] public static class MidGameAbilitySelectPatch { public static void Postfix(MidGameAbilitySelect __instance) { if (__instance.AbilityIcons.sprites.Count == defaultAbilityCount) { __instance.AbilityIcons.sprites.AddRange(Api.Sprites); __instance.localAbilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(RandomAbility), "Awake")] public static class RandomAbilityPatch { public static void Postfix(RandomAbility __instance) { if (__instance.abilityIcons.sprites.Count == defaultAbilityCount) { __instance.abilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(SelectAbility), "Awake")] public static class SelectAbilityPatch { public static void Postfix(SelectAbility __instance) { if (__instance.abilityIcons.sprites.Count == defaultAbilityCount) { __instance.abilityIcons.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(SlimeController), "Awake")] public static class SlimeControllerPatch { public static void Postfix(SlimeController __instance) { if (__instance.abilityIconsFull.sprites.Count == defaultAbilityCount) { __instance.abilityIconsFull.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(SteamManager), "Awake")] public static class SteamManagerPatch { public static void Postfix(SteamManager __instance) { if (__instance.abilityIconsFull.sprites.Count == defaultAbilityCount) { __instance.abilityIconsFull.sprites.AddRange(Api.Sprites); } } } [HarmonyPatch(typeof(CharacterSelectHandler_online), "InitPlayer")] public static class CharacterSelectHandler_onlinePatch { public static Player playerToReturn; public static bool Prefix(CharacterSelectHandler_online __instance, int id, byte color, byte team, byte ability1, byte ability2, byte ability3, int nrOfAbilities, PlayerColors playerColors) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) NamedSpriteList abilityIcons = SteamManager.instance.abilityIcons; Player val = new Player(); val.Id = id; val.Color = playerColors.playerColors[color].playerMaterial; val.Team = team; Debug.Log((object)$"team is {team}"); if (nrOfAbilities > 0) { if (Api.CustomAbilitySpritesWithBackrounds.ContainsKey(abilityIcons.sprites[ability1])) { val.Abilities.Add(Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[ability1]][team].associatedGameObject); val.AbilityIcons.Add(Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[ability1]][team].sprite); } else { val.Abilities.Add(abilityIcons.sprites[ability1].associatedGameObject); val.AbilityIcons.Add(abilityIcons.sprites[ability1].sprite); } } if (nrOfAbilities > 1) { if (Api.CustomAbilitySpritesWithBackrounds.ContainsKey(abilityIcons.sprites[ability2])) { val.Abilities.Add(Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[ability2]][team].associatedGameObject); val.AbilityIcons.Add(Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[ability2]][team].sprite); } else { val.Abilities.Add(abilityIcons.sprites[ability2].associatedGameObject); val.AbilityIcons.Add(abilityIcons.sprites[ability2].sprite); } } if (nrOfAbilities > 2) { if (Api.CustomAbilitySpritesWithBackrounds.ContainsKey(abilityIcons.sprites[ability3])) { val.Abilities.Add(Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[ability3]][team].associatedGameObject); val.AbilityIcons.Add(Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[ability3]][team].sprite); } else { val.Abilities.Add(abilityIcons.sprites[ability3].associatedGameObject); val.AbilityIcons.Add(abilityIcons.sprites[ability3].sprite); } } val.IsLocalPlayer = false; playerToReturn = val; return false; } public static void Postfix(CharacterSelectHandler_online __instance, ref Player __result) { __result = playerToReturn; } } [HarmonyPatch(typeof(CharacterSelectHandler), "TryStartGame_inner")] public static class CharacterSelectHandlerPatch { public static bool Prefix(CharacterSelectHandler __instance) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) if (CharacterSelectHandler.startButtonAvailable && CharacterSelectHandler.allReadyForMoreThanOneFrame) { AudioManager val = AudioManager.Get(); if ((Object)(object)val != (Object)null) { val.Play("startGame"); } CharacterSelectHandler.startButtonAvailable = false; List<Player> list = PlayerHandler.Get().PlayerList(); list.Clear(); int num = 1; NamedSpriteList abilityIcons = SteamManager.instance.abilityIcons; for (int i = 0; i < __instance.characterSelectBoxes.Length; i++) { if ((int)__instance.characterSelectBoxes[i].menuState != 2) { continue; } PlayerInit playerInit = __instance.characterSelectBoxes[i].playerInit; Player val2 = new Player(num, playerInit.team); val2.Color = __instance.playerColors[playerInit.color].playerMaterial; val2.UsesKeyboardAndMouse = playerInit.usesKeyboardMouse; val2.CanUseAbilities = true; val2.inputDevice = playerInit.inputDevice; val2.Abilities = new List<GameObject>(3); val2.AbilityIcons = new List<Sprite>(3); val2.Abilities.Add(abilityIcons.sprites[playerInit.ability0].associatedGameObject); if (Api.Sprites.Contains(abilityIcons.sprites[playerInit.ability0])) { List<NamedSprite> list2 = Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[playerInit.ability0]]; val2.AbilityIcons.Add(list2[val2.Team].sprite); } else { val2.AbilityIcons.Add(abilityIcons.sprites[playerInit.ability0].sprite); } Settings val3 = Settings.Get(); if ((Object)(object)val3 != (Object)null && val3.NumberOfAbilities > 1) { val2.Abilities.Add(abilityIcons.sprites[playerInit.ability1].associatedGameObject); if (Api.Sprites.Contains(abilityIcons.sprites[playerInit.ability1])) { List<NamedSprite> list3 = Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[playerInit.ability1]]; val2.AbilityIcons.Add(list3[val2.Team].sprite); } else { val2.AbilityIcons.Add(abilityIcons.sprites[playerInit.ability1].sprite); } } Settings val4 = Settings.Get(); if ((Object)(object)val4 != (Object)null && val4.NumberOfAbilities > 2) { val2.Abilities.Add(abilityIcons.sprites[playerInit.ability2].associatedGameObject); if (Api.Sprites.Contains(abilityIcons.sprites[playerInit.ability2])) { List<NamedSprite> list4 = Api.CustomAbilitySpritesWithBackrounds[abilityIcons.sprites[playerInit.ability2]]; val2.AbilityIcons.Add(list4[val2.Team].sprite); } else { val2.AbilityIcons.Add(abilityIcons.sprites[playerInit.ability2].sprite); } } val2.CustomKeyBinding = playerInit.keybindOverride; num++; list.Add(val2); } GameSession.Init(); SceneManager.LoadScene("Level1"); if (!WinnerTriangleCanvas.HasBeenSpawned) { SceneManager.LoadScene("winnerTriangle", (LoadSceneMode)1); } } return false; } } public static int defaultAbilityCount = 30; public static Vector4 defaultExtents = new Vector4(0.04882813f, 0.04882813f, 0.08300781f, 0.9287109f); public static string directoryToModFolder = ""; public static InstantTestAbility testAbilityPrefab; public static Texture2D testAbilityTex; public static Sprite testSprite; public static List<Texture2D> BackroundSprites = new List<Texture2D>(); private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin AbilityApi is loaded!"); Harmony val = new Harmony("com.David_Loves_JellyCar_Worlds.AbilityApi"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"harmany created"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AbilityApi Patch Compleate!"); new Harmony("AbilityApi").PatchAll(Assembly.GetExecutingAssembly()); directoryToModFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); BackroundSprites.Add(Api.LoadImage(Path.Combine(directoryToModFolder, "BlueTeam.png"))); BackroundSprites.Add(Api.LoadImage(Path.Combine(directoryToModFolder, "OrangeTeam.png"))); BackroundSprites.Add(Api.LoadImage(Path.Combine(directoryToModFolder, "GreenTeam.png"))); BackroundSprites.Add(Api.LoadImage(Path.Combine(directoryToModFolder, "PinkTeam.png"))); } } }