using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PluginConfig.API; using PluginConfig.API.Decorators; using PluginConfig.API.Fields; using TMPro; using UltraKasane.Properties; using UnityEngine; 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: ComVisible(false)] [assembly: Guid("6a88a782-cbb3-48de-8fc3-24f2aa8c9765")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("tweeni")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Teto")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ULTRA_KASANE")] [assembly: AssemblyTitle("ULTRA_KASANE")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace UltraKasane { public class Class1 { } public class PunchPatcherStart { public static ManualLogSource logSource; public static void DoPatching(ManualLogSource logSource) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown PunchPatcherStart.logSource = logSource; Harmony val = new Harmony("com.tweeni.ultrakasane.patcher"); val.PatchAll(); } } [HarmonyPatch(typeof(Punch))] [HarmonyPatch("Awake")] internal class PunchPatcher { private static FieldRef smr = AccessTools.FieldRefAccess("smr"); private static void Postfix(Punch __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: 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_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.type > 0) { return; } SkinnedMeshRenderer val = smr.Invoke(__instance); Mesh feedbackerMesh = UltraKasaneMain.feedbackerMesh; List list = new List(val.bones); List feedbackerBoneNames = UltraKasaneMain.feedbackerBoneNames; Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[feedbackerMesh.bindposeCount]; if (UltraKasaneMain.TetoArmIsEnabled) { Dictionary dictionary = new Dictionary(); int i; for (i = 0; i < feedbackerMesh.bindposeCount; i++) { int num = list.FindIndex((Transform tr) => ((Object)tr).name == feedbackerBoneNames[i]); if (num != -1) { dictionary[i] = num; Transform val2 = list[num]; array[i] = feedbackerMesh.bindposes[num]; } else { array[i] = Matrix4x4.identity; Console.WriteLine("Bone mismatch; no corresponding bone for: " + feedbackerBoneNames[i]); } } BoneWeight[] boneWeights = feedbackerMesh.boneWeights; for (int j = 0; j < boneWeights.Length; j++) { ((BoneWeight)(ref boneWeights[j])).boneIndex0 = dictionary[((BoneWeight)(ref boneWeights[j])).boneIndex0]; ((BoneWeight)(ref boneWeights[j])).boneIndex1 = dictionary[((BoneWeight)(ref boneWeights[j])).boneIndex1]; ((BoneWeight)(ref boneWeights[j])).boneIndex2 = dictionary[((BoneWeight)(ref boneWeights[j])).boneIndex2]; ((BoneWeight)(ref boneWeights[j])).boneIndex3 = dictionary[((BoneWeight)(ref boneWeights[j])).boneIndex3]; } feedbackerMesh.bindposes = array; feedbackerMesh.boneWeights = boneWeights; val.sharedMesh = feedbackerMesh; Material sharedMaterial = ((Renderer)val).sharedMaterial; List list2 = new List(); for (int k = 0; k < UltraKasaneMain.feedbackerMats.Length; k++) { Material val3 = Object.Instantiate(sharedMaterial); val3.mainTexture = UltraKasaneMain.feedbackerMats[k].mainTexture; val3.color = new Color(0.95f, 0.95f, 0.95f); list2.Add(val3); } ((Renderer)val).sharedMaterials = list2.ToArray(); } int num2 = 0; while (true) { int num3 = num2; _ = list.Count; if (num3 < 0) { Matrix4x4 val4 = ((Component)__instance).transform.localToWorldMatrix * ((Matrix4x4)(ref val.sharedMesh.bindposes[num2])).inverse; list[num2].position = Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(3)); list[num2].rotation = Quaternion.LookRotation(Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(2)), Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(1))); num2++; continue; } break; } } private static string PrintBoneStructure(IList trans) { return BoneNameRecursive(trans[0]); } private static string BoneNameRecursive(Transform trans, string __pad = "") { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown string text = ((Object)trans).name + "\n"; foreach (Transform tran in trans) { Transform trans2 = tran; text = text + __pad + BoneNameRecursive(trans2, __pad + "| "); } return text; } private static List FindLeafBones(Transform root) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown List list = new List(); if (root.childCount == 0) { list.Add(root); } else { foreach (Transform item in root) { Transform root2 = item; list.AddRange(FindLeafBones(root2)); } } return list; } private static void GetSkeleton(SkinnedMeshRenderer smr, Matrix4x4 rootWorld) { //IL_0025: 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_0054: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Mesh sharedMesh = smr.sharedMesh; Transform[] bones = smr.bones; Matrix4x4[] bindposes = sharedMesh.bindposes; string text = ""; for (int i = 0; i < bones.Length; i++) { Matrix4x4 val = bindposes[i]; text = text + "\n { \"" + ((Object)bones[i]).name + "\", " + StringUtils.Matrix4x4ToCsharp(rootWorld * ((Matrix4x4)(ref val)).inverse) + " },"; } List list = FindLeafBones(bones[0]); foreach (Transform item in list) { text = text + "\n { \"" + ((Object)item).name + "\", " + StringUtils.Matrix4x4ToCsharp(item.localToWorldMatrix) + " },"; } Console.WriteLine("\nnew Dictionary()\n{" + text + "\n};"); } } internal class StringUtils { public static string Matrix4x4ToCsharp(Matrix4x4 matrix) { string[] array = new string[4]; for (int i = 0; i < 4; i++) { string[] array2 = new string[4]; for (int j = 0; j < 4; j++) { array2[j] = ((Matrix4x4)(ref matrix))[j, i].ToString("G17") + "f"; } array[i] = "new Vector4(" + string.Join(", ", array2) + ")"; } return "new Matrix4x4(" + string.Join(", ", array) + ")"; } } [BepInPlugin("com.tweeni.ultrakasane", "ULTRA_KASANE", "1.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class UltraKasaneMain : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static BoolValueChangeEventDelegate <>9__16_0; internal void b__16_0(BoolValueChangeEvent e) { TetoArmIsEnabled = e.value; } } public const string pluginGuid = "com.tweeni.ultrakasane"; public const string pluginName = "ULTRA_KASANE"; public const string pluginVersion = "1.0.3"; public static AssetBundle tetoAssetBundle; public static Mesh feedbackerMesh; public static Material[] feedbackerMats; public static List feedbackerBoneNames; private static PluginConfigurator config; private GameObject spriteObject = null; private BoolField armToggle; private BoolField textmodeToggle; public static bool TetoArmIsEnabled { get; private set; } private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"I'm a pear"); try { tetoAssetBundle = AssetBundle.LoadFromMemory(Resources.teto); string[] allAssetNames = tetoAssetBundle.GetAllAssetNames(); foreach (string text in allAssetNames) { } GameObject val = tetoAssetBundle.LoadAsset("teto_feedbacker_variant"); SkinnedMeshRenderer componentInChildren = Object.Instantiate(val).GetComponentInChildren(); spriteObject = tetoAssetBundle.LoadAsset("TextmodeTeto"); PluginConfig_init(); feedbackerBoneNames = new List(new string[componentInChildren.bones.Length]); for (int j = 0; j < componentInChildren.bones.Length; j++) { feedbackerBoneNames[j] = ((Object)componentInChildren.bones[j]).name; } feedbackerMesh = componentInChildren.sharedMesh; feedbackerMats = ((Renderer)componentInChildren).sharedMaterials; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)"Vital component of Teto could not be loaded. Teto will not run."); ((BaseUnityPlugin)this).Logger.LogError((object)ex.Message); tetoAssetBundle.Unload(false); return; } PunchPatcherStart.DoPatching(((BaseUnityPlugin)this).Logger); SceneManager.sceneLoaded += SceneManager_sceneLoaded; } private void PluginConfig_init() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00ec: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown config = PluginConfigurator.Create("ULTRA_KASANE", "com.tweeni.ultrakasane"); ConfigPanel rootPanel = config.rootPanel; armToggle = new BoolField(rootPanel, "Toggle Feedbacker (require lvl reload)", "teto_arm", true); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); directoryName = directoryName.Replace("\\", "/"); directoryName.TrimEnd('/'); config.SetIconWithURL("file:///" + directoryName + "/config icon.png"); textmodeToggle = new BoolField(rootPanel, "Toggle Textmode Teto", "teto_textmode", true); BoolField obj = armToggle; object obj2 = <>c.<>9__16_0; if (obj2 == null) { BoolValueChangeEventDelegate val = delegate(BoolValueChangeEvent e) { TetoArmIsEnabled = e.value; }; <>c.<>9__16_0 = val; obj2 = (object)val; } obj.onValueChange += (BoolValueChangeEventDelegate)obj2; ConfigPanel val2 = new ConfigPanel(config.rootPanel, "", "panel_guid"); ConfigHeader val3 = new ConfigHeader(val2, Resources.allegation, 16, (TextAlignmentOptions)4097); val3.textColor = Color.red; } private void TextmodeSetup(bool toggled) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Textmode set applied: " + toggled)); } private void SceneManager_sceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) TetoArmIsEnabled = armToggle.value; Image[] array = Object.FindObjectsOfType(true); Image[] array2 = array; foreach (Image val in array2) { if (!((Object)(object)val.sprite != (Object)null) || !(((Object)val.sprite).name == "TextmodeV1")) { continue; } GameObject val2 = Object.Instantiate(spriteObject); Image component = val2.GetComponent(); ((Graphic)component).color = ((Graphic)val).color; Image[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); Image[] componentsInChildren2 = val2.GetComponentsInChildren(true); ToggleWatcher toggleWatcher = ((Component)val).gameObject.AddComponent(); toggleWatcher.tied = component; toggleWatcher.localImg = val; ((Behaviour)toggleWatcher).enabled = true; toggleWatcher.Init(textmodeToggle); Image[] array3 = componentsInChildren; foreach (Image val3 in array3) { Image[] array4 = componentsInChildren2; foreach (Image val4 in array4) { if (((Object)val4).name == ((Object)val3).name) { ToggleWatcher toggleWatcher2 = ((Component)val3).gameObject.AddComponent(); toggleWatcher2.tied = val4; toggleWatcher2.localImg = val3; ((Graphic)val4).color = ((Graphic)val3).color; ((Graphic)val4).raycastTarget = false; ((Behaviour)toggleWatcher2).enabled = true; toggleWatcher2.Init(textmodeToggle); } } } val2.transform.parent = ((Component)val).transform; val2.transform.localScale = Vector3.one * 9.6f; val2.transform.localPosition = new Vector3(0f, -5f, 0f); } textmodeToggle.TriggerValueChangeEvent(); } } public class ToggleWatcher : MonoBehaviour { public Image tied = null; public Image localImg = null; private Sprite tiedSprite; private Sprite localImgSprite; private Sprite nullSpr; private BoolField toggleEvtHandler; public void Init(BoolField toggleEvtHandler) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown this.toggleEvtHandler = toggleEvtHandler; toggleEvtHandler.onValueChange += new BoolValueChangeEventDelegate(_SwapToggle); nullSpr = createNullSprite(); tiedSprite = tied.sprite; localImgSprite = localImg.sprite; } private void _SwapToggle(BoolValueChangeEvent toggle) { SwapToggle(toggle.value); } private void SwapToggle(bool value) { if (!((Object)(object)tied == (Object)null)) { if (value && ((Component)localImg).gameObject.activeSelf) { localImg.sprite = nullSpr; tied.sprite = tiedSprite; } else { localImg.sprite = localImgSprite; tied.sprite = nullSpr; } } } private void OnEnable() { if (toggleEvtHandler != null) { SwapToggle(toggleEvtHandler.value); } } private void OnDisable() { tied.sprite = nullSpr; } private void OnDestroy() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown toggleEvtHandler.onValueChange -= new BoolValueChangeEventDelegate(_SwapToggle); } private void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) ((Graphic)tied).color = ((Graphic)localImg).color; } private static Sprite createNullSprite() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, new Color(0f, 0f, 0f, 0f)); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); } } } namespace UltraKasane.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("UltraKasane.Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static string allegation => ResourceManager.GetString("allegation", resourceCulture); internal static byte[] teto { get { object @object = ResourceManager.GetObject("teto", resourceCulture); return (byte[])@object; } } internal Resources() { } } }