using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TootTally.Utils;
using TootTally.Utils.TootTallySettings;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TootTally.CustomCosmetics")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Custom Cosmetic Plugin TootTallyModule")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyProduct("TootTally.CustomCosmetics")]
[assembly: AssemblyTitle("TootTally.CustomCosmetics")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.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 TootTally.CustomCosmetics
{
public static class CustomCursor
{
public static class CustomCursorPatch
{
[HarmonyPatch(typeof(HomeController), "tryToSaveSettings")]
[HarmonyPostfix]
public static void OnSettingsChange()
{
ResolvePresets(null);
}
[HarmonyPatch(typeof(HomeController), "Start")]
[HarmonyPostfix]
public static void OnHomeStartLoadTexture()
{
ResolvePresets(null);
}
[HarmonyPatch(typeof(GameController), "Start")]
[HarmonyPostfix]
public static void PatchCustorTexture(GameController __instance)
{
ResolvePresets(__instance);
}
}
private const string NOTETARGET_PATH = "GameplayCanvas/GameSpace/TargetNote";
private const string NOTEDOT_PATH = "GameplayCanvas/GameSpace/TargetNote/note-dot";
private const string NOTEDOTGLOW_PATH = "GameplayCanvas/GameSpace/TargetNote/note-dot-glow";
private const string NOTEDOTGLOW1_PATH = "GameplayCanvas/GameSpace/TargetNote/note-dot-glow/note-dot-glow (1)";
private static Texture2D _noteTargetTexture;
private static Texture2D _noteDotTexture;
private static Texture2D _noteDotGlowTexture;
private static Texture2D _noteDotGlow1Texture;
private static string _lastCursorName;
public static void LoadCursorTexture(GameController __instance, string CursorName)
{
if (AreAllTexturesLoaded() && !ConfigCursorNameChanged())
{
return;
}
string text = Path.Combine(Paths.BepInExRootPath, Plugin.CURSORS_FOLDER_PATH, CursorName);
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/TargetNote.png", delegate(Texture2D texture)
{
_noteTargetTexture = texture;
Plugin.Instance.LogInfo("Target Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/note-dot.png", delegate(Texture2D texture)
{
_noteDotTexture = texture;
Plugin.Instance.LogInfo("Dot Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/note-dot-glow.png", delegate(Texture2D texture)
{
_noteDotGlowTexture = texture;
Plugin.Instance.LogInfo("Dot Glow Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/note-dot-glow (1).png", delegate(Texture2D texture)
{
_noteDotGlow1Texture = texture;
Plugin.Instance.LogInfo("Dot Glow1 Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
}
public static void UnloadTextures()
{
Object.DestroyImmediate((Object)(object)_noteTargetTexture);
Object.DestroyImmediate((Object)(object)_noteDotTexture);
Object.DestroyImmediate((Object)(object)_noteDotGlowTexture);
Object.DestroyImmediate((Object)(object)_noteDotGlow1Texture);
Plugin.Instance.LogInfo("Custom Cursor Textures Destroyed.");
}
public static void OnAllTextureLoadedAfterConfigChange(GameController __instance)
{
ApplyCustomTextureToCursor(__instance);
_lastCursorName = Plugin.Instance.option.CursorName.Value;
}
public static bool AreAllTexturesLoaded()
{
return (Object)(object)_noteTargetTexture != (Object)null && (Object)(object)_noteDotTexture != (Object)null && (Object)(object)_noteDotGlowTexture != (Object)null && (Object)(object)_noteDotGlow1Texture != (Object)null;
}
public static bool ConfigCursorNameChanged()
{
return Plugin.Instance.option.CursorName.Value != _lastCursorName;
}
public static IEnumerator<UnityWebRequestAsyncOperation> LoadCursorTexture(string filePath, Action<Texture2D> callback)
{
UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(filePath);
yield return webRequest.SendWebRequest();
if (!webRequest.isNetworkError && !webRequest.isHttpError)
{
callback(DownloadHandlerTexture.GetContent(webRequest));
}
else
{
Plugin.Instance.LogInfo("Cursor does not exist or have the wrong format.");
}
}
public static void ApplyCustomTextureToCursor(GameController __instance)
{
//IL_008f: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_021d: Unknown result type (might be due to invalid IL or missing references)
if (AreAllTexturesLoaded())
{
Plugin.Instance.LogInfo("Applying Custom Textures to cursor.");
GameObject gameObject = GameObject.Find("GameplayCanvas/GameSpace/TargetNote").gameObject;
GameObject gameObject2 = GameObject.Find("GameplayCanvas/GameSpace/TargetNote/note-dot").gameObject;
GameObject gameObject3 = GameObject.Find("GameplayCanvas/GameSpace/TargetNote/note-dot-glow").gameObject;
GameObject gameObject4 = GameObject.Find("GameplayCanvas/GameSpace/TargetNote/note-dot-glow/note-dot-glow (1)").gameObject;
gameObject.GetComponent<Image>().sprite = Sprite.Create(_noteTargetTexture, new Rect(0f, 0f, (float)((Texture)_noteTargetTexture).width, (float)((Texture)_noteTargetTexture).height), Vector2.one);
gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteTargetTexture).width, (float)((Texture)_noteTargetTexture).height) / 2f;
gameObject2.GetComponent<Image>().sprite = Sprite.Create(_noteDotTexture, new Rect(0f, 0f, (float)((Texture)_noteDotTexture).width, (float)((Texture)_noteDotTexture).height), Vector2.zero);
gameObject2.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteDotTexture).width, (float)((Texture)_noteDotTexture).height) / 2f;
gameObject3.GetComponent<Image>().sprite = Sprite.Create(_noteDotGlowTexture, new Rect(0f, 0f, (float)((Texture)_noteDotGlowTexture).width, (float)((Texture)_noteDotGlowTexture).height), Vector2.zero);
gameObject3.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteDotGlowTexture).width, (float)((Texture)_noteDotGlowTexture).height) / 2f;
gameObject4.GetComponent<Image>().sprite = Sprite.Create(_noteDotGlow1Texture, new Rect(0f, 0f, (float)((Texture)_noteDotGlow1Texture).width, (float)((Texture)_noteDotGlow1Texture).height), Vector2.zero);
gameObject4.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteDotGlow1Texture).width, (float)((Texture)_noteDotGlow1Texture).height) / 2f;
__instance.dotsize = ((Texture)_noteTargetTexture).width / 2;
}
}
public static void ResolvePresets(GameController __instance)
{
if ((!AreAllTexturesLoaded() || (Object)(object)__instance == (Object)null) && Plugin.Instance.option.CursorName.Value != "Default")
{
Plugin.Instance.LogInfo("[" + Plugin.Instance.option.CursorName.Value + "] preset loading...");
LoadCursorTexture(__instance, Plugin.Instance.option.CursorName.Value);
}
else if (Plugin.Instance.option.CursorName.Value != "Default")
{
ApplyCustomTextureToCursor(__instance);
}
else
{
Plugin.Instance.LogInfo("[Default] preset selected. Not loading any Custom Cursor.");
}
}
}
public static class CustomNote
{
public static class CustomNotePatch
{
[HarmonyPatch(typeof(HomeController), "tryToSaveSettings")]
[HarmonyPostfix]
public static void OnSettingsChange()
{
ResolvePresets(null);
}
[HarmonyPatch(typeof(HomeController), "Start")]
[HarmonyPostfix]
public static void OnHomeStartLoadTexture()
{
ResolvePresets(null);
}
[HarmonyPatch(typeof(GameController), "buildNotes")]
[HarmonyPrefix]
public static void PatchCustorTexture(GameController __instance)
{
ResolvePresets(__instance);
ApplyNoteResize(__instance);
if (Plugin.Instance.option.OverwriteNoteColor.Value)
{
ApplyColor(__instance);
}
}
[HarmonyPatch(typeof(NoteDesigner), "setColorScheme")]
[HarmonyPrefix]
public static void PatchCursorColorRandom(ref float col_r, ref float col_g, ref float col_b, ref float col_r2, ref float col_g2, ref float col_b2)
{
if (Plugin.Instance.option.RandomNoteColor.Value)
{
ApplyRandomColor(ref col_r, ref col_g, ref col_b, ref col_r2, ref col_g2, ref col_b2);
}
}
[HarmonyPatch(typeof(GameController), "buildNotes")]
[HarmonyPostfix]
public static void FixEndNotePosition(GameController __instance)
{
FixNoteEndPosition(__instance);
}
}
private static Sprite _noteOriginalInTexture;
private static Sprite _noteOriginalOutTexture;
private static Sprite _noteStartOutTexture;
private static Sprite _noteEndOutTexture;
private static Sprite _noteStartInTexture;
private static Sprite _noteEndInTexture;
private static string _lastNoteName;
private static readonly Random _rdm = new Random();
public static void LoadNoteTexture(GameController __instance, string NoteName)
{
if (AreAllTexturesLoaded() && !ConfigNotesNameChanged())
{
return;
}
string text = Path.Combine(Paths.BepInExRootPath, Plugin.NOTES_FOLDER_PATH, NoteName);
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadNoteTexture(text + "/NoteStartOutline.png", delegate(Texture2D texture)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
_noteStartOutTexture = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one / 2f);
Plugin.Instance.LogInfo("NoteStartOutline Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadNoteTexture(text + "/NoteEndOutline.png", delegate(Texture2D texture)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
_noteEndOutTexture = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one / 2f);
Plugin.Instance.LogInfo("NoteEndOutline Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadNoteTexture(text + "/NoteStartInline.png", delegate(Texture2D texture)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
_noteStartInTexture = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one / 2f);
Plugin.Instance.LogInfo("NoteStartInline Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadNoteTexture(text + "/NoteEndInline.png", delegate(Texture2D texture)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
_noteEndInTexture = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one / 2f);
Plugin.Instance.LogInfo("NoteEndInline Texture Loaded.");
if (AreAllTexturesLoaded() && (Object)(object)__instance != (Object)null)
{
OnAllTextureLoadedAfterConfigChange(__instance);
}
}));
}
public static void UnloadTextures()
{
Object.DestroyImmediate((Object)(object)_noteStartOutTexture);
Object.DestroyImmediate((Object)(object)_noteEndOutTexture);
Object.DestroyImmediate((Object)(object)_noteStartInTexture);
Object.DestroyImmediate((Object)(object)_noteEndInTexture);
Plugin.Instance.LogInfo("Custom Notes Textures Destroyed.");
}
public static void OnAllTextureLoadedAfterConfigChange(GameController __instance)
{
ApplyCustomTextureToNotes(__instance);
_lastNoteName = Plugin.Instance.option.NoteName.Value;
}
public static bool AreAllTexturesLoaded()
{
return (Object)(object)_noteStartOutTexture != (Object)null && (Object)(object)_noteEndOutTexture != (Object)null && (Object)(object)_noteStartInTexture != (Object)null && (Object)(object)_noteEndInTexture != (Object)null;
}
public static bool ConfigNotesNameChanged()
{
return Plugin.Instance.option.NoteName.Value != _lastNoteName;
}
public static IEnumerator<UnityWebRequestAsyncOperation> LoadNoteTexture(string filePath, Action<Texture2D> callback)
{
UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(filePath);
yield return webRequest.SendWebRequest();
if (!webRequest.isNetworkError && !webRequest.isHttpError)
{
callback(DownloadHandlerTexture.GetContent(webRequest));
}
else
{
Plugin.Instance.LogInfo("Custom Note does not exist or have the wrong format.");
}
}
public static void ResolvePresets(GameController __instance)
{
if ((!AreAllTexturesLoaded() || (Object)(object)__instance == (Object)null) && Plugin.Instance.option.NoteName.Value != "Default")
{
Plugin.Instance.LogInfo("[" + Plugin.Instance.option.NoteName.Value + "] preset loading...");
LoadNoteTexture(__instance, Plugin.Instance.option.NoteName.Value);
}
else if (Plugin.Instance.option.NoteName.Value != "Default")
{
ApplyCustomTextureToNotes(__instance);
}
else if ((Object)(object)__instance != (Object)null)
{
SetToOriginalTexture(__instance);
Plugin.Instance.LogInfo("[Default] preset selected. Not loading any Custom Notes.");
}
}
public static void ApplyCustomTextureToNotes(GameController __instance)
{
if (AreAllTexturesLoaded())
{
Plugin.Instance.LogInfo("Applying Custom Textures to notes.");
NoteDesigner component = __instance.singlenote.GetComponent<NoteDesigner>();
if ((Object)(object)_noteOriginalInTexture == (Object)null || (Object)(object)_noteOriginalOutTexture == (Object)null)
{
_noteOriginalInTexture = component.startdot.sprite;
_noteOriginalOutTexture = ((Component)__instance.singlenote.transform.Find("StartPoint")).GetComponent<Image>().sprite;
}
((Component)__instance.singlenote.transform.Find("StartPoint")).GetComponent<Image>().sprite = _noteStartOutTexture;
((Component)__instance.singlenote.transform.Find("EndPoint")).GetComponent<Image>().sprite = _noteEndOutTexture;
component.startdot.sprite = _noteStartInTexture;
component.enddot.sprite = _noteEndInTexture;
}
}
public static void SetToOriginalTexture(GameController __instance)
{
if (!((Object)(object)_noteOriginalInTexture == (Object)null) && !((Object)(object)_noteOriginalOutTexture == (Object)null))
{
NoteDesigner component = __instance.singlenote.GetComponent<NoteDesigner>();
((Component)__instance.singlenote.transform.Find("StartPoint")).GetComponent<Image>().sprite = _noteOriginalOutTexture;
Image component2 = ((Component)__instance.singlenote.transform.Find("EndPoint")).GetComponent<Image>();
Image startdot = component.startdot;
Sprite val = (component.enddot.sprite = _noteOriginalInTexture);
Sprite sprite = (startdot.sprite = val);
component2.sprite = sprite;
}
}
public static void ApplyColor(GameController __instance)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//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_0034: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_006d: Unknown result type (might be due to invalid IL or missing references)
Color value = Plugin.Instance.option.NoteColorStart.Value;
Color value2 = Plugin.Instance.option.NoteColorEnd.Value;
__instance.note_c_start = new float[3] { value.r, value.g, value.b };
__instance.note_c_end = new float[3] { value2.r, value2.g, value2.b };
}
public static void ApplyRandomColor(ref float col_r, ref float col_g, ref float col_b, ref float col_r2, ref float col_g2, ref float col_b2)
{
col_r = (float)_rdm.NextDouble();
col_g = (float)_rdm.NextDouble();
col_b = (float)_rdm.NextDouble();
col_r2 = (float)_rdm.NextDouble();
col_g2 = (float)_rdm.NextDouble();
col_b2 = (float)_rdm.NextDouble();
}
public static void ApplyNoteResize(GameController __instance)
{
//IL_004c: 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_005b: 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_0080: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: 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_0146: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = ((Component)__instance.singlenote.transform.Find("StartPoint")).GetComponent<RectTransform>();
RectTransform component2 = ((Component)__instance.singlenote.transform.Find("EndPoint")).GetComponent<RectTransform>();
component.sizeDelta = Plugin.Instance.option.NoteHeadSize.Value * Vector2.one * 40f;
component2.sizeDelta = Plugin.Instance.option.NoteHeadSize.Value * Vector2.one * 17f;
Vector2 pivot = (component2.pivot = Vector2.one / 2f);
component.pivot = pivot;
component.anchoredPosition = Vector2.zero;
((Component)__instance.singlenote.transform.Find("StartPoint/StartPointColor")).GetComponent<RectTransform>().sizeDelta = Plugin.Instance.option.NoteHeadSize.Value * Vector2.one * 16f;
((Component)__instance.singlenote.transform.Find("EndPoint/EndPointColor")).GetComponent<RectTransform>().sizeDelta = Plugin.Instance.option.NoteHeadSize.Value * Vector2.one * 10f;
((Component)__instance.singlenote.transform.Find("Line")).GetComponent<LineRenderer>().widthMultiplier = Plugin.Instance.option.NoteBodySize.Value * 7f;
((Component)__instance.singlenote.transform.Find("OutlineLine")).GetComponent<LineRenderer>().widthMultiplier = Plugin.Instance.option.NoteBodySize.Value * 12f;
}
public static void FixNoteEndPosition(GameController __instance)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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)
foreach (GameObject allnote in __instance.allnotes)
{
RectTransform component = ((Component)((Component)allnote.transform).transform.Find("EndPoint")).GetComponent<RectTransform>();
Vector2 anchorMin = (component.anchorMax = new Vector2(1f, 0.5f));
component.anchorMin = anchorMin;
component.pivot = new Vector2(0.34f, 0.5f);
}
}
}
public static class CustomTromboner
{
public static class CustomBonerPatch
{
public static GameObject _customPuppet;
public static GameObject _customPuppetPrefab;
[HarmonyPatch(typeof(HomeController), "tryToSaveSettings")]
[HarmonyPostfix]
public static void OnSettingsChange()
{
ResolveCurrentBundle();
}
[HarmonyPatch(typeof(HomeController), "Start")]
[HarmonyPostfix]
public static void OnHomeControllerStart()
{
string path = Path.Combine(Paths.BepInExRootPath, "CustomTromboners");
if (_bonerDict == null || Directory.GetFiles(path).Any((string x) => !_bonerDict.ContainsKey(x.Replace(".boner", ""))))
{
LoadAssetBundles();
}
ResolveCurrentBundle();
}
[HarmonyPatch(typeof(GameController), "Start")]
[HarmonyPrefix]
public static void SetPuppetIDOnStartPrefix(GameController __instance)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_currentBundle == (Object)null))
{
_customPuppetPrefab = _currentBundle.LoadAsset<GameObject>("puppet.prefab");
if ((Object)(object)_customPuppetPrefab != (Object)null)
{
_customPuppet = Object.Instantiate<GameObject>(_customPuppetPrefab, __instance.modelparent.transform);
_customPuppet.transform.localPosition = new Vector3(0.7f, -0.4f, 1.3f);
}
}
}
[HarmonyPatch(typeof(GameController), "Start")]
[HarmonyPostfix]
public static void OverwriteHumanPuppetBody(GameController __instance)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_customPuppetPrefab != (Object)null)
{
__instance.puppet_human.transform.localScale = Vector3.zero;
}
else if (!((Object)(object)_currentBundle == (Object)null))
{
Plugin.Instance.LogInfo("Applying Custom Boner...");
HumanPuppetController puppet_humanc = __instance.puppet_humanc;
puppet_humanc.head_oob = GetMaterial("head_oob.mat");
puppet_humanc.head_def = GetMaterial("head_def.mat");
puppet_humanc.head_def_es = GetMaterial("head_def_es.mat");
puppet_humanc.head_act = GetMaterial("head_act.mat");
puppet_humanc.costume_alt = GetMaterial("custom_alt.mat");
Material[] materials = ((Renderer)puppet_humanc.bodymesh).materials;
materials[0] = GetMaterial("body.mat");
((Renderer)puppet_humanc.bodymesh).materials = materials;
}
}
}
internal static class FileHelper
{
public const string BONER_FILE_EXT = ".boner";
public static FileInfo[] GetFilesFromDirectory(string directory)
{
return GetOrCreateDirectory(directory).GetFiles();
}
public static DirectoryInfo GetOrCreateDirectory(string directory)
{
if (!Directory.Exists(directory))
{
return Directory.CreateDirectory(directory);
}
return new DirectoryInfo(directory);
}
public static List<FileInfo> GetAllBonerFilesFromDirectory(string diretory)
{
return (from x in GetFilesFromDirectory(diretory)
where x.FullName.Contains(".boner")
select x).ToList();
}
}
[Serializable]
private class BonerInfo : MonoBehaviour
{
public string Name { get; set; }
public string Description { get; set; }
public string Author { get; set; }
public string PuppetName { get; set; }
}
public const string CUSTOM_TROMBONER_FOLDER = "CustomTromboners";
private static Dictionary<string, AssetBundle> _bonerDict;
private static AssetBundle _currentBundle;
private static TootTallySettingLabel _label;
private static TootTallySettingDropdown _dropdown;
public static string[] GetBonerNames => _bonerDict.Keys.ToArray();
public static void LoadAssetBundles()
{
Plugin.Instance.LogInfo("New Custom Tromboner detected, reloading CustomTromboners...");
if (_bonerDict != null)
{
foreach (string key in _bonerDict.Keys)
{
_bonerDict[key].Unload(true);
}
}
_bonerDict = new Dictionary<string, AssetBundle>();
string diretory = Path.Combine(Paths.BepInExRootPath, "CustomTromboners");
List<FileInfo> allBonerFilesFromDirectory = FileHelper.GetAllBonerFilesFromDirectory(diretory);
allBonerFilesFromDirectory.ForEach(AddToAssetBundle);
Plugin.Instance.LogInfo("Custom Tromboners Loaded.");
}
public static void AddToAssetBundle(FileInfo file)
{
Plugin.Instance.LogInfo("Would add " + file.Name + " using " + file.FullName);
try
{
_bonerDict.Add(file.Name.Replace(".boner", ""), AssetBundle.LoadFromFile(file.FullName));
}
catch (Exception ex)
{
Plugin.Instance.LogError(ex.Message);
Plugin.Instance.LogError(ex.StackTrace);
}
}
public static void ResolveCurrentBundle()
{
string value = Plugin.Instance.option.BonerName.Value;
if (value != "None" && _bonerDict.ContainsKey(value))
{
_currentBundle = _bonerDict[value];
_currentBundle.GetAllAssetNames().ToList().ForEach(Plugin.Instance.LogInfo);
Plugin.Instance.LogInfo("Boner bundle " + ((Object)_currentBundle).name + " loaded.");
}
else if ((Object)(object)_currentBundle != (Object)null && value == "None")
{
Plugin.Instance.LogInfo("No bundle loaded.");
_currentBundle = null;
}
}
public static Material GetMaterial(string name)
{
return _currentBundle.LoadAsset<Material>(name);
}
public static Texture GetTexture(string name)
{
return _currentBundle.LoadAsset<Texture>(name);
}
public static int GetPuppetIDFromName(string PuppetName)
{
string text = PuppetName.ToLower().Replace(" ", "");
if (1 == 0)
{
}
int result;
switch (text)
{
case "beezerly":
case "kazyleii":
result = 0;
break;
case "appaloosa":
case "trixiebell":
result = 2;
break;
case "hornlord":
case "soda":
result = 4;
break;
case "jermajesty":
case "meldor":
result = 6;
break;
default:
result = -1;
break;
}
if (1 == 0)
{
}
return result;
}
}
[BepInPlugin("TootTally.CustomCosmetics", "TootTally.CustomCosmetics", "2.0.1")]
public class Plugin : BaseUnityPlugin, ITootTallyModule
{
public class Options
{
public ConfigEntry<string> CursorName { get; set; }
public ConfigEntry<TrailType> TrailType { get; set; }
public ConfigEntry<string> NoteName { get; set; }
public ConfigEntry<string> BonerName { get; set; }
public ConfigEntry<float> NoteHeadSize { get; set; }
public ConfigEntry<float> NoteBodySize { get; set; }
public ConfigEntry<bool> RandomNoteColor { get; set; }
public ConfigEntry<bool> OverwriteNoteColor { get; set; }
public ConfigEntry<Color> NoteColorStart { get; set; }
public ConfigEntry<Color> NoteColorEnd { get; set; }
}
public enum TrailType
{
None,
Short,
Long
}
public static Plugin Instance;
private const string CONFIG_NAME = "CustomCosmetics.cfg";
private const string CURSOR_CONFIG_FIELD = "CustomCursor";
private const string NOTE_CONFIG_FIELD = "CustomCursor";
private const string BONER_CONFIG_FIELD = "CustomBoner";
public const string DEFAULT_CURSORNAME = "Default";
public const string DEFAULT_NOTENAME = "Default";
public const string DEFAULT_BONER = "None";
private const string SETTINGS_PAGE_NAME = "CustomCosmetics";
private const TrailType DEFAULT_TRAIL = TrailType.None;
public static string CURSORS_FOLDER_PATH = "CustomCursors";
public static string NOTES_FOLDER_PATH = "CustomNotes";
public Options option;
public static TootTallySettingPage SettingPage;
public ConfigEntry<bool> ModuleConfigEnabled { get; set; }
public ConfigEntry<string> CursorName { get; set; }
public bool IsConfigInitialized { get; set; }
public string Name
{
get
{
return "TootTally.CustomCosmetics";
}
set
{
Name = value;
}
}
public ManualLogSource GetLogger => ((BaseUnityPlugin)this).Logger;
public void LogInfo(string msg)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)msg);
}
public void LogError(string msg)
{
((BaseUnityPlugin)this).Logger.LogError((object)msg);
}
private void Awake()
{
if (!((Object)(object)Instance != (Object)null))
{
Instance = this;
ModuleConfigEnabled = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Modules", "Custom Cursor", true, "Enable Custom Cursor Module");
Plugin.AddModule((ITootTallyModule)(object)this);
}
}
public void LoadModule()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(Paths.BepInExRootPath, "config/");
ConfigFile val = new ConfigFile(text + "CustomCosmetics.cfg", true)
{
SaveOnConfigSet = true
};
option = new Options
{
CursorName = val.Bind<string>("CustomCursor", "CursorName", "Default", (ConfigDescription)null),
TrailType = val.Bind<TrailType>("CustomCursor", "TrailType", TrailType.None, (ConfigDescription)null),
NoteName = val.Bind<string>("CustomCursor", "NoteName", "Default", (ConfigDescription)null),
NoteHeadSize = val.Bind<float>("CustomCursor", "NoteHeadSize", 1f, (ConfigDescription)null),
NoteBodySize = val.Bind<float>("CustomCursor", "NoteBodySize", 1f, (ConfigDescription)null),
RandomNoteColor = val.Bind<bool>("CustomCursor", "RandomNoteColor", false, (ConfigDescription)null),
OverwriteNoteColor = val.Bind<bool>("CustomCursor", "OverwriteNoteColor", false, (ConfigDescription)null),
NoteColorStart = val.Bind<Color>("CustomCursor", "NoteColorStart", Color.white, (ConfigDescription)null),
NoteColorEnd = val.Bind<Color>("CustomCursor", "NoteColorEnd", Color.black, (ConfigDescription)null),
BonerName = val.Bind<string>("CustomBoner", "BonerName", "None", (ConfigDescription)null)
};
SettingPage = TootTallySettingsManager.AddNewPage("CustomCosmetics", "Custom Cosmetics", 40f, new Color(0.1f, 0.1f, 0.1f, 0.1f));
TryMigrateFolder("CustomCursors");
TryMigrateFolder("CustomNotes");
TryMigrateFolder("CustomTromboners");
CreateDropdownFromFolder(CURSORS_FOLDER_PATH, option.CursorName, "Default");
CreateDropdownFromFolder(NOTES_FOLDER_PATH, option.NoteName, "Default");
TootTallySettingSlider headSlider = SettingPage.AddSlider("NoteHeadSizeSlider", 0f, 5f, 250f, "Note Head Size", option.NoteHeadSize, false);
TootTallySettingSlider bodySlider = SettingPage.AddSlider("NoteBodySizeSlider", 0f, 5f, 250f, "Note Body Size", option.NoteBodySize, false);
SettingPage.AddButton("ResetSliders", new Vector2(160f, 80f), "Reset", (Action)delegate
{
headSlider.slider.value = 1f;
bodySlider.slider.value = 1f;
});
SettingPage.AddToggle("RandomNoteColor", option.RandomNoteColor, (UnityAction<bool>)null);
SettingPage.AddToggle("OverwriteNoteColor", option.OverwriteNoteColor, (UnityAction<bool>)OnToggleValueChange);
if (option.OverwriteNoteColor.Value)
{
OnToggleValueChange(value: true);
}
SettingPage.AddLabel("BonerLabel", "Custom Tromboners", 24f, (FontStyles)0, (TextAlignmentOptions)1025);
CustomTromboner.LoadAssetBundles();
List<string> list = new List<string> { "None" };
list.AddRange(CustomTromboner.GetBonerNames);
SettingPage.AddDropdown("BonerDropdown", option.BonerName, list.ToArray());
Harmony.CreateAndPatchAll(typeof(CustomCursor.CustomCursorPatch), "TootTally.CustomCosmetics");
Harmony.CreateAndPatchAll(typeof(CustomNote.CustomNotePatch), "TootTally.CustomCosmetics");
Harmony.CreateAndPatchAll(typeof(CustomTromboner.CustomBonerPatch), "TootTally.CustomCosmetics");
LogInfo("Module loaded!");
}
public void OnToggleValueChange(bool value)
{
if (value)
{
SettingPage.AddLabel("Note Start Color", (FontStyles)0, (TextAlignmentOptions)4097);
SettingPage.AddColorSliders("NoteStart", "Note Start Color", option.NoteColorStart);
SettingPage.AddLabel("Note End Color", (FontStyles)0, (TextAlignmentOptions)4097);
SettingPage.AddColorSliders("NoteEnd", "Note End Color", option.NoteColorEnd);
}
else
{
SettingPage.RemoveSettingObjectFromList("Note Start Color");
SettingPage.RemoveSettingObjectFromList("NoteStart");
SettingPage.RemoveSettingObjectFromList("Note End Color");
SettingPage.RemoveSettingObjectFromList("NoteEnd");
}
}
public void TryMigrateFolder(string folderName)
{
string text = Path.Combine(Paths.BepInExRootPath, folderName);
if (!Directory.Exists(text))
{
string text2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), folderName);
LogInfo(folderName + " folder not found. Attempting to move folder from " + text2 + " to " + text);
if (Directory.Exists(text2))
{
Directory.Move(text2, text);
return;
}
LogError("Source " + folderName + " Folder Not Found. Cannot Create " + folderName + " Folder. Download the module again to fix the issue.");
}
}
public void CreateDropdownFromFolder(string folderName, ConfigEntry<string> config, string defaultValue)
{
List<string> folderNames = new List<string> { defaultValue };
string path = Path.Combine(Paths.BepInExRootPath, folderName);
if (Directory.Exists(path))
{
List<string> list = Directory.GetDirectories(path).ToList();
list.ForEach(delegate(string d)
{
if (!d.Contains("TEMPALTE"))
{
folderNames.Add(Path.GetFileNameWithoutExtension(d));
}
});
}
SettingPage.AddLabel(folderName, folderName, 24f, (FontStyles)0, (TextAlignmentOptions)1025);
SettingPage.AddDropdown(folderName + "Dropdown", config, folderNames.ToArray());
}
public void UnloadModule()
{
CustomCursor.UnloadTextures();
CustomNote.UnloadTextures();
Harmony.UnpatchID("TootTally.CustomCosmetics");
SettingPage.Remove();
LogInfo("Module unloaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TootTally.CustomCosmetics";
public const string PLUGIN_NAME = "TootTally.CustomCosmetics";
public const string PLUGIN_VERSION = "2.0.1";
}
}