Decompiled source of CustomGraffiti v1.0.5

CustomGraffiti.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Reptile;
using Reptile.Phone;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CustomGraffiti")]
[assembly: AssemblyDescription("A mod that allows the user to add custom graffiti into Bomb Rush Cyberfunk.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("dance.tari")]
[assembly: AssemblyProduct("CustomGraffiti")]
[assembly: AssemblyCopyright("Copyright © tari.dance 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("599d5395-7651-401e-8755-c3e08bdadead")]
[assembly: AssemblyFileVersion("1.0.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.5.0")]
namespace CustomGraffiti
{
	public class CustomGraffiti
	{
		private string _name;

		private Texture2D _texture;

		private GraffitiSize _size;

		private Combos _combo;

		private GraffitiAppEntry _appEntry;

		private GraffitiArt _art;

		public string Name
		{
			get
			{
				return _name;
			}
			set
			{
				_name = value;
				_appEntry.Title = value;
				_art.title = value;
			}
		}

		public Texture2D Texture
		{
			get
			{
				return _texture;
			}
			set
			{
				_texture = value;
				_appEntry.GraffitiTexture = (Texture)(object)value;
				_art.graffitiMaterial.mainTexture = (Texture)(object)value;
			}
		}

		public GraffitiSize Size
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				return _size;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				_size = value;
				_appEntry.Size = value;
				_art.graffitiSize = value;
			}
		}

		public Combos Combo
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				return _combo;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				_combo = value;
				_appEntry.Combos = value;
				_art.combos = value;
			}
		}

		public Combos combos => Combo;

		public GraffitiArt Art => _art;

		public GraffitiAppEntry AppEntry => _appEntry;

		public CustomGraffiti()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			_art = new GraffitiArt();
			_art.graffitiMaterial = new Material(Shader.Find("Standard"));
			_texture = null;
			_size = (GraffitiSize)0;
			_combo = (Combos)(-1);
			_name = "Empty Custom Graffiti";
			_appEntry = ScriptableObject.CreateInstance<GraffitiAppEntry>();
			_art.unlockable = _appEntry;
		}

		public void AddToGraffitiArtInfo()
		{
			GraffitiLoader graffitiLoader = GetGraffitiLoader();
			if (graffitiLoader == null)
			{
				CustomGraffitiMod.Log.LogWarning((object)"GraffitiLoader was null.");
				return;
			}
			if ((Object)(object)graffitiLoader.GraffitiArtInfo == (Object)null)
			{
				CustomGraffitiMod.Log.LogWarning((object)"GraffitiArtInfo was null.");
				return;
			}
			if (graffitiLoader.GraffitiArtInfo.graffitiArt == null)
			{
				CustomGraffitiMod.Log.LogWarning((object)"graffitiArt List was null.");
				return;
			}
			foreach (GraffitiArt item in graffitiLoader.GraffitiArtInfo.graffitiArt)
			{
				if (item == Art)
				{
					CustomGraffitiMod.Log.LogWarning((object)"This custom graffiti is already in the graffiti art info. Returning.");
					return;
				}
			}
			graffitiLoader.GraffitiArtInfo.graffitiArt.Add(Art);
		}

		public void FixShader()
		{
			FixShaderGraffiti(_art.graffitiMaterial);
		}

		public static void FixShaderGraffiti(Material material)
		{
			GraffitiLoader graffitiLoader = GetGraffitiLoader();
			if (graffitiLoader == null)
			{
				CustomGraffitiMod.Log.LogWarning((object)"Failed to fix shader graffiti.");
				return;
			}
			Material graffitiMaterial = graffitiLoader.GraffitiArtInfo.FindByCharacter((Characters)3).graffitiMaterial;
			material.shader = graffitiMaterial.shader;
		}

		public static GraffitiLoader GetGraffitiLoader()
		{
			if ((Object)(object)Core.Instance == (Object)null)
			{
				return null;
			}
			if ((Object)(object)Core.Instance.Assets == (Object)null)
			{
				CustomGraffitiMod.Log.LogWarning((object)"Core Assets not initialized yet.");
				return null;
			}
			return Core.Instance.Assets.GetAssetsLoader<GraffitiLoader>();
		}
	}
	[BepInPlugin("dance.tari.bombrushcyberfunk.customgraffiti", "CustomGraffiti", "1.0.5")]
	[BepInProcess("Bomb Rush Cyberfunk.exe")]
	public class CustomGraffitiMod : BaseUnityPlugin
	{
		private static Harmony _harmonyInstance;

		private static CustomGraffitiMod _modInstance;

		public static List<CustomGraffiti> LoadedGraffiti;

		private GraffitiLoader _loaderInstance;

		private bool _initialized = false;

		public static CustomGraffitiMod Instance => _modInstance;

		public static ManualLogSource Log => ((BaseUnityPlugin)_modInstance).Logger;

		public CustomGraffitiMod()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			_modInstance = this;
			_harmonyInstance = new Harmony("dance.tari.bombrushcyberfunk.customgraffiti.patch");
			LoadedGraffiti = new List<CustomGraffiti>();
		}

		public static CustomGraffiti AddCustomGraffitiFromFilePath(string filePath)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			string directoryName = Path.GetDirectoryName(filePath);
			directoryName = directoryName.Substring(directoryName.LastIndexOf('\\') + 1, directoryName.Length - directoryName.LastIndexOf('\\') - 1);
			GraffitiSize size = (GraffitiSize)0;
			switch (directoryName)
			{
			case "Small":
				size = (GraffitiSize)0;
				break;
			case "Medium":
				size = (GraffitiSize)1;
				break;
			case "Large":
				size = (GraffitiSize)2;
				break;
			case "ExtraLarge":
				size = (GraffitiSize)3;
				break;
			}
			return AddCustomGraffitiFromFilePath(filePath, size);
		}

		public static CustomGraffiti AddCustomGraffitiFromFilePath(string filePath, GraffitiSize size)
		{
			//IL_0022: 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)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected I4, but got Unknown
			//IL_012e: 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)
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
			string extension = Path.GetExtension(filePath);
			string[] array = fileNameWithoutExtension.Split(new char[1] { '_' });
			Combos val = (Combos)(-1);
			string name;
			if (array.Length >= 2)
			{
				string numericComboString = array[0];
				Combos val2 = ParseCombo(numericComboString);
				val = val2;
				name = string.Join("_", array, 1, array.Length - 1);
			}
			else
			{
				name = fileNameWithoutExtension;
			}
			if ((int)val == -1 && (int)size > 0)
			{
				string text = "";
				switch (size - 1)
				{
				case 0:
					text = "1234";
					break;
				case 1:
					text = "12345";
					break;
				case 2:
					text = "123456";
					break;
				}
				Log.LogError((object)("Unable to add graffiti " + fileNameWithoutExtension + ". Graffiti larger than small graffiti need a combo in the file name, such as '" + text + "_" + fileNameWithoutExtension + extension + "'. The underscore to separate the combo from the name is required!"));
				return null;
			}
			Texture2D val3 = LoadTexture(filePath);
			if ((Object)(object)val3 == (Object)null)
			{
				return null;
			}
			CustomGraffiti customGraffiti = new CustomGraffiti();
			customGraffiti.Name = name;
			customGraffiti.Combo = val;
			customGraffiti.Texture = val3;
			customGraffiti.Size = size;
			LoadedGraffiti.Add(customGraffiti);
			return customGraffiti;
		}

		public static List<CustomGraffiti> GetCustomGraffitiBySize(GraffitiSize size)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			List<CustomGraffiti> list = new List<CustomGraffiti>();
			foreach (CustomGraffiti item in LoadedGraffiti)
			{
				if (item.Size == size)
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static List<CustomGraffiti> GetCustomGraffitiByCombo(Combos combo)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			List<CustomGraffiti> list = new List<CustomGraffiti>();
			foreach (CustomGraffiti item in LoadedGraffiti)
			{
				if (item.Combo == combo)
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static List<CustomGraffiti> GetCustomGraffitiByName(string name)
		{
			List<CustomGraffiti> list = new List<CustomGraffiti>();
			foreach (CustomGraffiti item in LoadedGraffiti)
			{
				if (item.Name == name)
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static Texture2D LoadTexture(string filePath)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
			string extension = Path.GetExtension(filePath);
			if (extension != ".jpg" && extension != ".png")
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Cannot load graffiti: " + fileNameWithoutExtension + extension + ". Only .png and .jpg files are accepted."));
				return null;
			}
			Texture2D val = new Texture2D(2, 2);
			if (ImageConversion.LoadImage(val, File.ReadAllBytes(filePath)))
			{
				val.Apply();
				return val;
			}
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Could not load image data of " + fileNameWithoutExtension + extension + "."));
			return null;
		}

		public static Combos ParseCombo(string numericComboString)
		{
			//IL_0031: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (int.TryParse(numericComboString, out var result))
			{
				Combos val = (Combos)result;
				if (Enum.IsDefined(typeof(Combos), val))
				{
					return val;
				}
			}
			return (Combos)(-1);
		}

		private void Uninitialize()
		{
			if (_initialized)
			{
				_initialized = false;
				Log.LogWarning((object)"Uninitialized.");
				LoadedGraffiti.Clear();
			}
		}

		private void Initialize()
		{
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			if (_initialized)
			{
				return;
			}
			Log.LogWarning((object)"Initialized.");
			string text = "CustomGraffiti";
			string text2 = Paths.BepInExRootPath + "\\" + text;
			string path = Path.Combine(text2, "Small") + "/";
			string path2 = Path.Combine(text2, "Medium") + "/";
			string path3 = Path.Combine(text2, "Large") + "/";
			string path4 = Path.Combine(text2, "ExtraLarge") + "/";
			if (!Directory.Exists(text2))
			{
				Directory.CreateDirectory(text2);
			}
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}
			if (!Directory.Exists(path2))
			{
				Directory.CreateDirectory(path2);
			}
			if (!Directory.Exists(path3))
			{
				Directory.CreateDirectory(path3);
			}
			if (!Directory.Exists(path4))
			{
				Directory.CreateDirectory(path4);
			}
			string[] files = Directory.GetFiles(path);
			string[] files2 = Directory.GetFiles(path2);
			string[] files3 = Directory.GetFiles(path3);
			string[] files4 = Directory.GetFiles(path4);
			List<string> list = new List<string>();
			list.AddRange(files);
			list.AddRange(files2);
			list.AddRange(files3);
			list.AddRange(files4);
			foreach (string item in list)
			{
				AddCustomGraffitiFromFilePath(item);
			}
			foreach (CustomGraffiti item2 in LoadedGraffiti)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"{item2.Name}, Size: {item2.Size}, Combo: {item2.Combo}");
				item2.FixShader();
				item2.AddToGraffitiArtInfo();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Custom Graffiti successfully initialized.");
		}

		private void Awake()
		{
			Harmony harmonyInstance = _harmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.PatchAll();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Custom Graffiti patched successfully.");
		}

		private void OnDestroy()
		{
			Harmony harmonyInstance = _harmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
			LoadedGraffiti.Clear();
		}

		private void Update()
		{
			if (_loaderInstance == null)
			{
				Uninitialize();
				GraffitiLoader graffitiLoader = CustomGraffiti.GetGraffitiLoader();
				if (graffitiLoader == null)
				{
					return;
				}
				_loaderInstance = graffitiLoader;
			}
			if ((Object)(object)_loaderInstance.GraffitiArtInfo != (Object)null)
			{
				if (_loaderInstance.GraffitiArtInfo.graffitiArt != null && !_initialized)
				{
					Initialize();
					_initialized = true;
				}
				else if (_loaderInstance.GraffitiArtInfo.graffitiArt == null)
				{
					Uninitialize();
				}
			}
			else
			{
				Uninitialize();
			}
		}
	}
}
namespace CustomGraffiti.Plugin
{
	public static class PluginMetadata
	{
		public const string GUID = "dance.tari.bombrushcyberfunk.customgraffiti";

