using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
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("BigEyes")]
[assembly: AssemblyTitle("BigEyes")]
[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 Empress.BigEyes
{
[BepInPlugin("empress.repo.bigeyes", "Big Eyes", "1.4.1")]
public sealed class BigEyesPlugin : BaseUnityPlugin
{
public const string Guid = "empress.repo.bigeyes";
public const string Name = "Big Eyes";
public const string Version = "1.4.1";
internal static ManualLogSource LogS;
internal static Harmony Harmony;
internal static ConfigEntry<bool> C_Enable;
internal static ConfigEntry<float> C_EyeScale;
internal static ConfigEntry<int> C_ApplyDelayFrames;
internal static ConfigEntry<bool> C_Debug;
internal static ConfigEntry<float> C_MaxSearchSeconds;
internal static ConfigEntry<bool> C_ScaleAllEyeMatches;
internal static ConfigEntry<string> C_LeftEyeName;
internal static ConfigEntry<string> C_RightEyeName;
private void Awake()
{
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
LogS = ((BaseUnityPlugin)this).Logger;
C_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable", true, "Master enable for the mod.");
C_EyeScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "EyeScale", 2f, "Uniform scale applied to eye transforms.");
C_ApplyDelayFrames = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ApplyDelayFrames", 1, "Frames to wait after PlayerAvatar.Start before applying changes.");
C_Debug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugLogs", false, "If true, prints extra search diagnostics.");
C_MaxSearchSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxSearchSeconds", 5f, "How long to keep scanning hierarchy for targets before giving up.");
C_ScaleAllEyeMatches = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ScaleAllEyeMatches", true, "Scale every transform that looks like an eye (not just L/R).");
C_LeftEyeName = ((BaseUnityPlugin)this).Config.Bind<string>("Names", "LeftEyeName", "ANIM EYE LEFT", "Left eye Transform name (fallback).");
C_RightEyeName = ((BaseUnityPlugin)this).Config.Bind<string>("Names", "RightEyeName", "ANIM EYE RIGHT", "Right eye Transform name (fallback).");
Harmony = new Harmony("empress.repo.bigeyes");
Harmony.PatchAll(typeof(Patches));
LogS.LogInfo((object)"Big Eyes 1.4.1 loaded (eyes only).");
}
private void OnDestroy()
{
try
{
Harmony harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
catch (Exception ex)
{
LogS.LogWarning((object)("Unpatch failed: " + ex.Message));
}
}
}
internal static class Util
{
[CompilerGenerated]
private sealed class <EnumerateAll>d__1 : IEnumerable<Transform>, IEnumerable, IEnumerator<Transform>, IEnumerator, IDisposable
{
private int <>1__state;
private Transform <>2__current;
private int <>l__initialThreadId;
private Transform root;
public Transform <>3__root;
private Stack<Transform> <stack>5__1;
private Transform <t>5__2;
private int <i>5__3;
Transform IEnumerator<Transform>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnumerateAll>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<stack>5__1 = null;
<t>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)root == (Object)null)
{
return false;
}
<stack>5__1 = new Stack<Transform>();
<stack>5__1.Push(root);
break;
case 1:
<>1__state = -1;
<i>5__3 = 0;
while (<i>5__3 < <t>5__2.childCount)
{
<stack>5__1.Push(<t>5__2.GetChild(<i>5__3));
<i>5__3++;
}
<t>5__2 = null;
break;
}
if (<stack>5__1.Count > 0)
{
<t>5__2 = <stack>5__1.Pop();
<>2__current = <t>5__2;
<>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();
}
[DebuggerHidden]
IEnumerator<Transform> IEnumerable<Transform>.GetEnumerator()
{
<EnumerateAll>d__1 <EnumerateAll>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<EnumerateAll>d__ = this;
}
else
{
<EnumerateAll>d__ = new <EnumerateAll>d__1(0);
}
<EnumerateAll>d__.root = <>3__root;
return <EnumerateAll>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<Transform>)this).GetEnumerator();
}
}
public static string Sanitize(string s)
{
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder(s.Length);
foreach (char c in s)
{
if (char.IsLetterOrDigit(c))
{
stringBuilder.Append(char.ToLowerInvariant(c));
}
}
return stringBuilder.ToString();
}
[IteratorStateMachine(typeof(<EnumerateAll>d__1))]
public static IEnumerable<Transform> EnumerateAll(Transform root)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EnumerateAll>d__1(-2)
{
<>3__root = root
};
}
public static int Depth(Transform t)
{
int num = 0;
Transform val = t;
while ((Object)(object)val != (Object)null)
{
num++;
val = val.parent;
}
return num;
}
public static string GetPath(Transform t)
{
if ((Object)(object)t == (Object)null)
{
return "<null>";
}
Stack<string> stack = new Stack<string>();
Transform val = t;
while ((Object)(object)val != (Object)null)
{
stack.Push(((Object)val).name);
val = val.parent;
}
return string.Join("/", stack.ToArray());
}
public static Transform PickDeepest(IList<Transform> list)
{
if (list == null || list.Count == 0)
{
return null;
}
Transform val = list[0];
int num = Depth(val);
for (int i = 1; i < list.Count; i++)
{
int num2 = Depth(list[i]);
if (num2 > num)
{
val = list[i];
num = num2;
}
}
return val;
}
}
[HarmonyPatch]
internal static class Patches
{
[CompilerGenerated]
private sealed class <ApplyRoutine>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAvatar avatar;
private int <delay>5__1;
private float <timeout>5__2;
private float <t0>5__3;
private List<Transform> <eyes>5__4;
private int <i>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ApplyRoutine>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<eyes>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<delay>5__1 = Mathf.Max(0, BigEyesPlugin.C_ApplyDelayFrames.Value);
<i>5__5 = 0;
goto IL_0074;
case 1:
<>1__state = -1;
<i>5__5++;
goto IL_0074;
case 2:
{
<>1__state = -1;
break;
}
IL_0074:
if (<i>5__5 < <delay>5__1)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<timeout>5__2 = Mathf.Max(0.1f, BigEyesPlugin.C_MaxSearchSeconds.Value);
<t0>5__3 = Time.realtimeSinceStartup;
<eyes>5__4 = null;
break;
}
if (Time.realtimeSinceStartup - <t0>5__3 < <timeout>5__2)
{
if (<eyes>5__4 == null || <eyes>5__4.Count == 0)
{
<eyes>5__4 = ResolveEyes(avatar);
}
if (<eyes>5__4 == null || <eyes>5__4.Count <= 0)
{
<>2__current = null;
<>1__state = 2;
return true;
}
}
if (<eyes>5__4 != null && <eyes>5__4.Count > 0)
{
ScaleEyes(<eyes>5__4, BigEyesPlugin.C_EyeScale.Value);
}
else
{
BigEyesPlugin.LogS.LogWarning((object)"Eye search timed out; nothing scaled.");
}
Processed.Add(((Object)avatar).GetInstanceID());
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();
}
}
private static readonly HashSet<int> Processed = new HashSet<int>();
[HarmonyPatch(typeof(PlayerAvatar), "Start")]
[HarmonyPostfix]
private static void PlayerAvatar_Start_Postfix(PlayerAvatar __instance)
{
if (BigEyesPlugin.C_Enable.Value && !((Object)(object)__instance == (Object)null))
{
int instanceID = ((Object)__instance).GetInstanceID();
if (!Processed.Contains(instanceID))
{
((MonoBehaviour)__instance).StartCoroutine(ApplyRoutine(__instance));
}
}
}
[IteratorStateMachine(typeof(<ApplyRoutine>d__2))]
private static IEnumerator ApplyRoutine(PlayerAvatar avatar)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ApplyRoutine>d__2(0)
{
avatar = avatar
};
}
private static List<Transform> ResolveEyes(PlayerAvatar avatar)
{
List<Transform> list = new List<Transform>(4);
PlayerAvatarVisuals val = (((Object)(object)avatar != (Object)null) ? avatar.playerAvatarVisuals : null);
if ((Object)(object)val == (Object)null && (Object)(object)avatar != (Object)null)
{
val = ((Component)avatar).GetComponentInChildren<PlayerAvatarVisuals>(true);
}
PlayerEyes val2 = null;
if ((Object)(object)val != (Object)null)
{
val2 = (((Object)(object)val.playerEyes != (Object)null) ? val.playerEyes : ((Component)val).GetComponentInChildren<PlayerEyes>(true));
}
if ((Object)(object)val2 != (Object)null)
{
if ((Object)(object)val2.eyeLeft != (Object)null)
{
list.Add(val2.eyeLeft);
}
if ((Object)(object)val2.eyeRight != (Object)null)
{
list.Add(val2.eyeRight);
}
if (list.Count > 0)
{
if (BigEyesPlugin.C_Debug.Value)
{
for (int i = 0; i < list.Count; i++)
{
BigEyesPlugin.LogS.LogInfo((object)("Eyes via PlayerEyes[" + i + "] => " + Util.GetPath(list[i])));
}
}
return list;
}
}
Transform val3 = (((Object)(object)avatar != (Object)null) ? ((Component)avatar).transform : null);
if ((Object)(object)val3 == (Object)null)
{
return list;
}
List<Transform> list2 = new List<Transform>();
foreach (Transform item2 in Util.EnumerateAll(val3))
{
string text = Util.Sanitize(((Object)item2).name);
if (text.Contains("eye"))
{
list2.Add(item2);
}
}
List<Transform> list3 = new List<Transform>();
List<Transform> list4 = new List<Transform>();
for (int j = 0; j < list2.Count; j++)
{
string text2 = Util.Sanitize(((Object)list2[j]).name);
bool flag = text2.Contains("left") || text2.EndsWith("l") || text2.Contains("_l");
bool flag2 = text2.Contains("right") || text2.EndsWith("r") || text2.Contains("_r");
if (flag && !flag2)
{
list3.Add(list2[j]);
}
else if (flag2 && !flag)
{
list4.Add(list2[j]);
}
}
if (list3.Count > 0)
{
list.Add(Util.PickDeepest(list3));
}
if (list4.Count > 0)
{
list.Add(Util.PickDeepest(list4));
}
if (BigEyesPlugin.C_ScaleAllEyeMatches.Value)
{
for (int k = 0; k < list2.Count; k++)
{
Transform item = list2[k];
if (!list.Contains(item))
{
list.Add(item);
}
}
}
if (BigEyesPlugin.C_Debug.Value)
{
for (int l = 0; l < list.Count; l++)
{
BigEyesPlugin.LogS.LogInfo((object)("Eye match[" + l + "] => " + Util.GetPath(list[l])));
}
}
return list;
}
private static void ScaleEyes(List<Transform> eyes, float scale)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(0.001f, scale);
int num2 = 0;
for (int i = 0; i < eyes.Count; i++)
{
Transform val = eyes[i];
if (!((Object)(object)val == (Object)null))
{
val.localScale = new Vector3(num, num, num);
num2++;
}
}
BigEyesPlugin.LogS.LogInfo((object)("Scaled " + num2 + " eye transform(s) to " + num + "."));
}
}
}
namespace BigEyes
{
[BepInPlugin("Omniscye.BigEyes", "BigEyes", "1.0")]
public class BigEyes : BaseUnityPlugin
{
internal static BigEyes 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()
{
}
}
}