using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EdgeDetection.Components; using EdgeDetection.Menu; using EdgeDetection.Structs; using GlobalEnums; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Silksong.ModMenu.Elements; using Silksong.ModMenu.Models; using Silksong.ModMenu.Plugin; using Silksong.ModMenu.Screens; using TeamCherry.Localization; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EdgeDetection")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+a1c9c62fc2428d50e47d4ddeea35b3807ba91fb9")] [assembly: AssemblyProduct("EdgeDetection")] [assembly: AssemblyTitle("EdgeDetection")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/kaycodes13/Silksong.EdgeDetection")] [assembly: NeutralResourcesLanguage("EN")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class ExtensionMarkerAttribute : Attribute { private readonly string k__BackingField; public string Name => k__BackingField; public ExtensionMarkerAttribute(string name) { k__BackingField = name; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace EdgeDetection { [BepInDependency("org.silksong-modding.modmenu", "0.7.6")] [BepInDependency("org.silksong-modding.i18n", "1.1.1")] [BepInPlugin("io.github.kaycodes13.edgedetection", "EdgeDetection", "1.0.4")] public class EdgeDetectionPlugin : BaseUnityPlugin, IModMenuCustomMenu, IModMenuInterface { internal static readonly PassDef[] PassDefs = Utils.ReadJsonAsset("pass_definitions.json"); public const string Id = "io.github.kaycodes13.edgedetection"; internal static EdgeDetectionPlugin Inst { get; private set; } internal static ManualLogSource Log { get; private set; } internal static Shader EdgeDetectionShader { get; private set; } private static Harmony Harmony { get; } = new Harmony("io.github.kaycodes13.edgedetection"); public static string Name => "EdgeDetection"; public static string Version => "1.0.4"; private void Awake() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00c0: Expected O, but got Unknown Inst = this; Log = ((BaseUnityPlugin)this).Logger; Utils.ReadAsset("shader.bundle", delegate(Stream stream) { AssetBundle obj = AssetBundle.LoadFromStream(stream); EdgeDetectionShader = obj.LoadAsset("assets/edgedetection.shader"); obj.Unload(false); }); int num = 0; PassDef[] passDefs = PassDefs; for (int num2 = 0; num2 < passDefs.Length; num2++) { PassDef passDef = passDefs[num2]; PassDefs[num++] = passDef with { Colour = ((BaseUnityPlugin)this).Config.Bind(passDef.Id, "Colour", passDef.Colour, (ConfigDescription)null).Value, Width = ((BaseUnityPlugin)this).Config.Bind(passDef.Id, "Width", passDef.Width, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange((byte)0, (byte)16), Array.Empty())).Value, HalfRes = ((BaseUnityPlugin)this).Config.Bind(passDef.Id, "Low Res", passDef.HalfRes, (ConfigDescription)null).Value }; } Harmony.PatchAll(); Log.LogInfo((object)("Plugin " + Name + " (io.github.kaycodes13.edgedetection) has loaded!")); } internal bool GetPassConfig(string id, out ConfigEntry colour, out ConfigEntry width, out ConfigEntry halfRes) { bool num = ((BaseUnityPlugin)this).Config.TryGetEntry(id, "Colour", ref colour) & ((BaseUnityPlugin)this).Config.TryGetEntry(id, "Width", ref width) & ((BaseUnityPlugin)this).Config.TryGetEntry(id, "Low Res", ref halfRes); if (!num) { Log.LogWarning((object)("Failed to load configuration for " + id + " pass.")); } return num; } public LocalizedText ModMenuName() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return LocalizedText.op_Implicit(MenuUtils.Localized("EDGE_DETECTION")); } public AbstractMenuScreen BuildCustomMenu() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown ScrollingMenuScreen val = new ScrollingMenuScreen(ModMenuName()); val.AddRange(EdgeDetectionPass.Passes.SelectMany, MenuElement>((KeyValuePair x) => GenerateDetectorOptions(x.Value))); return (AbstractMenuScreen)val; } private IEnumerable GenerateDetectorOptions(EdgeDetectionPass pass) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0068: 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) //IL_0075: Expected O, but got Unknown //IL_007a: 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_00ab: Unknown result type (might be due to invalid IL or missing references) TextLabel val = new TextLabel(LocalizedText.op_Implicit(MenuUtils.Localized(pass.Id + "_NAME"))); ((MenuElement)val).SetFontSizes((FontSizes)2); val.Text.fontStyle = (FontStyle)2; RectTransform rectTransform = ((MenuElement)val).RectTransform; Vector2 sizeDelta = ((MenuElement)val).RectTransform.sizeDelta; sizeDelta.y = 105f; rectTransform.sizeDelta = sizeDelta; ColorInput val2 = new ColorInput(LocalizedText.op_Implicit(MenuUtils.Localized("LINE_COLOUR_LABEL"))) { Format = (InputFormat)6 }; WiderSliderElement widerSliderElement = new WiderSliderElement(LocalizedText.op_Implicit(MenuUtils.Localized("LINE_WIDTH_LABEL")), (SliderModel)(object)new ByteSliderModel(0, 16)); ChoiceElement val3 = new ChoiceElement(LocalizedText.op_Implicit(MenuUtils.Localized("HALF_RES_LABEL")), (IChoiceModel)(object)ChoiceModels.ForBool(), LocalizedText.op_Implicit(MenuUtils.Localized("HALF_RES_DESC"))); if (GetPassConfig(pass.Id, out ConfigEntry colour, out ConfigEntry width, out ConfigEntry halfRes)) { ConfigEntryFactoryExtensions.SynchronizeWith((SelectableValueElement)(object)val2, colour); ConfigEntryFactoryExtensions.SynchronizeWith((SelectableValueElement)(object)widerSliderElement, width); ConfigEntryFactoryExtensions.SynchronizeWith((SelectableValueElement)(object)val3, halfRes); } return new <>z__ReadOnlyArray((MenuElement[])(object)new MenuElement[4] { (MenuElement)val, (MenuElement)val2, (MenuElement)widerSliderElement, (MenuElement)val3 }); } } internal static class Utils { [SpecialName] public sealed class $1A716C91D2B72E1C13325FC88724110E { [SpecialName] public static class $FD985437AAE2EF705567DB8FF4C7DF30 { } [ExtensionMarker("$FD985437AAE2EF705567DB8FF4C7DF30")] internal void RotateVertices(Quaternion rotation) { throw new NotSupportedException(); } [ExtensionMarker("$FD985437AAE2EF705567DB8FF4C7DF30")] internal void RotateVertices(Quaternion rotation, Vector3 center) { throw new NotSupportedException(); } } internal static readonly Assembly asm = Assembly.GetExecutingAssembly(); internal static void ReadAsset(string path, Action action) { using Stream obj = asm.GetManifestResourceStream("EdgeDetection.Assets." + path); action(obj); } internal static T ReadJsonAsset(string path) { using StreamReader streamReader = new StreamReader(asm.GetManifestResourceStream("EdgeDetection.Assets." + path)); return JsonConvert.DeserializeObject(streamReader.ReadToEnd()); } internal static IEnumerable WalkHierarchy(IEnumerable roots) { foreach (Transform item in roots.SelectMany((GameObject x) => SelfAndWalkHierarchy(x))) { yield return item; } } internal static IEnumerable SelfAndWalkHierarchy(GameObject go) { yield return go.transform; foreach (Transform item in WalkHierarchy(go)) { yield return item; } } internal static IEnumerable WalkHierarchy(GameObject go) { foreach (Transform item in go.transform) { Transform t = item; yield return t; foreach (Transform item2 in WalkHierarchy(((Component)t).gameObject)) { yield return item2; } } } internal static void RotateVertices(this Mesh mesh, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) mesh.RotateVertices(rotation, Vector3.zero); } internal static void RotateVertices(this Mesh mesh, Quaternion rotation, Vector3 center) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) mesh.vertices = mesh.vertices.Select((Vector3 v) => rotation * (v - center) + center).ToArray(); mesh.RecalculateNormals(); mesh.RecalculateBounds(); } } } namespace EdgeDetection.Structs { [Serializable] internal record struct ObjectMods(HashSet HideViaLayer, Dictionary ChangeLayer, Dictionary ChangeAllLayers, HashSet HideFromDetectors, HashSet HideCollider, HashSet HideSubColliders, Dictionary VisualizeSprite) { public const PhysLayers HIDE_LAYER = (PhysLayers)18; public const int HIDE_LAYER_INT = 18; public readonly void Apply(Transform t) { Apply(((Component)t).gameObject); } public readonly void Apply(GameObject go) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected I4, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected I4, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) string text = CleanName(go); Dictionary changeLayer = ChangeLayer; if (changeLayer != null && changeLayer.TryGetValue(text, out var value)) { go.layer = (int)value; } Dictionary changeAllLayers = ChangeAllLayers; if (changeAllLayers != null && changeAllLayers.TryGetValue(text, out var value2)) { foreach (Transform item in Utils.SelfAndWalkHierarchy(go)) { if (Object.op_Implicit((Object)(object)((Component)item).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)item).GetComponent())) { ((Component)item).gameObject.layer = (int)value2; } } } HashSet hideViaLayer = HideViaLayer; if (hideViaLayer != null && hideViaLayer.Contains(text)) { go.layer = 18; } HashSet hideFromDetectors = HideFromDetectors; if (hideFromDetectors != null && hideFromDetectors.Contains(text)) { Extensions.AddComponentIfNotPresent(go).hideFromEdgeDetectors = true; } HashSet hideCollider = HideCollider; if (hideCollider != null && hideCollider.Contains(text)) { go.AddComponent(); } HashSet hideSubColliders = HideSubColliders; if (hideSubColliders != null && hideSubColliders.Contains(text)) { foreach (Transform item2 in Utils.WalkHierarchy(go)) { ((Component)item2).gameObject.AddComponent(); } } Dictionary visualizeSprite = VisualizeSprite; if (visualizeSprite != null && visualizeSprite.TryGetValue(text, out var value3)) { Extensions.AddComponentIfNotPresent(go).layer = value3; } } public static string CleanName(GameObject go) { return Regex.Replace(((Object)go).name, "\\s?\\([a-zA-Z0-9]+\\)", "").Trim(); } public static ObjectMods Union(ObjectMods one, ObjectMods two) { return new ObjectMods { HideViaLayer = MergeSet(one.HideViaLayer, two.HideViaLayer), HideFromDetectors = MergeSet(one.HideFromDetectors, two.HideFromDetectors), HideCollider = MergeSet(one.HideCollider, two.HideCollider), HideSubColliders = MergeSet(one.HideSubColliders, two.HideSubColliders), ChangeLayer = MergeDict(one.ChangeLayer, two.ChangeLayer), ChangeAllLayers = MergeDict(one.ChangeAllLayers, two.ChangeAllLayers), VisualizeSprite = MergeDict(one.VisualizeSprite, two.VisualizeSprite) }; static Dictionary MergeDict(Dictionary? a, Dictionary? b) { Dictionary dictionary = new Dictionary(); K key; V value; foreach (KeyValuePair item in a ?? new Dictionary()) { item.Deconstruct(out key, out value); K key2 = key; V value2 = value; dictionary.TryAdd(key2, value2); } foreach (KeyValuePair item2 in b ?? new Dictionary()) { item2.Deconstruct(out key, out value); K key3 = key; V value3 = value; dictionary.TryAdd(key3, value3); } return dictionary; } static HashSet MergeSet(HashSet? a, HashSet? b) { HashSet hashSet = new HashSet(); foreach (T item3 in (a ?? new HashSet()).Union(b ?? new HashSet())) { hashSet.Add(item3); } return hashSet; } } } [Serializable] internal record struct PassDef(string Id, Color Colour, byte Width, bool HalfRes, PhysLayers[] Layers, float Threshold, float ClipFar, float ClipNear, string ExcludePass); } namespace EdgeDetection.Patches { [HarmonyPatch] internal static class ApplyObjectMods { private static readonly ObjectMods genericMods = ObjectMods.Union(Utils.ReadJsonAsset("generic_modifications.json"), Utils.ReadJsonAsset("boss_modifications.json")); private static readonly HashSet colliderLayers = new HashSet { (PhysLayers)23, (PhysLayers)22, (PhysLayers)17, (PhysLayers)12 }; [HarmonyPatch(typeof(GameCameras), "Start")] [HarmonyPostfix] private static void SoKParticles(GameCameras __instance) { foreach (Transform item in Utils.WalkHierarchy(((Component)__instance.sceneParticles).gameObject)) { ((Component)item).gameObject.layer = 18; } foreach (Transform item2 in Utils.WalkHierarchy(((Component)((Component)__instance).transform.Find("Roar Wave Emitter")).gameObject)) { ((Component)item2).gameObject.layer = 18; } } [HarmonyPatch(typeof(GameManager), "Start")] [HarmonyPostfix] private static void OnSceneLoad() { SceneManager.activeSceneChanged -= SceneChangeHandler; SceneManager.activeSceneChanged += SceneChangeHandler; SceneManager.sceneLoaded -= SceneLoadHandler; SceneManager.sceneLoaded += SceneLoadHandler; static IEnumerator Coro(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)GameManager.SilentInstance) && !GameManager.instance.IsNonGameplayScene()) { for (int i = 0; i < 2; i++) { yield return null; } if (((Scene)(ref scene)).isLoaded) { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (Transform item in Utils.WalkHierarchy((IEnumerable)rootGameObjects)) { if (!ObjectVisualizer.IsVisualizer(item)) { ShowColliderHideParticles(item); } } foreach (Transform item2 in Utils.WalkHierarchy((IEnumerable)rootGameObjects)) { if (!ObjectVisualizer.IsVisualizer(item2)) { genericMods.Apply(item2); } } } } } static void SceneChangeHandler(Scene _, Scene scene) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)EdgeDetectionPlugin.Inst).StartCoroutine(Coro(scene)); } static void SceneLoadHandler(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)mode == 1) { ((MonoBehaviour)EdgeDetectionPlugin.Inst).StartCoroutine(Coro(scene)); } } } [HarmonyPatch(typeof(ObjectPool), "Spawn", new Type[] { typeof(GameObject), typeof(Transform), typeof(Vector3), typeof(Quaternion), typeof(bool) })] [HarmonyPostfix] private static void OnObjectSpawned(GameObject __result) { foreach (Transform item in Utils.SelfAndWalkHierarchy(__result)) { ShowColliderHideParticles(item); genericMods.Apply(item); } } [HarmonyPatch(typeof(HeroController), "Awake")] [HarmonyPostfix] private static void OnHeroAwake(HeroController __instance) { ObjectMods objectMods = Utils.ReadJsonAsset("hornet_modifications.json"); foreach (Transform item in Utils.WalkHierarchy(((Component)__instance).gameObject)) { ShowColliderHideParticles(item); objectMods.Apply(item); } } private static void ShowColliderHideParticles(Transform t) { //IL_000d: 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) GameObject gameObject = ((Component)t).gameObject; PhysLayers item = (PhysLayers)gameObject.layer; Renderer component = gameObject.GetComponent(); if (!Object.op_Implicit((Object)(object)gameObject.GetComponent())) { if (component is ParticleSystemRenderer) { gameObject.layer = 18; } else { if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)gameObject.GetComponent())) { return; } foreach (Transform item2 in Utils.SelfAndWalkHierarchy(gameObject)) { if (Object.op_Implicit((Object)(object)((Component)item2).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)t).GetComponent())) { ((Component)item2).gameObject.layer = 19; } } } } else if (!Object.op_Implicit((Object)(object)component) && (Object.op_Implicit((Object)(object)gameObject.GetComponent()) || colliderLayers.Contains(item))) { Extensions.AddComponentIfNotPresent(gameObject); } } } [HarmonyPatch(typeof(GameCameras), "Start")] internal static class CameraSetup { private static void Postfix(GameCameras __instance) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) PassDef[] passDefs = EdgeDetectionPlugin.PassDefs; for (int i = 0; i < passDefs.Length; i++) { PassDef passDef = passDefs[i]; EdgeDetectionPass detector = ((Component)__instance.mainCamera).gameObject.AddComponent(); EdgeDetectionPass edgeDetectionPass = detector; EdgeDetectionPass edgeDetectionPass2 = detector; EdgeDetectionPass edgeDetectionPass3 = detector; EdgeDetectionPass edgeDetectionPass4 = detector; EdgeDetectionPass edgeDetectionPass5 = detector; EdgeDetectionPass edgeDetectionPass6 = detector; EdgeDetectionPass edgeDetectionPass7 = detector; EdgeDetectionPass edgeDetectionPass8 = detector; EdgeDetectionPass edgeDetectionPass9 = detector; PassDef passDef2 = passDef; (edgeDetectionPass.Id, edgeDetectionPass2.LineColor, edgeDetectionPass3.LineWidth, edgeDetectionPass4.HalfResolution, edgeDetectionPass5.Layers, edgeDetectionPass6.AlphaThreshold, edgeDetectionPass7.ClipFar, edgeDetectionPass8.ClipNear, edgeDetectionPass9.ExcludePass) = (PassDef)(ref passDef2); if (EdgeDetectionPlugin.Inst.GetPassConfig(passDef.Id, out ConfigEntry colour, out ConfigEntry width, out ConfigEntry halfRes)) { colour.SettingChanged += delegate(object _, EventArgs e) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) detector.LineColor = GetValue(e); }; width.SettingChanged += delegate(object _, EventArgs e) { detector.LineWidth = GetValue(e); }; halfRes.SettingChanged += delegate(object _, EventArgs e) { detector.HalfResolution = GetValue(e); }; } } static T GetValue(EventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (T)((SettingChangedEventArgs)e).ChangedSetting.BoxedValue; } } } } namespace EdgeDetection.Menu { internal class ByteSliderModel : SliderModel { public ByteSliderModel(byte min, byte max) : base((int)min, (int)max) { } protected override bool GetIndex(byte value, out int index) { index = value; if (base.MinimumIndex <= index) { return index <= base.MaximumIndex; } return false; } protected override byte GetValue(int index) { return (byte)Math.Clamp(index, 0, 255); } } internal static class MenuUtils { [SpecialName] public sealed class $1945437846AC44BD79BE419C90BB2AE7 { [SpecialName] public static class $D30A0C6AD6B3A0DECA793BBD3009BA46 { } [ExtensionMarker("$D30A0C6AD6B3A0DECA793BBD3009BA46")] internal RectTransform AsRect { [ExtensionMarker("$D30A0C6AD6B3A0DECA793BBD3009BA46")] get { throw new NotSupportedException(); } } [ExtensionMarker("$D30A0C6AD6B3A0DECA793BBD3009BA46")] internal void SetAnchors(Vector2 anchor) { throw new NotSupportedException(); } } internal static LocalisedString Localized(string key) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return new LocalisedString("Mods.io.github.kaycodes13.edgedetection", key); } internal static RectTransform get_AsRect(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown return (RectTransform)t; } internal static void SetAnchors(this Transform t, Vector2 anchor) { //IL_000c: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = get_AsRect(t); Vector2 anchorMax = (get_AsRect(t).anchorMin = anchor); obj.anchorMax = anchorMax; } } internal class WiderSliderElement : SliderElement { public WiderSliderElement(LocalizedText label, SliderModel model) : base(label, model) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_01ea: Unknown result type (might be due to invalid IL or missing references) Vector2 anchor = default(Vector2); ((Vector2)(ref anchor))..ctor(1f, 0.5f); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 0.5f); Vector2 anchorMax = default(Vector2); ((Vector2)(ref anchorMax))..ctor(0.5f, 1f); Vector2 anchorMin = default(Vector2); ((Vector2)(ref anchorMin))..ctor(0.5f, 0f); Vector2 anchor2 = Vector2.one * 0.5f; RectTransform obj = MenuUtils.get_AsRect(((Transform)((MenuElement)this).RectTransform).Find("Slider")); RectTransform val2 = MenuUtils.get_AsRect(((Transform)obj).Find("Menu Option Label")); RectTransform val3 = MenuUtils.get_AsRect(((Transform)obj).Find("CursorHotspot")); RectTransform val4 = MenuUtils.get_AsRect(((Transform)val3).Find("CursorLeft")); RectTransform val5 = MenuUtils.get_AsRect(((Transform)val3).Find("CursorRight")); RectTransform rectTransform = ((MenuElement)this).RectTransform; Vector2 sizeDelta = ((MenuElement)this).RectTransform.sizeDelta; sizeDelta.x = 720f; rectTransform.sizeDelta = sizeDelta; ((Transform)(object)((MenuElement)this).RectTransform).SetAnchors(anchor2); RectTransform rectTransform2 = ((MenuElement)this).RectTransform; sizeDelta = ((MenuElement)this).RectTransform.anchoredPosition; sizeDelta.x = 0f; rectTransform2.anchoredPosition = sizeDelta; ((Transform)(object)obj).SetAnchors(anchor); obj.anchoredPosition = Vector2.zero; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.pivot = val; val2.anchoredPosition = new Vector2(0f - 2f * ((MenuElement)this).RectTransform.offsetMax.x - 91f, 0f); val3.anchorMax = anchorMax; val3.anchorMin = anchorMin; val3.anchoredPosition = new Vector2(((MenuElement)this).RectTransform.offsetMin.x, 0f); val3.sizeDelta = new Vector2(1000f + ((MenuElement)this).RectTransform.offsetMax.x, 0f); ((Transform)(object)val4).SetAnchors(val); val4.anchoredPosition = Vector2.zero; ((Transform)(object)val5).SetAnchors(anchor); val5.anchoredPosition = Vector2.zero; base.ValueText.alignByGeometry = true; } } } namespace EdgeDetection.Components { internal class ColliderVisualizer : ObjectVisualizer { private Collider2D collider; private Lever? lever; private Vector3 origScale; private Mesh mesh; private static readonly Shader shader = Shader.Find("Sprites/Default"); private static readonly Type[] validTriggerTypes = new Type[3] { typeof(BouncePod), typeof(BounceBalloon), typeof(DamageHero) }; protected override void InitDupe() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown ((Object)base.Dupe).name = ((Object)((Component)this).gameObject).name + " Collider"; origScale = ((Component)this).transform.lossyScale; lever = ((Component)((Component)this).transform).GetComponent(); collider = ((Component)((Component)this).transform).GetComponent(); if (!Object.op_Implicit((Object)(object)collider) || (collider.isTrigger && !IsTriggerVisualizable(collider))) { return; } Object.Destroy((Object)(object)mesh); mesh = collider.CreateMesh(true, true, true); if (Object.op_Implicit((Object)(object)mesh)) { mesh.vertices = mesh.vertices.Select((Vector3 v) => v - ((Component)this).transform.position).ToArray(); mesh.RotateVertices(Quaternion.Inverse(((Component)this).transform.rotation)); mesh.colors = Enumerable.Repeat(Color.white, mesh.vertexCount).ToArray(); if (Object.op_Implicit((Object)(object)((Component)((Component)this).transform).GetComponent())) { base.Dupe.layer = 11; } else { base.Dupe.layer = ((Component)this).gameObject.layer; } base.Dupe.AddComponent().mesh = mesh; ((Renderer)base.Dupe.AddComponent()).material = new Material(shader); base.Dupe.AddComponent().hideFromMain = true; } } protected override void UpdateDupe() { //IL_0053: 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) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)mesh)) { InitDupe(); } else if (!((Behaviour)collider).enabled || (Object.op_Implicit((Object)(object)lever) && lever.hitBlocked)) { base.Dupe.SetActive(false); } else { base.Dupe.transform.localScale = Vector3.Scale(Vector3.one, Extensions.DivideElements(((Component)this).transform.lossyScale, origScale)); } } protected override void DestroyDupe() { Object.Destroy((Object)(object)mesh); } private static bool IsTriggerVisualizable(Collider2D collider) { if (!validTriggerTypes.Any((Type x) => Object.op_Implicit((Object)(object)((Component)collider).GetComponent(x)))) { PlayMakerFSM val = default(PlayMakerFSM); if (((Component)collider).TryGetComponent(ref val)) { return val.FsmName == "hornet_multi_wounder"; } return false; } return true; } } [RequireComponent(typeof(Camera))] [RequireComponent(typeof(CameraShakeManager))] public class EdgeDetectionPass : MonoBehaviour { [CompilerGenerated] private string k__BackingField = ""; [CompilerGenerated] private byte k__BackingField = 1; [CompilerGenerated] private PhysLayers[] k__BackingField = (PhysLayers[])(object)new PhysLayers[1] { (PhysLayers)9 }; private int layerMask = LayerMask.GetMask(new string[1] { LayerMask.LayerToName(9) }); [CompilerGenerated] private float k__BackingField = 0.4f; [CompilerGenerated] private float k__BackingField = 1.8f; [CompilerGenerated] private float k__BackingField = 1.8f; [CompilerGenerated] private string k__BackingField = ""; internal static readonly Dictionary Passes = new Dictionary(); internal const byte WIDTH_MIN = 0; internal const byte WIDTH_MAX = 16; private Material edgeMat; private Camera mainCam; private Camera detectorCam; private CameraShakeManager mainShaker; private CameraShakeManager detectorShaker; private static readonly int thresholdID = Shader.PropertyToID("_AlphaThreshold"); private static readonly int lineColorID = Shader.PropertyToID("_LineColor"); private static readonly int sceneTexID = Shader.PropertyToID("_SceneTex"); private static readonly int subtractTexID = Shader.PropertyToID("_SubtractTex"); private const int SILHOUETTE_PASS = 0; private const int DETECT_PASS = 1; private const int COMPOSITE_PASS = 2; public string Id { get { return k__BackingField; } set { if (k__BackingField != value) { if (Passes.ContainsKey(value)) { throw new InvalidOperationException("The Id must be unique."); } Passes.Remove(k__BackingField); Passes.TryAdd(value, this); k__BackingField = value; } } } public Color LineColor { get; set; } = Color.white; public byte LineWidth { get { return k__BackingField; } set { k__BackingField = Math.Clamp(value, (byte)0, (byte)16); } } public PhysLayers[] Layers { get { return k__BackingField; } set { k__BackingField = value; layerMask = LayerMask.GetMask(k__BackingField.Select((PhysLayers x) => LayerMask.LayerToName((int)x)).ToArray()); } } public bool HalfResolution { get; set; } public float AlphaThreshold { get { return k__BackingField; } set { k__BackingField = Mathf.Clamp01(value); } } public float ClipFar { get { return k__BackingField; } set { k__BackingField = Mathf.Max(0f, value); } } public float ClipNear { get { return k__BackingField; } set { k__BackingField = Mathf.Max(0f, value); } } public string ExcludePass { get { return k__BackingField; } set { k__BackingField = value ?? ""; } } private void Start() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown Passes.TryAdd(Id, this); mainCam = ((Component)this).GetComponent(); GameObject val = new GameObject(Id + " Edge Detection Camera"); Extensions.SetParentReset(val.transform, ((Component)this).transform); detectorCam = Extensions.AddComponentIfNotPresent(val); ((Behaviour)detectorCam).enabled = false; mainShaker = ((Component)this).GetComponent(); detectorShaker = Extensions.AddComponentIfNotPresent(val); mainShaker.CopyTo(val); val.AddComponent().Settings = this; edgeMat = new Material(EdgeDetectionPlugin.EdgeDetectionShader); } private void OnDestroy() { Object.DestroyImmediate((Object)(object)((Component)detectorCam).gameObject); Object.DestroyImmediate((Object)(object)edgeMat); Passes.Remove(Id); } private void OnRenderImage(RenderTexture source, RenderTexture destination) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (LineWidth < 1) { Graphics.Blit((Texture)(object)source, destination); return; } int num = ((!HalfResolution) ? 1 : 2); int width = ((Texture)source).width / num; int height = ((Texture)source).height / num; RenderTexture[] emptyTemporaryTextures; if (TryGetExcludePass(out EdgeDetectionPass other)) { emptyTemporaryTextures = GetEmptyTemporaryTextures(3, width, height); other.RenderSilhouette(emptyTemporaryTextures[2]); edgeMat.SetTexture(subtractTexID, (Texture)(object)emptyTemporaryTextures[2]); } else { emptyTemporaryTextures = GetEmptyTemporaryTextures(2, width, height); edgeMat.SetTexture(subtractTexID, (Texture)(object)Texture2D.blackTexture); } edgeMat.SetColor(lineColorID, LineColor); edgeMat.SetTexture(sceneTexID, (Texture)(object)source); RenderSilhouette(emptyTemporaryTextures[0]); for (int i = 0; i < LineWidth; i++) { Graphics.Blit((Texture)(object)emptyTemporaryTextures[0], emptyTemporaryTextures[1], edgeMat, 1); RenderTexture[] array = emptyTemporaryTextures; RenderTexture[] array2 = emptyTemporaryTextures; RenderTexture val = emptyTemporaryTextures[1]; RenderTexture val2 = emptyTemporaryTextures[0]; array[0] = val; array2[1] = val2; } Graphics.Blit((Texture)(object)emptyTemporaryTextures[0], destination, edgeMat, 2); for (int j = 0; j < emptyTemporaryTextures.Length; j++) { RenderTexture.ReleaseTemporary(emptyTemporaryTextures[j]); } } internal void RenderSilhouette(RenderTexture output) { //IL_0023: 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_009c: Unknown result type (might be due to invalid IL or missing references) detectorCam.CopyFrom(mainCam); detectorCam.clearFlags = (CameraClearFlags)2; detectorCam.backgroundColor = Color.clear; detectorCam.cullingMask = layerMask; if ((Object)(object)detectorShaker.cameraTypeReference != (Object)(object)mainShaker.cameraTypeReference) { mainShaker.CopyTo(((Component)detectorCam).gameObject); } if (Object.op_Implicit((Object)(object)HeroController.instance)) { float num = HeroController.instance.transform.position.z - ((Component)detectorCam).transform.position.z; detectorCam.farClipPlane = num + ClipFar; detectorCam.nearClipPlane = num - ClipNear; } else { detectorCam.farClipPlane = 42f; detectorCam.nearClipPlane = 38f; } RenderTexture val = GetEmptyTemporaryTextures(1, ((Texture)output).width, ((Texture)output).height)[0]; detectorCam.targetTexture = val; detectorCam.Render(); edgeMat.SetFloat(thresholdID, AlphaThreshold); Graphics.Blit((Texture)(object)val, output, edgeMat, 0); detectorCam.targetTexture = null; RenderTexture.ReleaseTemporary(val); } private bool TryGetExcludePass(out EdgeDetectionPass other) { other = null; if (ExcludePass != "" && ExcludePass != Id) { return Passes.TryGetValue(ExcludePass, out other); } return false; } private static RenderTexture[] GetEmptyTemporaryTextures(int count, int width, int height) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) RenderTexture[] array = (RenderTexture[])(object)new RenderTexture[count]; RenderTexture active = RenderTexture.active; for (int i = 0; i < count; i++) { array[i] = RenderTexture.GetTemporary(width, height, 32, (RenderTextureFormat)0); RenderTexture.active = array[i]; GL.Clear(true, true, Color.clear); } RenderTexture.active = active; return array; } } [RequireComponent(typeof(Camera))] public class EdgeDetector : MonoBehaviour { public EdgeDetectionPass Settings { get; internal set; } } [RequireComponent(typeof(Renderer))] public class HideFromCamera : MonoBehaviour { public bool hideFromMain; public bool hideFromEdgeDetectors; public readonly HashSet filteredCameras = new HashSet(); private Renderer rend; private void Start() { rend = ((Component)this).GetComponent(); } private void OnDisable() { SetVisible(value: true); } private void OnWillRenderObject() { SetVisible(value: true); if ((hideFromMain && (Object)(object)Camera.current == (Object)(object)GameCameras.instance.mainCamera) || (hideFromEdgeDetectors && Object.op_Implicit((Object)(object)((Component)Camera.current).GetComponent())) || filteredCameras.Contains(Camera.current)) { SetVisible(value: false); } } private void SetVisible(bool value) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)rend)) { Start(); } if (Object.op_Implicit((Object)(object)rend)) { Color color = (value ? Color.white : Color.clear); if (Object.op_Implicit((Object)(object)rend.sharedMaterial)) { rend.sharedMaterial.color = color; } else if (Object.op_Implicit((Object)(object)rend.material)) { rend.material.color = color; } } } } internal abstract class ObjectVisualizer : MonoBehaviour { private static GameObject dupeParent; protected GameObject Dupe { get; private set; } private void Start() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown if (IsVisualizer(((Component)this).gameObject)) { Object.Destroy((Object)(object)this); return; } if (!Object.op_Implicit((Object)(object)dupeParent)) { dupeParent = new GameObject("Edge Detection Visualizers"); Object.DontDestroyOnLoad((Object)(object)dupeParent); Extensions.Reset(dupeParent.transform); } if (!Object.op_Implicit((Object)(object)Dupe)) { Dupe = new GameObject(); Extensions.SetParentReset(Dupe.transform, dupeParent.transform); InitDupe(); } } private void OnEnable() { Start(); if (Object.op_Implicit((Object)(object)Dupe) && ((Component)this).gameObject.activeInHierarchy) { Dupe.SetActive(true); } } private void Update() { //IL_0058: 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_007e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Dupe)) { Start(); } if (Object.op_Implicit((Object)(object)Dupe)) { if (!((Component)this).gameObject.activeInHierarchy) { Dupe.SetActive(false); return; } Dupe.SetActive(true); Dupe.transform.SetPositionAndRotation(((Component)this).transform.position, ((Component)this).transform.rotation); Dupe.transform.localScale = ((Component)this).transform.lossyScale; UpdateDupe(); } } private void OnDisable() { if (Object.op_Implicit((Object)(object)Dupe)) { Dupe.SetActive(false); } } private void OnDestroy() { DestroyDupe(); Object.Destroy((Object)(object)Dupe); } public static bool IsVisualizer(GameObject go) { return IsVisualizer(go.transform); } public static bool IsVisualizer(Transform t) { if (Object.op_Implicit((Object)(object)dupeParent)) { if (!((Object)(object)t == (Object)(object)dupeParent.transform)) { return (Object)(object)t.parent == (Object)(object)dupeParent.transform; } return true; } return false; } protected abstract void InitDupe(); protected abstract void UpdateDupe(); protected abstract void DestroyDupe(); } internal class RemoveColliderVisualizer : MonoBehaviour { private const int MAX_TRIES = 10; private int tries; private void Awake() { TryRemove(); } private void Start() { TryRemove(); } private void Update() { TryRemove(); } private void TryRemove() { tries++; ColliderVisualizer colliderVisualizer = default(ColliderVisualizer); if (((Component)this).TryGetComponent(ref colliderVisualizer)) { Object.Destroy((Object)(object)colliderVisualizer); Object.Destroy((Object)(object)this); } if (tries > 10) { Object.Destroy((Object)(object)this); } } } internal class SpriteVisualizer : ObjectVisualizer { public PhysLayers layer; private SpriteRenderer sprite; private SpriteRenderer dupeSprite; private tk2dSprite tk2d; private tk2dSprite dupeTk2d; private MeshRenderer dupeMesh; private Material dupeMat; protected override void InitDupe() { ((Object)base.Dupe).name = ((Object)((Component)this).gameObject).name + " Sprite"; if (((Component)this).TryGetComponent(ref sprite)) { dupeSprite = base.Dupe.AddComponent(); ((Renderer)dupeSprite).materials = ((IEnumerable)((Renderer)sprite).materials).Select((Func)((Material x) => new Material(x.shader))).ToArray(); } else if (((Component)this).TryGetComponent(ref tk2d)) { base.Dupe.AddComponent(); dupeMesh = base.Dupe.AddComponent(); dupeTk2d = base.Dupe.AddComponent(); } if (Object.op_Implicit((Object)(object)sprite) || Object.op_Implicit((Object)(object)tk2d)) { base.Dupe.AddComponent().hideFromMain = true; } } protected override void UpdateDupe() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected I4, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f1: Expected O, but got Unknown //IL_00f6: Expected O, but got Unknown base.Dupe.layer = (int)layer; if (Object.op_Implicit((Object)(object)sprite)) { dupeSprite.sprite = sprite.sprite; dupeSprite.flipX = sprite.flipX; dupeSprite.flipY = sprite.flipY; } else if (Object.op_Implicit((Object)(object)tk2d) && ((tk2dBaseSprite)tk2d).CurrentSprite != ((tk2dBaseSprite)dupeTk2d).CurrentSprite) { if (Object.op_Implicit((Object)(object)dupeMat)) { Object.Destroy((Object)(object)dupeMat); } ((tk2dBaseSprite)dupeTk2d).scale = ((tk2dBaseSprite)tk2d).scale; ((tk2dBaseSprite)dupeTk2d).SetSprite(((tk2dBaseSprite)tk2d).collection, ((tk2dBaseSprite)tk2d).spriteId); MeshRenderer obj = dupeMesh; Material val = new Material(((Renderer)dupeMesh).material); Material material = val; dupeMat = val; ((Renderer)obj).material = material; } } protected override void DestroyDupe() { Object.Destroy((Object)(object)dupeMat); } } }