Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TinyREPO v1.2.0
TinyRepo.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TinyRepo")] [assembly: AssemblyTitle("TinyRepo")] [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.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; } } [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 REPO.TinyPlayers { public static class Entry { [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] private static void Bootstrap() { TinyPlayersMod.Init(); } } [HarmonyPatch] public static class TinyPlayersMod { private static Harmony _harmony; private static bool _patched; public static void Init() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!_patched) { _patched = true; _harmony = new Harmony("repo.tinyplayers.toggle"); _harmony.PatchAll(typeof(TinyPlayersMod).Assembly); Debug.Log((object)"[TinyPlayers] Harmony patches applied."); } } [HarmonyPostfix] [HarmonyPatch(typeof(RenderTextureMain), "Awake")] private static void RenderTextureMain_Awake_Postfix(RenderTextureMain __instance) { TinyController tinyController = default(TinyController); if (Object.op_Implicit((Object)(object)__instance) && !((Component)__instance).gameObject.TryGetComponent<TinyController>(ref tinyController)) { ((Component)__instance).gameObject.AddComponent<TinyController>(); } } } public sealed class TinyController : MonoBehaviour { [CompilerGenerated] private sealed class <AvatarKeepTinyLoop>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TinyController <>4__this; private WaitForSecondsRealtime <wait>5__1; private PlayerAvatar[] <avatars>5__2; private int <i>5__3; private PlayerAvatar <p>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AvatarKeepTinyLoop>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <wait>5__1 = null; <avatars>5__2 = null; <p>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <wait>5__1 = new WaitForSecondsRealtime(0.75f); break; case 1: <>1__state = -1; <avatars>5__2 = null; break; } if (<>4__this.ModEnabled) { <avatars>5__2 = Object.FindObjectsByType<PlayerAvatar>((FindObjectsSortMode)0); <i>5__3 = 0; while (<i>5__3 < <avatars>5__2.Length) { <p>5__4 = <avatars>5__2[<i>5__3]; if (Object.op_Implicit((Object)(object)<p>5__4) && ((Component)<p>5__4).gameObject.activeInHierarchy) { TinyAvatarUtil.AttachUniformScaler(<p>5__4, <>4__this.Factor); <p>5__4 = null; } <i>5__3++; } <>2__current = <wait>5__1; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public bool ModEnabled = false; [Range(0.05f, 1f)] public float Factor = 0.3f; private Coroutine _avatarLoop; private void Update() { if (!Input.GetKeyDown((KeyCode)289)) { return; } ModEnabled = !ModEnabled; if (ModEnabled) { ((MonoBehaviour)this).StopAllCoroutines(); _avatarLoop = ((MonoBehaviour)this).StartCoroutine(AvatarKeepTinyLoop()); Debug.Log((object)"[TinyPlayers] ENABLED"); return; } if (_avatarLoop != null) { ((MonoBehaviour)this).StopCoroutine(_avatarLoop); _avatarLoop = null; } TinyAvatarUtil.DetachAll(); Debug.Log((object)"[TinyPlayers] DISABLED"); } [IteratorStateMachine(typeof(<AvatarKeepTinyLoop>d__4))] private IEnumerator AvatarKeepTinyLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AvatarKeepTinyLoop>d__4(0) { <>4__this = this }; } private void OnDisable() { if (_avatarLoop != null) { ((MonoBehaviour)this).StopCoroutine(_avatarLoop); _avatarLoop = null; } TinyAvatarUtil.DetachAll(); } private void OnGUI() { //IL_0020: 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_002e: 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_0040: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) string text = (ModEnabled ? "Tiny Mode: ON (F8 to toggle)" : "Tiny Mode: OFF (F8 to toggle)"); GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 12 }; val.normal.textColor = Color.black; GUIStyle val2 = val; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(10f, 10f, 400f, 30f); GUI.Label(new Rect(((Rect)(ref val3)).x + 1f, ((Rect)(ref val3)).y + 1f, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), text, val2); val2.normal.textColor = Color.green; GUI.Label(val3, text, val2); } } public sealed class AvatarUniformScaler : MonoBehaviour { public Transform Target; public float Factor = 0.3f; private Vector3 _origScale; private bool _hasOrig; public void Configure(Transform target, float factor) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Target = target; Factor = Mathf.Clamp(factor, 0.05f, 1f); if (Object.op_Implicit((Object)(object)Target) && !_hasOrig) { _origScale = Target.localScale; _hasOrig = true; } ((Behaviour)this).enabled = true; } private void LateUpdate() { //IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) if (!Object.op_Implicit((Object)(object)Target)) { ((Behaviour)this).enabled = false; return; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Factor, Factor, Factor); Vector3 val2 = Target.localScale - val; if (((Vector3)(ref val2)).sqrMagnitude > 1E-07f) { Target.localScale = val; } } private void OnDisable() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Target) && _hasOrig) { Target.localScale = _origScale; } } private void OnDestroy() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Target) && _hasOrig) { Target.localScale = _origScale; } } } internal static class TinyAvatarUtil { private static readonly string[] VISUALS_NAMES = new string[5] { "Player Visuals", "PlayerVisuals", "Player Visual", "Player_Visuals", "Visuals" }; private static readonly string[] RIG_NAMES = new string[6] { "[RIG]", "RIG", "Rig", "Armature", "Root", "RootTransform" }; private static readonly Dictionary<PlayerAvatar, Transform> _cachedTarget = new Dictionary<PlayerAvatar, Transform>(); public static void AttachUniformScaler(PlayerAvatar avatar, float factor) { //IL_0124: 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) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) if (Object.op_Implicit((Object)(object)avatar)) { if (!_cachedTarget.TryGetValue(avatar, out Transform value) || !Object.op_Implicit((Object)(object)value)) { (Transform visuals, Transform rig, Transform usedRoot) tuple = ResolveAvatarRigLoose(((Component)avatar).transform); Transform item = tuple.visuals; Transform item2 = tuple.rig; Transform item3 = tuple.usedRoot; value = item2 ?? item ?? ((Component)avatar).transform; _cachedTarget[avatar] = value; Debug.Log((object)("[TinyPlayers] target -> root: " + ((item3 != null) ? ((Object)item3).name : null) + ", visuals: " + (Object.op_Implicit((Object)(object)item) ? ((Object)item).name : "<null>") + ", rig: " + (Object.op_Implicit((Object)(object)item2) ? ((Object)item2).name : "<null>") + ", use: " + ((Object)value).name)); } AvatarUniformScaler avatarUniformScaler = ((Component)avatar).GetComponent<AvatarUniformScaler>() ?? ((Component)avatar).gameObject.AddComponent<AvatarUniformScaler>(); avatarUniformScaler.Configure(value, factor); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(factor, factor, factor); Vector3 val2 = value.localScale - val; if (((Vector3)(ref val2)).sqrMagnitude > 1E-07f) { value.localScale = val; } } } public static void DetachAll() { AvatarUniformScaler[] array = Object.FindObjectsByType<AvatarUniformScaler>((FindObjectsSortMode)0); foreach (AvatarUniformScaler avatarUniformScaler in array) { if (Object.op_Implicit((Object)(object)avatarUniformScaler)) { ((Behaviour)avatarUniformScaler).enabled = false; Object.Destroy((Object)(object)avatarUniformScaler); } } _cachedTarget.Clear(); } private static (Transform visuals, Transform rig, Transform usedRoot) ResolveAvatarRigLoose(Transform avatarNode) { if (!Object.op_Implicit((Object)(object)avatarNode)) { return (null, null, null); } Transform val = FindNearestAncestorWhoseSubtreeHasLoose(avatarNode, VISUALS_NAMES) ?? avatarNode; Transform val2 = FindLooseBFS(val, VISUALS_NAMES); Transform val3 = (Object.op_Implicit((Object)(object)val2) ? FindLooseBFS(val2, RIG_NAMES) : null); if (!Object.op_Implicit((Object)(object)val3)) { val3 = FindLooseBFS(avatarNode, RIG_NAMES); } return (val2, val3, val); } private static string Normalize(string s) { if (string.IsNullOrEmpty(s)) { return ""; } IEnumerable<char> source = from ch in s.ToLowerInvariant() where ch != ' ' && ch != '_' && ch != '-' && ch != '[' && ch != ']' && ch != '(' && ch != ')' && ch != '{' && ch != '}' && ch != '.' select ch; return new string(source.ToArray()); } private static Transform FindLooseBFS(Transform root, params string[] names) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)root)) { return null; } string[] source = names.Select(Normalize).ToArray(); foreach (Transform item in root) { Transform val = item; string cn2 = Normalize(((Object)val).name); if (source.Any((string t) => t == cn2)) { return val; } } Queue<Transform> queue = new Queue<Transform>(); queue.Enqueue(root); while (queue.Count > 0) { Transform val2 = queue.Dequeue(); foreach (Transform item2 in val2) { Transform val3 = item2; string cn = Normalize(((Object)val3).name); if (source.Any((string t) => t == cn || cn.Contains(t))) { return val3; } queue.Enqueue(val3); } } return null; } private static Transform FindNearestAncestorWhoseSubtreeHasLoose(Transform start, params string[] names) { Transform val = start; while ((Object)(object)val != (Object)null) { if (Object.op_Implicit((Object)(object)FindLooseBFS(val, names))) { return val; } val = val.parent; } return null; } } [HarmonyPatch(typeof(PlayerAvatar), "Start")] internal static class Patch_TinyPlayer_OnStart { private static void Postfix(PlayerAvatar __instance) { TinyController tinyController = Object.FindFirstObjectByType<TinyController>(); if (Object.op_Implicit((Object)(object)__instance) && !((Object)(object)tinyController == (Object)null) && tinyController.ModEnabled) { TinyAvatarUtil.AttachUniformScaler(__instance, tinyController.Factor); } } } } namespace TinyRepo { [BepInPlugin("Omniscye.TinyRepo", "TinyRepo", "1.0")] public class TinyRepo : BaseUnityPlugin { internal static TinyRepo Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } }