using 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("OmniRepo2D")]
[assembly: AssemblyTitle("OmniRepo2D")]
[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 OmniRepo2D
{
[BepInPlugin("Omniscye.OmniRepo2D", "OmniRepo2D", "1.0")]
public class OmniRepo2D : BaseUnityPlugin
{
internal static OmniRepo2D 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()
{
}
}
}
namespace REPO.Flat2D
{
public static class Entry
{
[RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)]
private static void Bootstrap()
{
Flat2DMod.Init();
}
}
[HarmonyPatch]
public static class Flat2DMod
{
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.flat2d.toggle");
_harmony.PatchAll(typeof(Flat2DMod).Assembly);
Debug.Log((object)"[Flat2D] Harmony patches applied.");
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(RenderTextureMain), "Awake")]
private static void RenderTextureMain_Awake_Postfix(RenderTextureMain __instance)
{
Flat2DController flat2DController = default(Flat2DController);
if (Object.op_Implicit((Object)(object)__instance) && !((Component)__instance).gameObject.TryGetComponent<Flat2DController>(ref flat2DController))
{
((Component)__instance).gameObject.AddComponent<Flat2DController>();
}
}
}
public sealed class Flat2DController : MonoBehaviour
{
[CompilerGenerated]
private sealed class <ApplyFlatToExistingDelayed>d__8 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float extraDelaySeconds;
public Flat2DController <>4__this;
private EnemyParent[] <enemies>5__1;
private ValuableObject[] <vals>5__2;
private Transform[] <all>5__3;
private PlayerAvatar[] <avatars>5__4;
private int <i>5__5;
private int <i>5__6;
private int <i>5__7;
private Transform <t>5__8;
private string <n>5__9;
private int <i>5__10;
private PlayerAvatar <p>5__11;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ApplyFlatToExistingDelayed>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<enemies>5__1 = null;
<vals>5__2 = null;
<all>5__3 = null;
<avatars>5__4 = null;
<t>5__8 = null;
<n>5__9 = null;
<p>5__11 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForEndOfFrame();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
if (extraDelaySeconds > 0f)
{
<>2__current = (object)new WaitForSecondsRealtime(extraDelaySeconds);
<>1__state = 3;
return true;
}
break;
case 3:
<>1__state = -1;
break;
}
if (!<>4__this.ModEnabled)
{
return false;
}
<enemies>5__1 = Object.FindObjectsByType<EnemyParent>((FindObjectsSortMode)0);
<i>5__5 = 0;
while (<i>5__5 < <enemies>5__1.Length)
{
if (Object.op_Implicit((Object)(object)<enemies>5__1[<i>5__5]) && ((Component)<enemies>5__1[<i>5__5]).gameObject.activeInHierarchy)
{
FlatUtil.TryFlatify(((Component)<enemies>5__1[<i>5__5]).gameObject, <>4__this.Depth);
}
<i>5__5++;
}
<vals>5__2 = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0);
<i>5__6 = 0;
while (<i>5__6 < <vals>5__2.Length)
{
if (Object.op_Implicit((Object)(object)<vals>5__2[<i>5__6]) && ((Component)<vals>5__2[<i>5__6]).gameObject.activeInHierarchy)
{
FlatUtil.TryFlatify(((Component)<vals>5__2[<i>5__6]).gameObject, <>4__this.Depth);
}
<i>5__6++;
}
<all>5__3 = Object.FindObjectsByType<Transform>((FindObjectsSortMode)0);
<i>5__7 = 0;
while (<i>5__7 < <all>5__3.Length)
{
<t>5__8 = <all>5__3[<i>5__7];
if (Object.op_Implicit((Object)(object)<t>5__8) && ((Component)<t>5__8).gameObject.activeInHierarchy)
{
<n>5__9 = ((Object)<t>5__8).name;
if (NameIsWhitelistedItem(<n>5__9) && !((Object)(object)((Component)<t>5__8).GetComponent<_FlatMarker>() != (Object)null))
{
FlatUtil.TryFlatify(((Component)<t>5__8).gameObject, <>4__this.Depth);
<t>5__8 = null;
<n>5__9 = null;
}
}
<i>5__7++;
}
<avatars>5__4 = Object.FindObjectsByType<PlayerAvatar>((FindObjectsSortMode)0);
<i>5__10 = 0;
while (<i>5__10 < <avatars>5__4.Length)
{
<p>5__11 = <avatars>5__4[<i>5__10];
if (Object.op_Implicit((Object)(object)<p>5__11) && ((Component)<p>5__11).gameObject.activeInHierarchy)
{
AvatarFlatUtil.AttachFlattener(<p>5__11, <>4__this.Depth);
AvatarFlatUtil.AttachFlashlightScaler(<p>5__11, <>4__this.FlashlightY);
<p>5__11 = null;
}
<i>5__10++;
}
FlashlightSceneUtil.SweepAndEnforce(<>4__this.FlashlightY);
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();
}
}
[CompilerGenerated]
private sealed class <AvatarKeepFlatLoop>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Flat2DController <>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 <AvatarKeepFlatLoop>d__5(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)
{
AvatarFlatUtil.AttachFlattener(<p>5__4, <>4__this.Depth);
AvatarFlatUtil.AttachFlashlightScaler(<p>5__4, <>4__this.FlashlightY);
<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.0001f, 0.2f)]
public float Depth = 0.01f;
[Range(0.0001f, 2f)]
public float FlashlightY = 0.1f;
private Coroutine _avatarLoop;
private void Update()
{
if (!Input.GetKeyDown((KeyCode)289))
{
return;
}
ModEnabled = !ModEnabled;
if (ModEnabled)
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(ApplyFlatToExistingDelayed(0.15f));
_avatarLoop = ((MonoBehaviour)this).StartCoroutine(AvatarKeepFlatLoop());
Debug.Log((object)"[Flat2D] ENABLED");
return;
}
if (_avatarLoop != null)
{
((MonoBehaviour)this).StopCoroutine(_avatarLoop);
_avatarLoop = null;
}
AvatarFlatUtil.DetachAllFlattener();
FlashlightSceneUtil.DetachAllEnforcers();
RestoreAllFlatified();
Debug.Log((object)"[Flat2D] DISABLED");
}
[IteratorStateMachine(typeof(<AvatarKeepFlatLoop>d__5))]
private IEnumerator AvatarKeepFlatLoop()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AvatarKeepFlatLoop>d__5(0)
{
<>4__this = this
};
}
private static bool NameIsWhitelistedItem(string n)
{
if (string.IsNullOrEmpty(n))
{
return false;
}
bool flag = n.StartsWith("Item ", StringComparison.OrdinalIgnoreCase);
bool flag2 = n.IndexOf("Cart", StringComparison.OrdinalIgnoreCase) >= 0;
return flag && !flag2;
}
private void RestoreAllFlatified()
{
_FlatMarker[] array = Object.FindObjectsByType<_FlatMarker>((FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
FlatUtil.Restore(((Component)array[i]).gameObject);
}
}
[IteratorStateMachine(typeof(<ApplyFlatToExistingDelayed>d__8))]
private IEnumerator ApplyFlatToExistingDelayed(float extraDelaySeconds)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ApplyFlatToExistingDelayed>d__8(0)
{
<>4__this = this,
extraDelaySeconds = extraDelaySeconds
};
}
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 ? "2D Mode: ON (F8 to toggle)" : "2D 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);
}
}
internal sealed class _FlatMarker : MonoBehaviour
{
public Dictionary<Transform, Vector3> original = new Dictionary<Transform, Vector3>();
}
internal static class FlatUtil
{
public static void TryFlatify(GameObject root, float depth)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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)
if (!Object.op_Implicit((Object)(object)root))
{
return;
}
_FlatMarker flatMarker = root.GetComponent<_FlatMarker>();
if (!Object.op_Implicit((Object)(object)flatMarker))
{
flatMarker = root.AddComponent<_FlatMarker>();
}
Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
float num = Mathf.Max(depth, 0.0001f);
for (int i = 0; i < componentsInChildren.Length; i++)
{
Transform transform = ((Component)componentsInChildren[i]).transform;
if (!flatMarker.original.ContainsKey(transform))
{
flatMarker.original[transform] = transform.localScale;
}
Vector3 localScale = transform.localScale;
if (localScale.z != num)
{
transform.localScale = new Vector3(localScale.x, localScale.y, num);
}
}
}
public static void Restore(GameObject root)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
_FlatMarker flatMarker = (Object.op_Implicit((Object)(object)root) ? root.GetComponent<_FlatMarker>() : null);
if (!Object.op_Implicit((Object)(object)flatMarker))
{
return;
}
foreach (KeyValuePair<Transform, Vector3> item in flatMarker.original)
{
if (Object.op_Implicit((Object)(object)item.Key))
{
item.Key.localScale = item.Value;
}
}
Object.Destroy((Object)(object)flatMarker);
}
}
public sealed class AvatarRigFlattener : MonoBehaviour
{
public Transform Target;
public float XDepth = 0.01f;
private Vector3 _origScale;
private bool _hasOrig;
public void Configure(Transform target, float xDepth)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
Target = target;
XDepth = xDepth;
if (Object.op_Implicit((Object)(object)Target) && !_hasOrig)
{
_origScale = Target.localScale;
_hasOrig = true;
}
((Behaviour)this).enabled = true;
}
private void LateUpdate()
{
//IL_0024: 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)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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 localScale = Target.localScale;
float num = Mathf.Max(XDepth, 0.0001f);
if (Mathf.Abs(localScale.x - num) > 1E-05f)
{
Target.localScale = new Vector3(num, localScale.y, localScale.z);
}
}
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;
}
}
}
public sealed class FlashlightMultiScaler : MonoBehaviour
{
public List<Transform> Targets = new List<Transform>();
public float YScale = 0.1f;
private readonly List<(Transform t, Vector3 orig)> _orig = new List<(Transform, Vector3)>();
private bool _captured;
public void Configure(IList<Transform> targets, float yScale)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
Targets.Clear();
if (targets != null)
{
for (int i = 0; i < targets.Count; i++)
{
Transform val = targets[i];
if (Object.op_Implicit((Object)(object)val))
{
Targets.Add(val);
}
}
}
YScale = yScale;
if (!_captured)
{
_orig.Clear();
for (int j = 0; j < Targets.Count; j++)
{
Transform val2 = Targets[j];
_orig.Add((val2, val2.localScale));
}
_captured = true;
}
((Behaviour)this).enabled = true;
}
private void LateUpdate()
{
//IL_0036: 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_003c: 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_005e: 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)
float num = Mathf.Max(YScale, 0.0001f);
for (int i = 0; i < Targets.Count; i++)
{
Transform val = Targets[i];
if (Object.op_Implicit((Object)(object)val))
{
Vector3 localScale = val.localScale;
if (Mathf.Abs(localScale.y - num) > 1E-05f)
{
val.localScale = new Vector3(localScale.x, num, localScale.z);
}
}
}
}
private void OnDisable()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _orig.Count; i++)
{
(Transform, Vector3) tuple = _orig[i];
if (Object.op_Implicit((Object)(object)tuple.Item1))
{
tuple.Item1.localScale = tuple.Item2;
}
}
}
private void OnDestroy()
{
OnDisable();
}
}
public sealed class FlashlightYEnforcer : MonoBehaviour
{
public float Y = 0.1f;
private Vector3 _orig;
private bool _has;
private void OnEnable()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
_orig = ((Component)this).transform.localScale;
_has = true;
}
private void LateUpdate()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(Y, 0.0001f);
Vector3 localScale = ((Component)this).transform.localScale;
if (Mathf.Abs(localScale.y - num) > 1E-05f)
{
((Component)this).transform.localScale = new Vector3(localScale.x, num, localScale.z);
}
}
private void OnDisable()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (_has)
{
((Component)this).transform.localScale = _orig;
}
}
private void OnDestroy()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (_has)
{
((Component)this).transform.localScale = _orig;
}
}
}
public sealed class AvatarPerRendererFlattener : MonoBehaviour
{
public float XDepth = 0.01f;
private readonly List<(Transform t, Vector3 orig)> _targets = new List<(Transform, Vector3)>();
private void OnEnable()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
_targets.Clear();
Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
Transform transform = ((Component)componentsInChildren[i]).transform;
_targets.Add((transform, transform.localScale));
}
}
private void LateUpdate()
{
//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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(XDepth, 0.0001f);
for (int i = 0; i < _targets.Count; i++)
{
Transform item = _targets[i].t;
if (Object.op_Implicit((Object)(object)item))
{
Vector3 localScale = item.localScale;
if (Mathf.Abs(localScale.x - num) > 1E-05f)
{
item.localScale = new Vector3(num, localScale.y, localScale.z);
}
}
}
}
private void OnDisable()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _targets.Count; i++)
{
(Transform, Vector3) tuple = _targets[i];
if (Object.op_Implicit((Object)(object)tuple.Item1))
{
tuple.Item1.localScale = tuple.Item2;
}
}
_targets.Clear();
}
private void OnDestroy()
{
OnDisable();
}
}
internal static class AvatarFlatUtil
{
[CompilerGenerated]
private sealed class <FindAllExactBFS>d__15 : 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 string[] names;
public string[] <>3__names;
private HashSet<string> <set>5__1;
private Queue<Transform> <q>5__2;
private Transform <cur>5__3;
private IEnumerator <>s__4;
private Transform <c>5__5;
Transform IEnumerator<Transform>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FindAllExactBFS>d__15(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<set>5__1 = null;
<q>5__2 = null;
<cur>5__3 = null;
<>s__4 = null;
<c>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
try
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -3;
goto IL_011b;
}
<>1__state = -1;
if (!Object.op_Implicit((Object)(object)root))
{
return false;
}
<set>5__1 = new HashSet<string>(names.Select((string n) => n.Trim()), StringComparer.OrdinalIgnoreCase);
<q>5__2 = new Queue<Transform>();
<q>5__2.Enqueue(root);
goto IL_0158;
IL_0135:
if (<>s__4.MoveNext())
{
<c>5__5 = (Transform)<>s__4.Current;
if (<set>5__1.Contains(((Object)<c>5__5).name))
{
<>2__current = <c>5__5;
<>1__state = 1;
return true;
}
goto IL_011b;
}
<>m__Finally1();
<>s__4 = null;
<cur>5__3 = null;
goto IL_0158;
IL_0158:
if (<q>5__2.Count > 0)
{
<cur>5__3 = <q>5__2.Dequeue();
<>s__4 = <cur>5__3.GetEnumerator();
<>1__state = -3;
goto IL_0135;
}
return false;
IL_011b:
<q>5__2.Enqueue(<c>5__5);
<c>5__5 = null;
goto IL_0135;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__4 is IDisposable disposable)
{
disposable.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<Transform> IEnumerable<Transform>.GetEnumerator()
{
<FindAllExactBFS>d__15 <FindAllExactBFS>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<FindAllExactBFS>d__ = this;
}
else
{
<FindAllExactBFS>d__ = new <FindAllExactBFS>d__15(0);
}
<FindAllExactBFS>d__.root = <>3__root;
<FindAllExactBFS>d__.names = <>3__names;
return <FindAllExactBFS>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<Transform>)this).GetEnumerator();
}
}
private static readonly string[] VISUALS = new string[2] { "Player Visuals", "PlayerVisuals" };
private static readonly string[] RIG = new string[2] { "[RIG]", "RIG" };
private static readonly string[] LOCAL_CAMERA = new string[1] { "Local Camera" };
private static readonly string[] FLASHLIGHT_TARGET = new string[2] { "Flashlight Target", "FlashlightTarget" };
private static readonly string[] FLASHLIGHT = new string[1] { "Flashlight" };
private static readonly string[] MESH = new string[1] { "Mesh" };
private static readonly Dictionary<PlayerAvatar, Transform> _cachedTarget = new Dictionary<PlayerAvatar, Transform>();
private static readonly Dictionary<PlayerAvatar, List<Transform>> _cachedFlashlightMeshes = new Dictionary<PlayerAvatar, List<Transform>>();
public static void AttachFlattener(PlayerAvatar avatar, float xDepth)
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)avatar))
{
return;
}
if (_cachedTarget.TryGetValue(avatar, out Transform value) && Object.op_Implicit((Object)(object)value))
{
EnsureEnforcers(avatar, value, xDepth);
return;
}
AvatarRigFlattener component = ((Component)avatar).GetComponent<AvatarRigFlattener>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.Target))
{
component.Configure(component.Target, xDepth);
AvatarPerRendererFlattener component2 = ((Component)avatar).GetComponent<AvatarPerRendererFlattener>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.XDepth = Mathf.Max(xDepth, 0.0001f);
((Behaviour)component2).enabled = true;
}
Transform target = component.Target;
Vector3 localScale = target.localScale;
float num = Mathf.Max(xDepth, 0.0001f);
if (Mathf.Abs(localScale.x - num) > 1E-05f)
{
target.localScale = new Vector3(num, localScale.y, localScale.z);
}
_cachedTarget[avatar] = target;
}
else
{
(Transform visuals, Transform rig, Transform searchRoot) tuple = ResolveAvatarRigStrict(((Component)avatar).transform);
Transform item = tuple.visuals;
Transform item2 = tuple.rig;
Transform item3 = tuple.searchRoot;
Transform val = item2 ?? item ?? ((Component)avatar).transform;
Debug.Log((object)("[Flat2D] Avatar STRICT target -> searchRoot: " + ((Object)item3).name + ", visuals: " + (Object.op_Implicit((Object)(object)item) ? ((Object)item).name : "<null>") + ", rig: " + (Object.op_Implicit((Object)(object)item2) ? ((Object)item2).name : "<null>") + ", use: " + ((Object)val).name));
_cachedTarget[avatar] = val;
EnsureEnforcers(avatar, val, xDepth);
}
}
public static void AttachFlashlightScaler(PlayerAvatar avatar, float yScale)
{
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)avatar))
{
return;
}
if (!_cachedFlashlightMeshes.TryGetValue(avatar, out List<Transform> value) || value == null || value.Count == 0 || value.Any((Transform m) => !Object.op_Implicit((Object)(object)m)))
{
value = ResolveAllFlashlightMeshes(((Component)avatar).transform);
if (value.Count > 0)
{
_cachedFlashlightMeshes[avatar] = value;
}
}
if (value == null || value.Count == 0)
{
return;
}
FlashlightMultiScaler flashlightMultiScaler = ((Component)avatar).GetComponent<FlashlightMultiScaler>() ?? ((Component)avatar).gameObject.AddComponent<FlashlightMultiScaler>();
flashlightMultiScaler.Configure(value, yScale);
float num = Mathf.Max(yScale, 0.0001f);
for (int i = 0; i < value.Count; i++)
{
Transform val = value[i];
if (Object.op_Implicit((Object)(object)val))
{
Vector3 localScale = val.localScale;
if (Mathf.Abs(localScale.y - num) > 1E-05f)
{
val.localScale = new Vector3(localScale.x, num, localScale.z);
}
}
}
}
private static void EnsureEnforcers(PlayerAvatar avatar, Transform target, float xDepth)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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)
float num = Mathf.Max(xDepth, 0.0001f);
AvatarRigFlattener avatarRigFlattener = ((Component)avatar).GetComponent<AvatarRigFlattener>() ?? ((Component)avatar).gameObject.AddComponent<AvatarRigFlattener>();
avatarRigFlattener.Configure(target, num);
Vector3 localScale = target.localScale;
if (Mathf.Abs(localScale.x - num) > 1E-05f)
{
target.localScale = new Vector3(num, localScale.y, localScale.z);
}
AvatarPerRendererFlattener avatarPerRendererFlattener = ((Component)avatar).GetComponent<AvatarPerRendererFlattener>() ?? ((Component)avatar).gameObject.AddComponent<AvatarPerRendererFlattener>();
avatarPerRendererFlattener.XDepth = num;
((Behaviour)avatarPerRendererFlattener).enabled = true;
}
public static void DetachAllFlattener()
{
AvatarRigFlattener[] array = Object.FindObjectsByType<AvatarRigFlattener>((FindObjectsSortMode)0);
foreach (AvatarRigFlattener avatarRigFlattener in array)
{
if (Object.op_Implicit((Object)(object)avatarRigFlattener))
{
((Behaviour)avatarRigFlattener).enabled = false;
Object.Destroy((Object)(object)avatarRigFlattener);
}
}
AvatarPerRendererFlattener[] array2 = Object.FindObjectsByType<AvatarPerRendererFlattener>((FindObjectsSortMode)0);
foreach (AvatarPerRendererFlattener avatarPerRendererFlattener in array2)
{
if (Object.op_Implicit((Object)(object)avatarPerRendererFlattener))
{
((Behaviour)avatarPerRendererFlattener).enabled = false;
Object.Destroy((Object)(object)avatarPerRendererFlattener);
}
}
FlashlightMultiScaler[] array3 = Object.FindObjectsByType<FlashlightMultiScaler>((FindObjectsSortMode)0);
foreach (FlashlightMultiScaler flashlightMultiScaler in array3)
{
if (Object.op_Implicit((Object)(object)flashlightMultiScaler))
{
((Behaviour)flashlightMultiScaler).enabled = false;
Object.Destroy((Object)(object)flashlightMultiScaler);
}
}
_cachedTarget.Clear();
_cachedFlashlightMeshes.Clear();
}
private static (Transform visuals, Transform rig, Transform searchRoot) ResolveAvatarRigStrict(Transform avatarNode)
{
Transform val = FindNearestAncestorWhoseSubtreeHas(avatarNode, VISUALS) ?? avatarNode;
Transform val2 = FindExactBFS(val, VISUALS);
if (!Object.op_Implicit((Object)(object)val2))
{
return (null, FallbackSkinsCommonAncestor(avatarNode, avatarNode), val);
}
Transform val3 = FindExactBFS(val2, RIG);
if (!Object.op_Implicit((Object)(object)val3))
{
Debug.LogWarning((object)"[Flat2D] [RIG] not found under Player Visuals; using SkinnedMesh common ancestor as rig.");
val3 = FallbackSkinsCommonAncestor(avatarNode, val2);
}
return (val2, val3, val);
}
private static List<Transform> ResolveAllFlashlightMeshes(Transform avatarNode)
{
List<Transform> list = new List<Transform>();
Transform root = FindNearestAncestorWhoseSubtreeHas(avatarNode, LOCAL_CAMERA) ?? avatarNode;
Transform val = FindExactBFS(root, LOCAL_CAMERA);
if (Object.op_Implicit((Object)(object)val))
{
foreach (Transform item in FindAllExactBFS(val, FLASHLIGHT_TARGET))
{
foreach (Transform item2 in FindAllExactBFS(item, FLASHLIGHT))
{
foreach (Transform item3 in FindAllExactBFS(item2, MESH))
{
if (Object.op_Implicit((Object)(object)item3) && !list.Contains(item3))
{
list.Add(item3);
}
}
}
}
}
if (list.Count == 0)
{
foreach (Transform item4 in FindAllExactBFS(avatarNode, FLASHLIGHT))
{
foreach (Transform item5 in FindAllExactBFS(item4, MESH))
{
if (Object.op_Implicit((Object)(object)item5) && !list.Contains(item5))
{
list.Add(item5);
}
}
}
}
return list;
}
private static Transform FindExactBFS(Transform root, params string[] names)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)root))
{
return null;
}
HashSet<string> hashSet = new HashSet<string>(names.Select((string n) => n.Trim()), StringComparer.OrdinalIgnoreCase);
foreach (Transform item in root)
{
Transform val = item;
if (hashSet.Contains(((Object)val).name))
{
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;
if (hashSet.Contains(((Object)val3).name))
{
return val3;
}
queue.Enqueue(val3);
}
}
return null;
}
[IteratorStateMachine(typeof(<FindAllExactBFS>d__15))]
private static IEnumerable<Transform> FindAllExactBFS(Transform root, params string[] names)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FindAllExactBFS>d__15(-2)
{
<>3__root = root,
<>3__names = names
};
}
private static Transform FindNearestAncestorWhoseSubtreeHas(Transform start, params string[] names)
{
Transform val = start;
while ((Object)(object)val != (Object)null)
{
if (Object.op_Implicit((Object)(object)FindExactBFS(val, names)))
{
return val;
}
val = val.parent;
}
return null;
}
private static Transform FallbackSkinsCommonAncestor(Transform avatarRoot, Transform fallback)
{
SkinnedMeshRenderer[] componentsInChildren = ((Component)avatarRoot).GetComponentsInChildren<SkinnedMeshRenderer>(true);
if (componentsInChildren.Length == 0)
{
return fallback;
}
List<List<Transform>> list = new List<List<Transform>>();
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val in array)
{
List<Transform> list2 = new List<Transform>();
Transform val2 = ((Component)val).transform;
while ((Object)(object)val2 != (Object)null)
{
list2.Add(val2);
val2 = val2.parent;
}
list.Add(list2);
}
foreach (Transform item in list[0])
{
bool flag = true;
for (int j = 1; j < list.Count; j++)
{
if (!list[j].Contains(item))
{
flag = false;
break;
}
}
if (flag)
{
return item;
}
}
return fallback;
}
}
internal static class FlashlightSceneUtil
{
[CompilerGenerated]
private sealed class <FindAllExactBFS>d__8 : 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 string[] names;
public string[] <>3__names;
private HashSet<string> <set>5__1;
private Queue<Transform> <q>5__2;
private Transform <cur>5__3;
private IEnumerator <>s__4;
private Transform <c>5__5;
Transform IEnumerator<Transform>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FindAllExactBFS>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<set>5__1 = null;
<q>5__2 = null;
<cur>5__3 = null;
<>s__4 = null;
<c>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
try
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -3;
goto IL_011b;
}
<>1__state = -1;
if (!Object.op_Implicit((Object)(object)root))
{
return false;
}
<set>5__1 = new HashSet<string>(names.Select((string n) => n.Trim()), StringComparer.OrdinalIgnoreCase);
<q>5__2 = new Queue<Transform>();
<q>5__2.Enqueue(root);
goto IL_0158;
IL_0135:
if (<>s__4.MoveNext())
{
<c>5__5 = (Transform)<>s__4.Current;
if (<set>5__1.Contains(((Object)<c>5__5).name))
{
<>2__current = <c>5__5;
<>1__state = 1;
return true;
}
goto IL_011b;
}
<>m__Finally1();
<>s__4 = null;
<cur>5__3 = null;
goto IL_0158;
IL_0158:
if (<q>5__2.Count > 0)
{
<cur>5__3 = <q>5__2.Dequeue();
<>s__4 = <cur>5__3.GetEnumerator();
<>1__state = -3;
goto IL_0135;
}
return false;
IL_011b:
<q>5__2.Enqueue(<c>5__5);
<c>5__5 = null;
goto IL_0135;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__4 is IDisposable disposable)
{
disposable.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<Transform> IEnumerable<Transform>.GetEnumerator()
{
<FindAllExactBFS>d__8 <FindAllExactBFS>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<FindAllExactBFS>d__ = this;
}
else
{
<FindAllExactBFS>d__ = new <FindAllExactBFS>d__8(0);
}
<FindAllExactBFS>d__.root = <>3__root;
<FindAllExactBFS>d__.names = <>3__names;
return <FindAllExactBFS>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<Transform>)this).GetEnumerator();
}
}
[CompilerGenerated]
private sealed class <FindAllExactBFS_Scene>d__7 : IEnumerable<Transform>, IEnumerable, IEnumerator<Transform>, IEnumerator, IDisposable
{
private int <>1__state;
private Transform <>2__current;
private int <>l__initialThreadId;
private string[] names;
public string[] <>3__names;
private Transform[] <all>5__1;
private int <i>5__2;
private Transform <tr>5__3;
private IEnumerator<Transform> <>s__4;
private Transform <m>5__5;
Transform IEnumerator<Transform>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FindAllExactBFS_Scene>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<all>5__1 = null;
<tr>5__3 = null;
<>s__4 = null;
<m>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
try
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -3;
<m>5__5 = null;
goto IL_00de;
}
<>1__state = -1;
<all>5__1 = Object.FindObjectsByType<Transform>((FindObjectsSortMode)0);
<i>5__2 = 0;
goto IL_0111;
IL_0111:
if (<i>5__2 < <all>5__1.Length)
{
<tr>5__3 = <all>5__1[<i>5__2];
if (!Object.op_Implicit((Object)(object)<tr>5__3) || !((Component)<tr>5__3).gameObject.activeInHierarchy)
{
goto IL_0101;
}
<>s__4 = FindAllExactBFS(<tr>5__3, names).GetEnumerator();
<>1__state = -3;
goto IL_00de;
}
return false;
IL_00de:
if (<>s__4.MoveNext())
{
<m>5__5 = <>s__4.Current;
<>2__current = <m>5__5;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>s__4 = null;
<tr>5__3 = null;
goto IL_0101;
IL_0101:
<i>5__2++;
goto IL_0111;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__4 != null)
{
<>s__4.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<Transform> IEnumerable<Transform>.GetEnumerator()
{
<FindAllExactBFS_Scene>d__7 <FindAllExactBFS_Scene>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<FindAllExactBFS_Scene>d__ = this;
}
else
{
<FindAllExactBFS_Scene>d__ = new <FindAllExactBFS_Scene>d__7(0);
}
<FindAllExactBFS_Scene>d__.names = <>3__names;
return <FindAllExactBFS_Scene>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<Transform>)this).GetEnumerator();
}
}
private static readonly string[] FLASHLIGHT = new string[1] { "Flashlight" };
private static readonly string[] FLASHLIGHT_TARGET = new string[2] { "Flashlight Target", "FlashlightTarget" };
private static readonly string[] MESH = new string[1] { "Mesh" };
private static readonly HashSet<Transform> _tracked = new HashSet<Transform>();
public static void SweepAndEnforce(float yScale)
{
foreach (Transform item in FindAllExactBFS_Scene(FLASHLIGHT_TARGET))
{
foreach (Transform item2 in FindAllExactBFS(item, FLASHLIGHT))
{
foreach (Transform item3 in FindAllExactBFS(item2, MESH))
{
Attach(item3, yScale);
}
}
}
foreach (Transform item4 in FindAllExactBFS_Scene(FLASHLIGHT))
{
foreach (Transform item5 in FindAllExactBFS(item4, MESH))
{
Attach(item5, yScale);
}
}
}
private static void Attach(Transform mesh, float yScale)
{
if (Object.op_Implicit((Object)(object)mesh))
{
if (!_tracked.Contains(mesh))
{
_tracked.Add(mesh);
}
FlashlightYEnforcer flashlightYEnforcer = ((Component)mesh).GetComponent<FlashlightYEnforcer>();
if (!Object.op_Implicit((Object)(object)flashlightYEnforcer))
{
flashlightYEnforcer = ((Component)mesh).gameObject.AddComponent<FlashlightYEnforcer>();
}
flashlightYEnforcer.Y = yScale;
((Behaviour)flashlightYEnforcer).enabled = true;
}
}
public static void DetachAllEnforcers()
{
foreach (Transform item in _tracked)
{
if (Object.op_Implicit((Object)(object)item))
{
FlashlightYEnforcer component = ((Component)item).GetComponent<FlashlightYEnforcer>();
if (Object.op_Implicit((Object)(object)component))
{
((Behaviour)component).enabled = false;
Object.Destroy((Object)(object)component);
}
}
}
_tracked.Clear();
}
[IteratorStateMachine(typeof(<FindAllExactBFS_Scene>d__7))]
private static IEnumerable<Transform> FindAllExactBFS_Scene(params string[] names)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FindAllExactBFS_Scene>d__7(-2)
{
<>3__names = names
};
}
[IteratorStateMachine(typeof(<FindAllExactBFS>d__8))]
private static IEnumerable<Transform> FindAllExactBFS(Transform root, params string[] names)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FindAllExactBFS>d__8(-2)
{
<>3__root = root,
<>3__names = names
};
}
}
[HarmonyPatch(typeof(EnemyParent), "SpawnRPC")]
internal static class Patch_FlatEnemies_OnSpawn
{
[CompilerGenerated]
private sealed class <WaitThenFlat>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public GameObject go;
public float depth;
public float delay;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitThenFlat>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForEndOfFrame();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
if (delay > 0f)
{
<>2__current = (object)new WaitForSecondsRealtime(delay);
<>1__state = 3;
return true;
}
break;
case 3:
<>1__state = -1;
break;
}
if (!Object.op_Implicit((Object)(object)go))
{
return false;
}
FlatUtil.TryFlatify(go, depth);
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 void Postfix(EnemyParent __instance)
{
Flat2DController flat2DController = Object.FindFirstObjectByType<Flat2DController>();
if (Object.op_Implicit((Object)(object)__instance) && !((Object)(object)flat2DController == (Object)null) && flat2DController.ModEnabled)
{
((MonoBehaviour)__instance).StartCoroutine(WaitThenFlat(((Component)__instance).gameObject, flat2DController.Depth, 0.15f));
}
}
[IteratorStateMachine(typeof(<WaitThenFlat>d__1))]
private static IEnumerator WaitThenFlat(GameObject go, float depth, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitThenFlat>d__1(0)
{
go = go,
depth = depth,
delay = delay
};
}
}
[HarmonyPatch(typeof(ValuableObject), "Start")]
internal static class Patch_FlatValuables_OnStart
{
[CompilerGenerated]
private sealed class <WaitThenFlat>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public GameObject go;
public float depth;
public float delay;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitThenFlat>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForEndOfFrame();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
if (delay > 0f)
{
<>2__current = (object)new WaitForSecondsRealtime(delay);
<>1__state = 3;
return true;
}
break;
case 3:
<>1__state = -1;
break;
}
if (!Object.op_Implicit((Object)(object)go))
{
return false;
}
FlatUtil.TryFlatify(go, depth);
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 void Postfix(ValuableObject __instance)
{
Flat2DController flat2DController = Object.FindFirstObjectByType<Flat2DController>();
if (Object.op_Implicit((Object)(object)__instance) && !((Object)(object)flat2DController == (Object)null) && flat2DController.ModEnabled)
{
((MonoBehaviour)__instance).StartCoroutine(WaitThenFlat(((Component)__instance).gameObject, flat2DController.Depth, 0.1f));
}
}
[IteratorStateMachine(typeof(<WaitThenFlat>d__1))]
private static IEnumerator WaitThenFlat(GameObject go, float depth, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitThenFlat>d__1(0)
{
go = go,
depth = depth,
delay = delay
};
}
}
[HarmonyPatch(typeof(PlayerAvatar), "Start")]
internal static class Patch_FlatPlayerAvatar_OnStart
{
private static void Postfix(PlayerAvatar __instance)
{
Flat2DController flat2DController = Object.FindFirstObjectByType<Flat2DController>();
if (Object.op_Implicit((Object)(object)__instance) && !((Object)(object)flat2DController == (Object)null) && flat2DController.ModEnabled)
{
AvatarFlatUtil.AttachFlattener(__instance, flat2DController.Depth);
AvatarFlatUtil.AttachFlashlightScaler(__instance, flat2DController.FlashlightY);
}
}
}
}