		public const string Name = "CustomGraffiti";

		public const string Version = "1.0.5";
	}
}
namespace CustomGraffiti.Patches
{
	[HarmonyPatch(typeof(AppGraffiti))]
	internal class PatchAppGraffiti
	{
		[HarmonyPatch("RefreshList")]
		[HarmonyPostfix]
		private static void Postfix(AppGraffiti __instance)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Invalid comparison between Unknown and I4
			Traverse val = Traverse.Create((object)__instance);
			Traverse<List<GraffitiAppEntry>> val2 = val.Property<List<GraffitiAppEntry>>("GraffitiArt", (object[])null);
			Traverse<GraffitiScrollView> val3 = val.Field<GraffitiScrollView>("m_ScrollView");
			List<CustomGraffiti> loadedGraffiti = CustomGraffitiMod.LoadedGraffiti;
			List<GraffitiAppEntry> value = val2.Value;
			for (int i = 0; i < value.Count; i++)
			{
				for (int j = 0; j < loadedGraffiti.Count; j++)
				{
					if (value[i].Combos == loadedGraffiti[j].combos)
					{
						value.RemoveAt(i);
						i--;
						break;
					}
				}
			}
			for (int k = 0; k < loadedGraffiti.Count; k++)
			{
				CustomGraffiti customGraffiti = loadedGraffiti[k];
				if ((int)customGraffiti.Size != 0)
				{
					if ((Object)(object)customGraffiti.AppEntry == (Object)null)
					{
						CustomGraffitiMod.Log.LogWarning((object)("Cannot create app entry for " + customGraffiti.Name + "."));
					}
					else
					{
						value.Add(customGraffiti.AppEntry);
					}
				}
			}
			val2.Value = value;
			((PhoneScroll)val3.Value).SetListContent(value.Count);
		}
	}
	[HarmonyPatch(typeof(GraffitiArtInfo))]
	internal class PatchGraffitiArtInfo
	{
		[HarmonyPatch("GetAvailableTargets")]
		[HarmonyPrefix]
		private static bool Prefix(GraffitiArtInfo __instance, List<GraffitiArt> unlockedGraffitiArt, List<int> targetSequence, GraffitiSize grafSize, ref int __result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected I4, but got Unknown
			//IL_00e0: 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_00ff: Expected I4, but got Unknown
			int num = 0;
			int num2 = grafSize + 3;
			int count = targetSequence.Count;
			if ((int)grafSize == 0 || count == num2)
			{
				__result = int.MaxValue;
				return false;
			}
			for (int i = 0; i < unlockedGraffitiArt.Count; i++)
			{
				int num3 = (int)unlockedGraffitiArt[i].combos;
				int num4 = (int)Mathf.Pow(10f, (float)(num2 - 1 - count));
				int num5 = num3 / num4 % 10;
				int num6 = 1;
				for (int j = 0; j < count; j++)
				{
					num4 = (int)Mathf.Pow(10f, (float)(num2 - 1 - (count - j - 1)));
					int num7 = num3 / num4 % 10;
					num6 &= Convert.ToInt32(num7 == targetSequence[count - j - 1]);
				}
				num |= num6 << num5;
			}
			List<CustomGraffiti> customGraffitiBySize = CustomGraffitiMod.GetCustomGraffitiBySize(grafSize);
			for (int k = 0; k < customGraffitiBySize.Count; k++)
			{
				int num8 = (int)customGraffitiBySize[k].Combo;
				int num9 = (int)Mathf.Pow(10f, (float)(num2 - 1 - count));
				int num10 = num8 / num9 % 10;
				int num11 = 1;
				for (int l = 0; l < count; l++)
				{
					num9 = (int)Mathf.Pow(10f, (float)(num2 - 1 - (count - l - 1)));
					int num12 = num8 / num9 % 10;
					num11 &= Convert.ToInt32(num12 == targetSequence[count - l - 1]);
				}
				num |= num11 << num10;
			}
			__result = num;
			return false;
		}
	}
	[HarmonyPatch(typeof(GraffitiGame))]
	internal class PatchGraffitiGame
	{
		[HarmonyPatch("SetState")]
		[HarmonyPrefix]
		private static bool Prefix(GraffitiGame __instance, GraffitiGameState setState)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Invalid comparison between Unknown and I4
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Invalid comparison between I4 and Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Invalid comparison between Unknown and I4
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Invalid comparison between Unknown and I4
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Invalid comparison between Unknown and I4
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Invalid comparison between Unknown and I4
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Invalid comparison between Unknown and I4
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			if ((int)setState != 2)
			{
				return true;
			}
			Traverse val = Traverse.Create((object)__instance);
			GraffitiGameState value = val.Field("state").GetValue<GraffitiGameState>();
			float value2 = val.Field("stateTimer").GetValue<float>();
			value = setState;
			value2 = 0f;
			val.Field("state").SetValue((object)value);
			val.Field("stateTimer").SetValue((object)value2);
			GraffitiSpot value3 = val.Field("gSpot").GetValue<GraffitiSpot>();
			GraffitiArt val2 = val.Field("grafArt").GetValue<GraffitiArt>();
			GraffitiArtInfo value4 = val.Field("graffitiArtInfo").GetValue<GraffitiArtInfo>();
			Player value5 = val.Field("player").GetValue<Player>();
			LineRenderer value6 = val.Field("line").GetValue<LineRenderer>();
			FieldInfo field = ((object)value5).GetType().GetField("character", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
			Characters val3 = (Characters)field.GetValue(value5);
			List<int> value7 = val.Field("targetsHitSequence").GetValue<List<int>>();
			object value8 = val.Field("targets").GetValue();
			object[] array = value8 as object[];
			if ((int)value3.size == 0)
			{
				List<CustomGraffiti> customGraffitiBySize = CustomGraffitiMod.GetCustomGraffitiBySize(value3.size);
				if (customGraffitiBySize.Count > 0)
				{
					CustomGraffiti customGraffiti = customGraffitiBySize[Random.Range(0, customGraffitiBySize.Count)];
					val2 = customGraffiti.Art;
				}
				else
				{
					val2 = value4.FindByCharacter(val3);
				}
				val.Field("grafArt").SetValue((object)val2);
				((Component)value6).gameObject.SetActive(false);
				object[] array2 = array;
				foreach (object obj in array2)
				{
					if (obj != null)
					{
						Type type = obj.GetType();
						PropertyInfo property = type.GetProperty("Transform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty);
						object value9 = property.GetValue(obj);
						Transform val4 = (Transform)((value9 is Transform) ? value9 : null);
						Object.Destroy((Object)(object)((Component)val4).gameObject);
					}
				}
			}
			else
			{
				if (value7.Count > value3.size + 3)
				{
					value7.RemoveAt(value7.Count - 1);
				}
				List<CustomGraffiti> customGraffitiByCombo = CustomGraffitiMod.GetCustomGraffitiByCombo(ParseComboBySequence(value7));
				if (customGraffitiByCombo.Count > 0)
				{
					CustomGraffiti customGraffiti2 = customGraffitiByCombo[Random.Range(0, customGraffitiByCombo.Count)];
					val2 = customGraffiti2.Art;
				}
				if (val2 == null)
				{
					val2 = value4.FindBySequence(value7);
				}
				val.Field("grafArt").SetValue((object)val2);
			}
			TrickType val5 = (TrickType)16;
			if ((int)value3.size == 1)
			{
				val5 = (TrickType)17;
			}
			if ((int)value3.size == 2)
			{
				val5 = (TrickType)18;
			}
			if ((int)value3.size == 3)
			{
				val5 = (TrickType)19;
			}
			value5.DoTrick(val5, val2.title, 0);
			bool flag = (int)value3.bottomCrew == 1 || (int)value3.bottomCrew == 7;
			Type type2 = ((object)value3).GetType();
			MethodInfo method = type2.GetMethod("Paint", BindingFlags.Instance | BindingFlags.NonPublic);
			method.Invoke(value3, new object[3]
			{
				(object)(Crew)1,
				val2,
				null
			});
			MethodInfo method2 = type2.GetMethod("GiveRep", BindingFlags.Instance | BindingFlags.Public);
			if (method2.GetParameters().Length == 0)
			{
				method2.Invoke(value3, null);
			}
			else
			{
				method2.Invoke(value3, new object[2] { false, flag });
			}
			MethodInfo method3 = ((object)__instance).GetType().GetMethod("SetStateVisual", BindingFlags.Instance | BindingFlags.NonPublic);
			method3.Invoke(__instance, new object[1] { value });
			return false;
		}

		private static Combos ParseComboBySequence(List<int> sequence)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			int num = 0;
			int count = sequence.Count;
			for (int i = 0; i < count; i++)
			{
				num += sequence[i] * (int)Mathf.Pow(10f, (float)(count - i - 1));
			}
			return (Combos)num;
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal class PatchPlayer
	{
		[HarmonyPatch("DoTrick")]
		[HarmonyPrefix]
		private static bool Prefix(Player __instance, TrickType type, string trickName = "", int trickNum = 0)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Invalid comparison between Unknown and I4
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Invalid comparison between Unknown and I4
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Invalid comparison between Unknown and I4
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Invalid comparison between Unknown and I4
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Invalid comparison between Unknown and I4
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Invalid comparison between Unknown and I4
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Invalid comparison between Unknown and I4
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Invalid comparison between Unknown and I4
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Invalid comparison between Unknown and I4
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Invalid comparison between Unknown and I4
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Invalid comparison between Unknown and I4
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Invalid comparison between Unknown and I4
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Invalid comparison between Unknown and I4
			Traverse val = Traverse.Create((object)__instance);
			MethodInfo method = ((object)__instance).GetType().GetMethod("IsGraffitiTypeTrick", BindingFlags.Instance | BindingFlags.NonPublic);
			bool flag = (bool)method.Invoke(__instance, new object[1] { type });
			if (!flag)
			{
				return true;
			}
			int num = val.Field("currentTrickPoints").GetValue<int>();
			int value = val.Field("newGraffitiBonusMulti").GetValue<int>();
			List<string> value2 = val.Field("graffitiTitlesDone").GetValue<List<string>>();
			if ((int)type == 16)
			{
				num = 500;
				value = 1;
			}
			else
			{
				List<CustomGraffiti> customGraffitiByName = CustomGraffitiMod.GetCustomGraffitiByName(trickName);
				value = ((customGraffitiByName.Count > 0 || value2.Contains(trickName)) ? 1 : 2);
				value2.Add(trickName);
				val.Field("graffitiTitlesDone").SetValue((object)value2);
				if ((int)type == 17)
				{
					num = 1000 * value;
				}
				if ((int)type == 18)
				{
					num = 1600 * value;
				}
				if ((int)type == 19)
				{
					num = 2000 * value;
				}
			}
			val.Field("currentTrickPoints").SetValue((object)num);
			val.Field("newGraffitiBonusMulti").SetValue((object)value);
			__instance.ResetComboTimeOut();
			float value3 = val.Field("moveInScoreTimer").GetValue<float>();
			TrickType value4 = val.Field("currentTrickType").GetValue<TrickType>();
			int value5 = val.Field("tricksInCombo").GetValue<int>();
			GameplayUI value6 = val.Field("ui").GetValue<GameplayUI>();
			AnimationCurve value7 = val.Field("gainBoostChargeCurve").GetValue<AnimationCurve>();
			float value8 = val.Field("showAddCharge").GetValue<float>();
			float value9 = val.Field("scoreMultiplier").GetValue<float>();
			string value10 = val.Field("currentTrickName").GetValue<string>();
			bool value11 = val.Field("currentTrickOnFoot").GetValue<bool>();
			bool value12 = val.Field("usingEquippedMovestyle").GetValue<bool>();
			float value13 = val.Field("scoreFactor").GetValue<float>();
			bool value14 = val.Field("didAbilityTrick").GetValue<bool>();
			float value15 = val.Field("baseScore").GetValue<float>();
			value3 = 1f;
			if (((int)value4 == 12 && (int)type == 12) || ((int)value4 == 22 && (int)type == 22))
			{
				value3 = 0f;
			}
			else
			{
				if (value5 == 0 && (Object)(object)value6 != (Object)null)
				{
					value6.SetTrickingChargeBarActive(true);
				}
				value5++;
				if (value5 >= 5)
				{
					__instance.AddBoostCharge(value8 = value7.Evaluate(Mathf.Min((float)value5, 50f) / 50f));
					val.Field("showAddCharge").SetValue((object)value8);
				}
				val.Field("tricksInCombo").SetValue((object)value5);
			}
			val.Field("moveInScoreTimer").SetValue((object)value3);
			if ((int)type != 1 && (int)type != 12 && !flag && (int)type != 22)
			{
				bool flag2 = (int)type == 8 || (int)type == 3 || (int)type == 5 || (int)type == 9;
				__instance.TryToRemoveCuff((!flag2) ? 1 : 5);
			}
			if (value9 == 0f)
			{
				value9 = 1f;
				val.Field("scoreMultiplier").SetValue((object)value9);
			}
			if (trickName == "")
			{
				trickName = ((object)(TrickType)(ref type)).ToString();
			}
			value4 = type;
			val.Field("currentTrickType").SetValue((object)value4);
			value10 = trickName;
			val.Field("currentTrickName").SetValue((object)value10);
			value11 = !value12;
			val.Field("currentTrickOnFoot").SetValue((object)value11);
			value15 += (float)(int)((float)num * value13);
			val.Field("baseScore").SetValue((object)value15);
			value14 = true;
			val.Field("didAbilityTrick").SetValue((object)value14);
			return false;
		}
	}
}