using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks.CompilerServices; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using Microsoft.CodeAnalysis; using TerrainScanner.DS; using UnityEngine; using UnityEngine.LowLevel; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.Rendering.RenderGraphModule; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("d542Bb.TerrainScanner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.5.0")] [assembly: AssemblyInformationalVersion("1.1.5+4802b9a0a0130f54e81e3f9e008a6d189a4c17df")] [assembly: AssemblyProduct("d542Bb.TerrainScanner")] [assembly: AssemblyTitle("TerrainScanner")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } 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; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] 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")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace TerrainScanner { public class ScanConfig { public RenderPassEvent renderEvent = (RenderPassEvent)450; public Material scanMaterial; public Color scanColorHead = new Color(0.054901965f, 29f / 51f, 0.85098046f, 1f); public Color scanColor = new Color(0.38823533f, 0.7372549f, 0.8705883f, 1f); public float outlineWidth = 1f; public float scanLineWidth = 1f; public float scanLineInterval = 1.5f; public float headScanLineWidth = 2f; public float scanLineBrightness = 2.5f; public float scanRange = 10f; public float outlineBrightness = 1.32f; public float headScanLineDistance = 15f; public Vector3 scanCenterWS = new Vector3(123.05f, 36.3f, 147.86f); public float outlineStarDistance = 30f; public Material markMaterial; public GameObject markParticle3; public GameObject markParticle2; public GameObject markParticle1; public float steepSpawnProb = 0.1f; public float midSpawnProb = 0.3f; public float flatSpawnProb = 0.0002f; public float sampling_maxDistanceShort = 30f; public float sampling_maxDistanceLong = 60f; public float sampling_centerShapeExponent = 0.75f; public float sampling_centerColumnThreshold = 0.25f; public float sampling_forwardOffset = 1f; public float sampling_jitterScale = 0.06f; public float sampling_rowStepMultiplier = 0.9f; public float sampling_originHeightOffset = 10f; public int horizontalCount = 40; public int verticalCount = 50; public float gridStep = 0.5f; public float scanCooldown = 0.8f; public float sfxVolume = 1f; public float markIconSize = 1f; public Color markSafeColor = new Color(0.3f, 1f, 1f, 1f); public Color markWarningColor = new Color(1f, 1f, 0f, 1f); public Color markDangerColor = new Color(1f, 0f, 0f, 1f); public float animHeadScanLineDistance = 400f; public float animScanRange = 5f; public float animOutlineStarDistance = 30f; public float animScanLineBrightnessPeak = 1f; public float animHeadScanLineBrightnessPeak = 1f; public float animOutlineBrightnessPeak = 1f; public KeyCode activeKey = (KeyCode)102; public ConfigEntry cfgScanColorHead; public ConfigEntry cfgScanColor; public ConfigEntry cfgOutlineWidth; public ConfigEntry cfgScanLineWidth; public ConfigEntry cfgScanLineInterval; public ConfigEntry cfgHeadScanLineWidth; public ConfigEntry cfgScanLineBrightness; public ConfigEntry cfgScanRange; public ConfigEntry cfgOutlineBrightness; public ConfigEntry cfgHeadScanLineDistance; public ConfigEntry cfgScanCenterWS; public ConfigEntry cfgOutlineStarDistance; public ConfigEntry cfgHorizontalCount; public ConfigEntry cfgVerticalCount; public ConfigEntry cfgScanCooldown; public ConfigEntry cfgSfxVolume; public ConfigEntry cfgMarkIconSize; public ConfigEntry cfgMarkSafeColor; public ConfigEntry cfgMarkWarningColor; public ConfigEntry cfgMarkDangerColor; public ConfigEntry cfgAnimHeadScanLineDistance; public ConfigEntry cfgAnimScanRange; public ConfigEntry cfgAnimOutlineStarDistance; public ConfigEntry cfgAnimScanLineBrightnessPeak; public ConfigEntry cfgAnimHeadScanLineBrightnessPeak; public ConfigEntry cfgAnimOutlineBrightnessPeak; public ConfigEntry cfgActiveKey; private bool _bound; public void Bind(BaseUnityPlugin plugin, Action onChanged = null) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)plugin == (Object)null || _bound) { return; } _bound = true; ConfigFile config = plugin.Config; cfgActiveKey = config.Bind("Controls", "ActiveScanKey", activeKey, "作用: 按下触发一次扫描的按键。\nEffect: Key that triggers an active scan.\n合法值例子(Example values): Q / F / V(Unity KeyCode 键名)."); cfgScanColorHead = config.Bind("Style", "ScanColorHead", scanColorHead.r + "," + scanColorHead.g + "," + scanColorHead.b + "," + scanColorHead.a, "作用: 扫描头部颜色(RGBA 四通道 0-1)。\nEffect: Scan head color as r,g,b,a.\n合法值例子(Example values): 0.05,0.57,0.85,1 / 1,1,1,1"); cfgScanColor = config.Bind("Style", "ScanColor", scanColor.r + "," + scanColor.g + "," + scanColor.b + "," + scanColor.a, "作用: 扫描主体颜色(RGBA 四通道 0-1)。\nEffect: Scan body color as r,g,b,a.\n合法值例子(Example values): 0.39,0.74,0.87,1 / 0,1,0,1"); cfgOutlineWidth = config.Bind("Style", "OutlineWidth", outlineWidth, "作用: 扫描轮廓线宽度。\nEffect: Width of the scan outline.\n合法值例子(Example values): 1.0 / 2.48 / 5.0(float,>0)"); cfgScanLineWidth = config.Bind("Style", "ScanLineWidth", scanLineWidth, "作用: 扫描线宽度。\nEffect: Width of the scan line.\n合法值例子(Example values): 0.5 / 1 / 2.5(float,>0)"); cfgScanLineInterval = config.Bind("Style", "ScanLineInterval", scanLineInterval, "作用: 扫描线之间的间隔。\nEffect: Interval between scan lines.\n合法值例子(Example values): 0.5 / 1 / 2(float,>0)"); cfgHeadScanLineWidth = config.Bind("Style", "HeadScanLineWidth", headScanLineWidth, "作用: 扫描头部线宽度。\nEffect: Width of the head scan line.\n合法值例子(Example values): 0.5 / 1 / 2(float,>0)"); cfgScanLineBrightness = config.Bind("Style", "ScanLineBrightness", scanLineBrightness, "作用: 扫描线亮度。\nEffect: Brightness of the scan line.\n合法值例子(Example values): 0.5 / 2.5 / 5(float,>0)"); cfgScanRange = config.Bind("Style", "ScanRange", scanRange, "作用: 扫描作用范围。\nEffect: Scan reach/range.\n合法值例子(Example values): 3 / 5 / 10(float,>0)"); cfgOutlineBrightness = config.Bind("Style", "OutlineBrightness", outlineBrightness, "作用: 扫描轮廓亮度。\nEffect: Brightness of the outline.\n合法值例子(Example values): 0.5 / 1.32 / 3(float,>0)"); cfgHeadScanLineDistance = config.Bind("Style", "HeadScanLineDistance", headScanLineDistance, "作用: 扫描头部线距离。\nEffect: Distance of the head scan line.\n合法值例子(Example values): 5 / 13.2 / 30(float,>0)"); cfgScanCenterWS = config.Bind("Style", "ScanCenterWS", scanCenterWS.x + "," + scanCenterWS.y + "," + scanCenterWS.z, "作用: 扫描中心的世界坐标(x,y,z)。\nEffect: Scan center world-space as x,y,z.\n合法值例子(Example values): 123.05,36.3,147.86 / 0,10,0"); cfgOutlineStarDistance = config.Bind("Style", "OutlineStarDistance", outlineStarDistance, "作用: 轮廓星标距离。\nEffect: Outline 'star' distance.\n合法值例子(Example values): 10 / 30 / 60(float,>0)"); cfgHorizontalCount = config.Bind("Performance", "HorizontalCount", horizontalCount, "作用: 相机视锥截面横向样本数量(采样分辨率)。\nEffect: Number of horizontal samples across the camera frustum.\n合法值例子(Example values): 10 / 40 / 80(int,>=1)"); cfgVerticalCount = config.Bind("Performance", "VerticalCount", verticalCount, "作用: 相机视锥截面纵向样本数量(采样分辨率)。\nEffect: Number of vertical samples across the camera frustum.\n合法值例子(Example values): 20 / 50 / 100(int,>=1)"); cfgScanCooldown = config.Bind("Performance", "ScanCooldown", scanCooldown, "作用: 扫描触发冷却(秒),扫描效果与扫描音效共用此冷却,冷却期间不可重复触发。\nEffect: Trigger cooldown in seconds, shared by the scan effect and its sfx.\n合法值例子(Example values): 0.3 / 0.8 / 2.0(float,>0)"); cfgSfxVolume = config.Bind("Style", "SfxVolume", sfxVolume, "作用: 扫描音效播放音量。\nEffect: Playback volume of the scan sfx.\n合法值例子(Example values): 0 / 0.5 / 1(float,0-1)"); cfgMarkIconSize = config.Bind("Style", "MarkIconSize", markIconSize, "作用: 地形标记(白点/红叉)图标的整体大小缩放。\nEffect: Overall size scale of terrain mark icons.\n合法值例子(Example values): 0.5 / 0.8 / 1(float,>0)"); cfgMarkSafeColor = config.Bind("Style", "MarkSafeColor", markSafeColor.r + "," + markSafeColor.g + "," + markSafeColor.b + "," + markSafeColor.a, "作用: 可站立标记(白点)颜色(RGBA 0-1,0-1)。\nEffect: Safe point color as r,g,b,a.\n合法值例子(Example values): 1,1,1,1 / 0.5,0.9,0.6,1(float)"); cfgMarkWarningColor = config.Bind("Style", "MarkWarningColor", markWarningColor.r + "," + markWarningColor.g + "," + markWarningColor.b + "," + markWarningColor.a, "作用: 警戒标记(黄)颜色(RGBA 0-1,0-1)。\nEffect: Warning point color as r,g,b,a.\n合法值例子(Example values): 1,1,0,1 / 1,0.6,0,1(float)"); cfgMarkDangerColor = config.Bind("Style", "MarkDangerColor", markDangerColor.r + "," + markDangerColor.g + "," + markDangerColor.b + "," + markDangerColor.a, "作用: 不可站立标记(红叉)颜色(RGBA 0-1,0-1)。\nEffect: Danger mark color as r,g,b,a.\n合法值例子(Example values): 1,0,0,1 / 0.9,0.2,0.3,1(float)"); cfgAnimHeadScanLineDistance = config.Bind("Style", "AnimHeadScanLineDistance", animHeadScanLineDistance, "作用: 扫描线头部扩散的目标距离。⚠\ufe0f 不建议修改(高级调试)。\nEffect: Target spread distance of the head scan line.\n合法值例子(Example values): 200 / 250 / 300(float,>0)"); cfgAnimScanRange = config.Bind("Style", "AnimScanRange", animScanRange, "作用: 扫描波范围目标。⚠\ufe0f 不建议修改(高级调试)。\nEffect: Target range of the scan wave.\n合法值例子(Example values): 3 / 5 / 8(float,>0)"); cfgAnimOutlineStarDistance = config.Bind("Style", "AnimOutlineStarDistance", animOutlineStarDistance, "作用: 描边距离带目标。⚠\ufe0f 不建议修改(高级调试)。\nEffect: Target outline star distance.\n合法值例子(Example values): 20 / 30 / 40(float,>0)"); cfgAnimScanLineBrightnessPeak = config.Bind("Style", "AnimScanLineBrightnessPeak", animScanLineBrightnessPeak, "作用: 平行扫描线亮度峰值。⚠\ufe0f 不建议修改(高级调试)。\nEffect: Peak brightness of scan lines.\n合法值例子(Example values): 0.5 / 1 / 2(float,0+)"); cfgAnimHeadScanLineBrightnessPeak = config.Bind("Style", "AnimHeadScanLineBrightnessPeak", animHeadScanLineBrightnessPeak, "作用: 头部扫描线亮度峰值。⚠\ufe0f 不建议修改(高级调试)。\nEffect: Peak brightness of the head scan line.\n合法值例子(Example values): 0.5 / 1 / 2(float,0+)"); cfgAnimOutlineBrightnessPeak = config.Bind("Style", "AnimOutlineBrightnessPeak", animOutlineBrightnessPeak, "作用: 描边亮度峰值。⚠\ufe0f 不建议修改(高级调试)。\nEffect: Peak brightness of the outline.\n合法值例子(Example values): 0.5 / 1 / 2(float,0+)"); UpdateFromConfig(); try { cfgScanColorHead.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanColor.SettingChanged += delegate { UpdateFromConfig(); }; cfgOutlineWidth.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanLineWidth.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanLineInterval.SettingChanged += delegate { UpdateFromConfig(); }; cfgHeadScanLineWidth.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanLineBrightness.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanRange.SettingChanged += delegate { UpdateFromConfig(); }; cfgOutlineBrightness.SettingChanged += delegate { UpdateFromConfig(); }; cfgHeadScanLineDistance.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanCenterWS.SettingChanged += delegate { UpdateFromConfig(); }; cfgOutlineStarDistance.SettingChanged += delegate { UpdateFromConfig(); }; cfgHorizontalCount.SettingChanged += delegate { UpdateFromConfig(); }; cfgVerticalCount.SettingChanged += delegate { UpdateFromConfig(); }; cfgScanCooldown.SettingChanged += delegate { UpdateFromConfig(); }; cfgSfxVolume.SettingChanged += delegate { UpdateFromConfig(); }; cfgMarkIconSize.SettingChanged += delegate { UpdateFromConfig(); }; cfgMarkSafeColor.SettingChanged += delegate { UpdateFromConfig(); }; cfgMarkWarningColor.SettingChanged += delegate { UpdateFromConfig(); }; cfgMarkDangerColor.SettingChanged += delegate { UpdateFromConfig(); }; cfgAnimHeadScanLineDistance.SettingChanged += delegate { UpdateFromConfig(); }; cfgAnimScanRange.SettingChanged += delegate { UpdateFromConfig(); }; cfgAnimOutlineStarDistance.SettingChanged += delegate { UpdateFromConfig(); }; cfgAnimScanLineBrightnessPeak.SettingChanged += delegate { UpdateFromConfig(); }; cfgAnimHeadScanLineBrightnessPeak.SettingChanged += delegate { UpdateFromConfig(); }; cfgAnimOutlineBrightnessPeak.SettingChanged += delegate { UpdateFromConfig(); }; cfgActiveKey.SettingChanged += delegate { UpdateFromConfig(); }; } catch { } static Color ParseColor(string s) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) try { string[] array = s.Split(','); if (array.Length < 3) { return Color.blue; } float num = float.Parse(array[0]); float num2 = float.Parse(array[1]); float num3 = float.Parse(array[2]); float num4 = ((array.Length >= 4) ? float.Parse(array[3]) : 1f); return new Color(num, num2, num3, num4); } catch { return Color.blue; } } static Vector3 ParseVec(string s) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) try { string[] array = s.Split(','); if (array.Length < 3) { return Vector3.zero; } float num = float.Parse(array[0]); float num2 = float.Parse(array[1]); float num3 = float.Parse(array[2]); return new Vector3(num, num2, num3); } catch { return Vector3.zero; } } void UpdateFromConfig() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) try { scanColorHead = ParseColor(cfgScanColorHead.Value); scanColor = ParseColor(cfgScanColor.Value); outlineWidth = cfgOutlineWidth.Value; scanLineWidth = cfgScanLineWidth.Value; scanLineInterval = cfgScanLineInterval.Value; headScanLineWidth = cfgHeadScanLineWidth.Value; scanLineBrightness = cfgScanLineBrightness.Value; scanRange = cfgScanRange.Value; outlineBrightness = cfgOutlineBrightness.Value; headScanLineDistance = cfgHeadScanLineDistance.Value; scanCenterWS = ParseVec(cfgScanCenterWS.Value); outlineStarDistance = cfgOutlineStarDistance.Value; horizontalCount = cfgHorizontalCount.Value; verticalCount = cfgVerticalCount.Value; scanCooldown = cfgScanCooldown.Value; sfxVolume = cfgSfxVolume.Value; markIconSize = cfgMarkIconSize.Value; markSafeColor = ParseColor(cfgMarkSafeColor.Value); markWarningColor = ParseColor(cfgMarkWarningColor.Value); markDangerColor = ParseColor(cfgMarkDangerColor.Value); animHeadScanLineDistance = cfgAnimHeadScanLineDistance.Value; animScanRange = cfgAnimScanRange.Value; animOutlineStarDistance = cfgAnimOutlineStarDistance.Value; animScanLineBrightnessPeak = cfgAnimScanLineBrightnessPeak.Value; animHeadScanLineBrightnessPeak = cfgAnimHeadScanLineBrightnessPeak.Value; animOutlineBrightnessPeak = cfgAnimOutlineBrightnessPeak.Value; activeKey = cfgActiveKey.Value; } catch { } try { onChanged?.Invoke(this); } catch { } } } public void CopyFrom(ScanConfig other) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (other != null) { scanColorHead = other.scanColorHead; scanColor = other.scanColor; outlineWidth = other.outlineWidth; scanLineWidth = other.scanLineWidth; scanLineInterval = other.scanLineInterval; headScanLineWidth = other.headScanLineWidth; scanLineBrightness = other.scanLineBrightness; scanRange = other.scanRange; outlineBrightness = other.outlineBrightness; headScanLineDistance = other.headScanLineDistance; scanCenterWS = other.scanCenterWS; outlineStarDistance = other.outlineStarDistance; steepSpawnProb = other.steepSpawnProb; midSpawnProb = other.midSpawnProb; flatSpawnProb = other.flatSpawnProb; markIconSize = other.markIconSize; markSafeColor = other.markSafeColor; markWarningColor = other.markWarningColor; markDangerColor = other.markDangerColor; horizontalCount = other.horizontalCount; verticalCount = other.verticalCount; scanCooldown = other.scanCooldown; sfxVolume = other.sfxVolume; animHeadScanLineDistance = other.animHeadScanLineDistance; animScanRange = other.animScanRange; animOutlineStarDistance = other.animOutlineStarDistance; animScanLineBrightnessPeak = other.animScanLineBrightnessPeak; animHeadScanLineBrightnessPeak = other.animHeadScanLineBrightnessPeak; animOutlineBrightnessPeak = other.animOutlineBrightnessPeak; } } } public static class ScanConfigManager { private static ScanConfig _current; private static readonly List _registered = new List(); public static ScanConfig Current => _current; private static event Action _onChanged; public static void Initialize(BaseUnityPlugin plugin) { if ((Object)(object)plugin == (Object)null || _current != null) { return; } _current = new ScanConfig(); try { _current.Bind(plugin, delegate { try { ScanConfigManager._onChanged?.Invoke(_current); } catch { } }); } catch { } try { ScanConfigManager._onChanged?.Invoke(_current); } catch { } } public static void RegisterFeature(ScanFeature feature) { if ((Object)(object)feature == (Object)null || _current == null) { return; } if (!_registered.Contains(feature)) { _registered.Add(feature); } try { feature.config.CopyFrom(_current); } catch { } try { if ((Object)(object)_current.scanMaterial != (Object)null) { feature.config.scanMaterial = _current.scanMaterial; } if ((Object)(object)_current.markMaterial != (Object)null) { try { _current.markMaterial.enableInstancing = true; } catch { } feature.config.markMaterial = _current.markMaterial; } feature.config.markParticle1 = _current.markParticle1; feature.config.markParticle2 = _current.markParticle2; feature.config.markParticle3 = _current.markParticle3; } catch { } _onChanged -= feature_OnConfigChanged; _onChanged += feature_OnConfigChanged; } public static void UnregisterFeature(ScanFeature feature) { if (!((Object)(object)feature == (Object)null)) { _registered.Remove(feature); _onChanged -= feature_OnConfigChanged; } } private static void feature_OnConfigChanged(ScanConfig cfg) { for (int i = 0; i < _registered.Count; i++) { ScanFeature scanFeature = _registered[i]; if (!((Object)(object)scanFeature == (Object)null)) { try { scanFeature.config.CopyFrom(cfg); } catch { } } } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("d542Bb.TerrainScanner", "TerrainScanner", "1.1.5")] public class TerrainScannerPlugin : BaseUnityPlugin { public static TerrainScannerPlugin Instance; internal static ManualLogSource Logger; private ScanFeature activeScanFeature; private bool assetsLoaded; private bool scanFeatureInitialized; public const string Id = "d542Bb.TerrainScanner"; public static string Name => "TerrainScanner"; public static string Version => "1.1.5"; private void Awake() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Instance = this; Logger = ((BaseUnityPlugin)this).Logger; try { ScanConfigManager.Initialize((BaseUnityPlugin)(object)this); Logger.LogInfo((object)"[INFO] ScanConfigManager initialized."); } catch (Exception ex) { Logger.LogWarning((object)("[WARN] ScanConfigManager.Initialize failed: " + ex.Message)); } try { PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); PlayerLoopHelper.Initialize(ref currentPlayerLoop, (InjectPlayerLoopTimings)65535); Logger.LogInfo((object)"[INFO] UniTask PlayerLoop initialized successfully."); } catch (Exception ex2) { Logger.LogWarning((object)("[WARN] UniTask PlayerLoop initialization failed: " + ex2.Message)); } LoadPeakBundle(); SceneManager.sceneLoaded += OnSceneLoaded; } public void LoadPeakBundle() { if (((BaseUnityPlugin)this).Info == null || string.IsNullOrEmpty(((BaseUnityPlugin)this).Info.Location)) { Logger.LogError((object)"[ERROR] Plugin Info.Location unavailable; cannot resolve bundle path."); return; } string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "TerrainScanner.peakbundle"); if (!File.Exists(text)) { Logger.LogError((object)("[ERROR] Peakbundle not found at: " + text)); return; } Logger.LogInfo((object)("[INFO] Loading AssetBundle from: " + text)); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[ERROR] AssetBundle.LoadFromFile returned null."); return; } Material val2 = val.LoadAsset("Assets/Material/Scan.mat"); Material val3 = val.LoadAsset("Assets/Shader/TerrianMarks.mat"); GameObject val4 = val.LoadAsset("Assets/Particles/LightParticle1.prefab"); GameObject val5 = val.LoadAsset("Assets/Particles/LightParticle2.prefab"); GameObject val6 = val.LoadAsset("Assets/Particles/LightParticle3.prefab"); if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)"[ERROR] Scan material failed to load from AssetBundle."); return; } if ((Object)(object)val3 == (Object)null) { Logger.LogError((object)"[ERROR] TerrianMarks.mat failed to load from AssetBundle."); return; } if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val6 == (Object)null) { Logger.LogError((object)"[ERROR] One or more mark particles failed to load from AssetBundle."); return; } Logger.LogInfo((object)"[INFO] All assets loaded successfully from AssetBundle."); try { if (ScanConfigManager.Current != null) { ScanConfigManager.Current.scanMaterial = val2; ScanConfigManager.Current.markMaterial = val3; ScanConfigManager.Current.markParticle1 = val4; ScanConfigManager.Current.markParticle2 = val5; ScanConfigManager.Current.markParticle3 = val6; } } catch (Exception ex) { Logger.LogWarning((object)("[WARN] Failed to assign loaded assets to ScanConfigManager.Current: " + ex.Message)); } assetsLoaded = true; try { if ((Object)(object)val2 != (Object)null) { ManualLogSource logger = Logger; Shader shader = val2.shader; logger.LogInfo((object)("[DIAG] scanMaterial shader=" + (((shader != null) ? ((Object)shader).name : null) ?? "null"))); Logger.LogInfo((object)string.Format("[DIAG] scanMaterial has scanRange? {0}", val2.HasProperty("scanRange"))); Logger.LogInfo((object)string.Format("[DIAG] scanMaterial has scanLineBrightness? {0}", val2.HasProperty("scanLineBrightness"))); Logger.LogInfo((object)$"[DIAG] scanMaterial renderQueue={val2.renderQueue} instancing={val2.enableInstancing}"); } if ((Object)(object)val3 != (Object)null) { ManualLogSource logger2 = Logger; Shader shader2 = val3.shader; logger2.LogInfo((object)("[DIAG] markMaterial shader=" + (((shader2 != null) ? ((Object)shader2).name : null) ?? "null"))); Logger.LogInfo((object)$"[DIAG] markMaterial instancing={val3.enableInstancing} renderQueue={val3.renderQueue}"); } } catch (Exception ex2) { Logger.LogWarning((object)("[WARN] Material diagnostics failed: " + ex2.Message)); } if ((Object)(object)Camera.main != (Object)null) { InitializeScanFeature(); } } public void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Camera main = Camera.main; if ((Object)(object)main != (Object)null) { if ((Object)(object)((Component)main).gameObject.GetComponent() == (Object)null) { ((Component)main).gameObject.AddComponent(); Logger.LogInfo((object)"[INFO] ActiveScan component added to main camera"); } if (assetsLoaded && !scanFeatureInitialized) { InitializeScanFeature(); } } else { Logger.LogWarning((object)"[WARN] Main camera not found in scene"); } } private void InitializeScanFeature() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (!assetsLoaded) { Logger.LogWarning((object)"[WARN] Assets not loaded yet. Waiting for AssetBundle to finish loading..."); return; } if (scanFeatureInitialized) { Logger.LogInfo((object)"[DEBUG] ScanFeature already initialized. Skipping..."); return; } UniversalRenderPipelineAsset val = (UniversalRenderPipelineAsset)GraphicsSettings.currentRenderPipeline; if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[ERROR] UniversalRenderPipelineAsset is null!"); return; } FieldInfo field = typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Logger.LogError((object)"[ERROR] Unable to access m_RendererDataList via reflection."); return; } if (!(field.GetValue(val) is ScriptableRendererData[] array) || array.Length == 0) { Logger.LogError((object)"[ERROR] RendererData array is null or empty."); return; } ScriptableRendererData obj = array[0]; UniversalRendererData val2 = (UniversalRendererData)(object)((obj is UniversalRendererData) ? obj : null); if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)"[ERROR] First renderer is not UniversalRendererData."); return; } foreach (ScriptableRendererFeature rendererFeature in ((ScriptableRendererData)val2).rendererFeatures) { if (rendererFeature is ScanFeature scanFeature) { Logger.LogInfo((object)"[DEBUG] ScanFeature already exists. Configuring..."); activeScanFeature = scanFeature; try { ScanConfigManager.RegisterFeature(scanFeature); } catch (Exception ex) { Logger.LogWarning((object)("[WARN] RegisterFeature failed: " + ex.Message)); } try { ((ScriptableRendererFeature)scanFeature).Create(); } catch (Exception ex2) { Logger.LogWarning((object)("[WARN] ScanFeature.Create (existing) failed: " + ex2.Message)); } scanFeatureInitialized = true; return; } } ScanFeature scanFeature2 = ScriptableObject.CreateInstance(); ((Object)scanFeature2).name = "TerrainScanner_ScanFeature"; ((ScriptableRendererData)val2).rendererFeatures.Add((ScriptableRendererFeature)(object)scanFeature2); Logger.LogInfo((object)"[SUCCESS] ScanFeature created and added to renderer!"); activeScanFeature = scanFeature2; try { ScanConfigManager.RegisterFeature(scanFeature2); } catch (Exception ex3) { Logger.LogWarning((object)("[WARN] RegisterFeature failed: " + ex3.Message)); } try { ((ScriptableRendererFeature)scanFeature2).Create(); } catch (Exception ex4) { Logger.LogWarning((object)("[WARN] ScanFeature.Create failed: " + ex4.Message)); } scanFeatureInitialized = true; Logger.LogInfo((object)"[SUCCESS] ScanFeature initialized!"); } } } namespace TerrainScanner.DS { public class ActiveScan : MonoBehaviour { public static KeyCode activeKey; private const string SfxFileName = "scan_sfx.mp3"; private static AudioClip scanSfx; private static bool sfxLoading; private static float lastScanTime; private AudioSource audioSource; private void Start() { if ((Object)(object)audioSource == (Object)null) { audioSource = ((Component)this).gameObject.AddComponent(); } if ((Object)(object)scanSfx == (Object)null && !sfxLoading) { ((MonoBehaviour)this).StartCoroutine(LoadScanSfx()); } } private IEnumerator LoadScanSfx() { sfxLoading = true; try { TerrainScannerPlugin instance = TerrainScannerPlugin.Instance; string path = ((((instance != null) ? ((BaseUnityPlugin)instance).Info : null) != null && !string.IsNullOrEmpty(((BaseUnityPlugin)TerrainScannerPlugin.Instance).Info.Location)) ? Path.GetDirectoryName(((BaseUnityPlugin)TerrainScannerPlugin.Instance).Info.Location) : (string.IsNullOrEmpty(Assembly.GetExecutingAssembly().Location) ? Paths.PluginPath : Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))); string file = Path.Combine(path, "scan_sfx.mp3"); if (!File.Exists(file)) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)("[ScanAudio] sfx not found: " + file)); } yield break; } UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(new Uri(file).AbsoluteUri, (AudioType)13); try { yield return req.SendWebRequest(); if ((int)req.result == 1) { scanSfx = DownloadHandlerAudioClip.GetContent(req); ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogInfo((object)("[ScanAudio] loaded: " + file)); } } else { ManualLogSource logger3 = TerrainScannerPlugin.Logger; if (logger3 != null) { logger3.LogError((object)("[ScanAudio] load failed: " + req.error)); } } } finally { ((IDisposable)req)?.Dispose(); } } finally { sfxLoading = false; } } private void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(activeKey)) { float num = ScanConfigManager.Current?.scanCooldown ?? 0.8f; if (!(Time.time - lastScanTime < num) && ScanFeature.CanScan && !((Object)(object)scanSfx == (Object)null) && !((Object)(object)audioSource == (Object)null)) { lastScanTime = Time.time; float num2 = ScanConfigManager.Current?.sfxVolume ?? 1f; audioSource.PlayOneShot(scanSfx, num2); ((MonoBehaviour)this).StartCoroutine(RunScanDelayed(0.5f)); } } } private IEnumerator RunScanDelayed(float delay) { yield return (object)new WaitForSeconds(delay); ScanFeature.ExecuteScan(((Component)this).transform); TerrainScannerPlugin.Logger.LogInfo((object)"TerrainScanner : scan executed"); } static ActiveScan() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) ConfigEntry cfgActiveKey = ScanConfigManager.Current.cfgActiveKey; activeKey = (KeyCode)((cfgActiveKey == null) ? 113 : ((int)cfgActiveKey.Value)); sfxLoading = false; lastScanTime = float.MinValue; } } public static class ParticleSpawner { public static void ShootParticle(Vector3 position, Vector3 normal, int index, ScanConfig config) { //IL_0052: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) try { if (config == null) { return; } GameObject val = (GameObject)(index switch { 3 => config.markParticle3, 2 => config.markParticle2, _ => config.markParticle1, }); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = Object.Instantiate(val); if (!((Object)(object)val2 == (Object)null)) { val2.transform.position = position; float num = Random.Range(0.5f, 1.5f); val2.transform.localScale = Vector3.one * num; ParticleSystem componentInChildren = val2.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.Play(); } } } catch (Exception arg) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)$"[ParticleSpawner] ShootParticle failed: {arg}"); } } } } public class ScanFeature : ScriptableRendererFeature { private class CustomRenderPass : ScriptableRenderPass { private class PassData { public Material scanMaterial; public Material markMaterial; public bool localShowMark; public Marks[] marks; public ComputeBuffer computeBuffer; public GraphicsBuffer graphicsBuffer; public IndirectDrawIndexedArgs[] commandData; public Mesh mesh; public int localHorizontalCount; public int localVerticalCount; public TextureHandle depthTarget; } private GraphicsBuffer _graphicsBuffer; private IndirectDrawIndexedArgs[] _commandData; private ComputeBuffer _computeBuffer; private Mesh mesh; private ScanConfig settings; private string _passName; public CustomRenderPass(ScanConfig settings) { ScanMarkRenderer.CreateResources(settings, settings.horizontalCount, settings.verticalCount, out mesh, out _computeBuffer, out _graphicsBuffer, out _commandData); this.settings = settings; _passName = "ScanEffect"; try { if ((Object)(object)this.settings?.markMaterial != (Object)null) { this.settings.markMaterial.enableInstancing = true; } } catch { } } public void DisposeResources() { try { if (_computeBuffer != null) { _computeBuffer.Dispose(); _computeBuffer = null; } } catch { } try { if (_graphicsBuffer != null) { _graphicsBuffer.Dispose(); _graphicsBuffer = null; } } catch { } try { if ((Object)(object)mesh != (Object)null) { Object.Destroy((Object)(object)mesh); mesh = null; } } catch { } } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { //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) //IL_000f: 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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) UniversalResourceData val = frameData.Get(); TextureHandle activeColorTexture = val.activeColorTexture; TextureHandle activeDepthTexture = val.activeDepthTexture; PassData passData = default(PassData); IRasterRenderGraphBuilder val2 = renderGraph.AddRasterRenderPass(_passName, ref passData, "./DS/ScanFeature.cs", 181); try { passData.scanMaterial = settings.scanMaterial; passData.markMaterial = settings.markMaterial; passData.localShowMark = showMark; passData.marks = _marksForRender; passData.computeBuffer = _computeBuffer; passData.graphicsBuffer = _graphicsBuffer; passData.commandData = _commandData; passData.mesh = mesh; passData.localHorizontalCount = settings.horizontalCount; passData.localVerticalCount = settings.verticalCount; passData.depthTarget = activeDepthTexture; ((IRenderAttachmentRenderGraphBuilder)val2).SetRenderAttachment(activeColorTexture, 0, (AccessFlags)3); ((IRenderAttachmentRenderGraphBuilder)val2).SetRenderAttachmentDepth(activeDepthTexture, (AccessFlags)3); ((IBaseRenderGraphBuilder)val2).UseTexture(ref activeDepthTexture, (AccessFlags)1); val2.SetRenderFunc((BaseRenderFunc)delegate(PassData data, RasterGraphContext ctx) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ExecutePass(data, ctx); }); } finally { ((IDisposable)val2)?.Dispose(); } } private static void ExecutePass(PassData data, RasterGraphContext context) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0039: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)data.scanMaterial == (Object)null) { return; } RasterCommandBuffer cmd = context.cmd; RTHandle val = TextureHandle.op_Implicit(data.depthTarget); Vector2 val2 = Vector2.one; try { if (val != null && val.useScaling) { val2 = new Vector2(val.rtHandleProperties.rtHandleScale.x, val.rtHandleProperties.rtHandleScale.y); } } catch (Exception ex) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)("[ScanFeature] depth handle read failed: " + ex.Message)); } } if (val != null) { try { Blitter.BlitTexture(cmd, val, Vector4.op_Implicit(val2), data.scanMaterial, 0); } catch (Exception arg) { TerrainScannerPlugin.Logger.LogError((object)$"[ScanFeature] ExecutePass: BlitTexture failed: {arg}"); } } if (!data.localShowMark || !((Object)(object)data.markMaterial != (Object)null)) { return; } try { Marks[] marksForRender = _marksForRender; ScanMarkRenderer.RenderMarks(cmd, data.markMaterial, data.computeBuffer, data.graphicsBuffer, data.commandData, data.mesh, marksForRender, data.localShowMark); } catch (Exception arg2) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogWarning((object)$"[ScanFeature] RenderMarks failed: {arg2}"); } } } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static TweenCallback <>9__5_0; public static TweenCallback <>9__5_1; internal void b__5_0() { canScan = true; } internal void b__5_1() { showMark = false; } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__5 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskVoidMethodBuilder <>t__builder; public Transform player; private Awaiter <>u__1; private void MoveNext() { //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Expected O, but got Unknown //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Expected O, but got Unknown //IL_00f0: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { if (num == 0) { goto IL_04ab; } int scanId = default(int); if (!Application.isPlaying) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)"[WARN] Cannot scan: not playing"); } } else if (!canScan) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogInfo((object)"[INFO] Scan already in progress"); } } else if ((Object)(object)_instance == (Object)null) { ManualLogSource logger3 = TerrainScannerPlugin.Logger; if (logger3 != null) { logger3.LogError((object)"[ERROR] ScanFeature instance is null. Ensure it is properly initialized."); } } else if (_instance.config == null) { ManualLogSource logger4 = TerrainScannerPlugin.Logger; if (logger4 != null) { logger4.LogError((object)"[ERROR] ScanFeature config is null."); } } else { if (!((Object)(object)_instance.config.scanMaterial == (Object)null)) { canScan = false; showMark = true; Tween markTween = ScanFeature.markTween; if (markTween != null) { TweenExtensions.Kill(markTween, false); } Vector3 val = player.position - player.forward * 2f; Material scanMaterial = _instance.config.scanMaterial; Material markMaterial = _instance.config.markMaterial; if ((Object)(object)scanMaterial != (Object)null) { try { scanMaterial.SetColor(ScanColorHead, _instance.config.scanColorHead); scanMaterial.SetColor(ScanColor, _instance.config.scanColor); scanMaterial.SetFloat(OutlineWidth, _instance.config.outlineWidth); scanMaterial.SetFloat(ScanLineWidth, _instance.config.scanLineWidth); scanMaterial.SetFloat(ScanLineInterval, _instance.config.scanLineInterval); scanMaterial.SetFloat(HeadScanLineWidth, _instance.config.headScanLineWidth); } catch (Exception ex) { ManualLogSource logger5 = TerrainScannerPlugin.Logger; if (logger5 != null) { logger5.LogWarning((object)("[ScanFeature] apply cfg to scan material failed: " + ex.Message)); } } scanMaterial.SetVector(ScanCenterWs, Vector4.op_Implicit(val)); scanMaterial.SetFloat(HeadScanLineDistance, 4f); TweenerCore val2 = TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFloat(scanMaterial, _instance.config.animHeadScanLineDistance, HeadScanLineDistance, 3.5f), (Ease)2); if (val2 != null) { TweenCallback onComplete = ((Tween)val2).onComplete; object obj = <>c.<>9__5_0; if (obj == null) { TweenCallback val3 = delegate { canScan = true; }; <>c.<>9__5_0 = val3; obj = (object)val3; } ((Tween)val2).onComplete = (TweenCallback)Delegate.Combine((Delegate?)(object)onComplete, (Delegate?)obj); } scanMaterial.SetFloat(ScanRange, 1f); TweenSettingsExtensions.SetDelay>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFloat(scanMaterial, _instance.config.animScanRange, ScanRange, 1.5f), (Ease)2), 1f); scanMaterial.SetFloat(ScanLineBrightness, 0.3f); scanMaterial.SetFloat(HeadScanLineBrightness, 0f); TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, _instance.config.animScanLineBrightnessPeak, ScanLineBrightness, 0.2f), 0.25f); TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, _instance.config.animHeadScanLineBrightnessPeak, HeadScanLineBrightness, 0.1f), 0.25f); TweenSettingsExtensions.SetEase>(TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, 0f, ScanLineBrightness, 0.5f), 2.25f), (Ease)1); TweenSettingsExtensions.SetEase>(TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, 0f, HeadScanLineBrightness, 0.5f), 2.25f), (Ease)1); scanMaterial.SetFloat(OutlineBrightness, _instance.config.animOutlineBrightnessPeak); scanMaterial.SetFloat(OutlineStarDistance, 0f); TweenSettingsExtensions.SetEase>(TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, 0f, OutlineBrightness, 0.5f), 2.25f), (Ease)1); TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFloat(scanMaterial, _instance.config.animOutlineStarDistance, OutlineStarDistance, 1f), (Ease)8); } if ((Object)(object)markMaterial != (Object)null) { markMaterial.SetFloat(ColorAlpha, 0f); float num2 = 0.5f; TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(markMaterial, 1f, ColorAlpha, 0.1f), num2); ScanFeature.markTween = (Tween)(object)TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(markMaterial, 0f, ColorAlpha, 1f), 7f); if (ScanFeature.markTween != null) { Tween markTween2 = ScanFeature.markTween; TweenCallback onComplete2 = markTween2.onComplete; object obj2 = <>c.<>9__5_1; if (obj2 == null) { TweenCallback val4 = delegate { showMark = false; }; <>c.<>9__5_1 = val4; obj2 = (object)val4; } markTween2.onComplete = (TweenCallback)Delegate.Combine((Delegate?)(object)onComplete2, (Delegate?)obj2); } } scanId = ++s_scanCounter; goto IL_04ab; } ManualLogSource logger6 = TerrainScannerPlugin.Logger; if (logger6 != null) { logger6.LogError((object)"[ERROR] ScanFeature scanMaterial is null. Assets may not be loaded yet."); } } goto end_IL_0007; IL_04ab: try { Awaiter val5; if (num != 0) { val5 = ScanMarkRenderer.GenerateTerrainMarks(player, _instance.config, _instance.config.horizontalCount, _instance.config.verticalCount, _instance.config.gridStep, scanId).GetAwaiter(); if (!val5.IsCompleted) { num = (<>1__state = 0); <>u__1 = val5; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted, d__5>(ref val5, ref this); return; } } else { val5 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } Marks[] result = val5.GetResult(); Marks[] marksForRender = result; object marksLock = _marksLock; bool lockTaken = false; try { Monitor.Enter(marksLock, ref lockTaken); _marksForRender = marksForRender; } finally { if (num < 0 && lockTaken) { Monitor.Exit(marksLock); } } } catch (Exception arg) { ManualLogSource logger7 = TerrainScannerPlugin.Logger; if (logger7 != null) { logger7.LogWarning((object)$"[ScanFeature] GenerateTerrainMarks failed: {arg}"); } object marksLock2 = _marksLock; bool lockTaken2 = false; try { Monitor.Enter(marksLock2, ref lockTaken2); _marksForRender = null; } finally { if (num < 0 && lockTaken2) { Monitor.Exit(marksLock2); } } } end_IL_0007:; } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } public ScanConfig config = new ScanConfig(); private static ScanFeature _instance; private CustomRenderPass _myPass; private static int s_scanCounter = 0; private static Marks[] _marksForRender; private static readonly object _marksLock = new object(); private static readonly int ScanColorHead = Shader.PropertyToID("scanColorHead"); private static readonly int ScanColor = Shader.PropertyToID("scanColor"); private static readonly int OutlineWidth = Shader.PropertyToID("outlineWidth"); private static readonly int OutlineBrightness = Shader.PropertyToID("outlineBrightness"); private static readonly int OutlineStarDistance = Shader.PropertyToID("outlineStarDistance"); private static readonly int ScanLineWidth = Shader.PropertyToID("scanLineWidth"); private static readonly int ScanLineInterval = Shader.PropertyToID("scanLineInterval"); private static readonly int ScanLineBrightness = Shader.PropertyToID("scanLineBrightness"); private static readonly int ScanRange = Shader.PropertyToID("scanRange"); private static readonly int HeadScanLineDistance = Shader.PropertyToID("headScanLineDistance"); private static readonly int HeadScanLineWidth = Shader.PropertyToID("headScanLineWidth"); private static readonly int HeadScanLineBrightness = Shader.PropertyToID("headScanLineBrightness"); private static readonly int ScanCenterWs = Shader.PropertyToID("scanCenterWS"); private static readonly int ColorAlpha = Shader.PropertyToID("colorAlpha"); private static bool canScan = true; private static bool showMark = false; private static Tween markTween; public static bool CanScan => canScan; public static void ExecuteScan(Transform player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) UniTaskVoid val = StartScan(player); ((UniTaskVoid)(ref val)).Forget(); } [AsyncStateMachine(typeof(d__5))] private static UniTaskVoid StartScan(Transform player) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) d__5 d__ = default(d__5); d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create(); d__.player = player; d__.<>1__state = -1; ((AsyncUniTaskVoidMethodBuilder)(ref d__.<>t__builder)).Start<d__5>(ref d__); return ((AsyncUniTaskVoidMethodBuilder)(ref d__.<>t__builder)).Task; } public override void Create() { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogInfo((object)"[ScanFeature] Create() called"); } if ((Object)(object)config.scanMaterial == (Object)null) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogError((object)"[ScanFeature] scanMaterial is not assigned!"); } return; } if ((Object)(object)config.markMaterial == (Object)null) { ManualLogSource logger3 = TerrainScannerPlugin.Logger; if (logger3 != null) { logger3.LogError((object)"[ScanFeature] markMaterial is not assigned!"); } return; } if ((Object)(object)config.markParticle1 == (Object)null || (Object)(object)config.markParticle2 == (Object)null || (Object)(object)config.markParticle3 == (Object)null) { ManualLogSource logger4 = TerrainScannerPlugin.Logger; if (logger4 != null) { logger4.LogError((object)"[ScanFeature] One or more mark particles are not assigned!"); } return; } if (!Application.isPlaying) { ManualLogSource logger5 = TerrainScannerPlugin.Logger; if (logger5 != null) { logger5.LogWarning((object)"[ScanFeature] Not in play mode, skipping Create()"); } return; } _myPass = new CustomRenderPass(config); _instance = this; ManualLogSource logger6 = TerrainScannerPlugin.Logger; if (logger6 != null) { logger6.LogInfo((object)"[ScanFeature] Create() completed successfully, _instance set"); } } private void OnDisable() { try { if (_myPass != null) { try { _myPass.DisposeResources(); } catch (Exception arg) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)$"[ScanFeature] DisposeResources failed: {arg}"); } } _myPass = null; } } catch (Exception arg2) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogWarning((object)$"[ScanFeature] OnDisable cleanup failed: {arg2}"); } } try { ScanConfigManager.UnregisterFeature(this); } catch (Exception arg3) { ManualLogSource logger3 = TerrainScannerPlugin.Logger; if (logger3 != null) { logger3.LogWarning((object)$"[ScanFeature] UnregisterFeature failed: {arg3}"); } } _instance = null; } public override void SetupRenderPasses(ScriptableRenderer renderer, in RenderingData renderingData) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)config.scanMaterial == (Object)null) && Application.isPlaying) { CameraData cameraData = renderingData.cameraData; if ((int)((CameraData)(ref cameraData)).cameraType == 1) { ((ScriptableRenderPass)_myPass).renderPassEvent = config.renderEvent; ((ScriptableRenderPass)_myPass).ConfigureInput((ScriptableRenderPassInput)4); ((ScriptableRenderPass)_myPass).ConfigureInput((ScriptableRenderPassInput)2); ((ScriptableRenderPass)_myPass).ConfigureInput((ScriptableRenderPassInput)1); } } } public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) { if (!((Object)(object)config.scanMaterial == (Object)null) && Application.isPlaying) { renderer.EnqueuePass((ScriptableRenderPass)(object)_myPass); } } } public struct Marks { public Vector3 markPosition; public ScanRaySampling.RayMarkCategory markCategory; } public static class ScanMarkRenderer { [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public int horizCount; public Marks[] marks; public float flatProb; public ScanConfig config; public float midProb; public float steepProb; internal void b__0(RaycastHit hit, int i, int j) { //IL_0055: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) int num = i * horizCount + j; if (num < 0 || num >= marks.Length) { return; } if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Undefined; marks[num].markPosition = Vector3.zero; return; } Vector3 normal = ((RaycastHit)(ref hit)).normal; if (((RaycastHit)(ref hit)).collider.isTrigger) { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Road; marks[num].markPosition = Vector3.zero; return; } float num2 = Vector3.Angle(Vector3.up, normal); if (num2 < 40f) { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Safe; marks[num].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < flatProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 1, config); } } else if (num2 < 50f) { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Warning; marks[num].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < midProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 2, config); } } else { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Danger; marks[num].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < steepProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 3, config); } } } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__0 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public int horizCount; public ScanConfig config; public int vertCount; public Transform player; public float gridStep; public int scanId; private <>c__DisplayClass0_0 <>8__1; private Awaiter <>u__1; private void MoveNext() { //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; Marks[] result; try { Awaiter val2; if (num != 0) { <>8__1 = new <>c__DisplayClass0_0(); <>8__1.horizCount = horizCount; <>8__1.config = config; int num2 = Math.Max(1, <>8__1.horizCount * vertCount); <>8__1.marks = new Marks[num2]; for (int i = 0; i < <>8__1.marks.Length; i++) { <>8__1.marks[i].markCategory = ScanRaySampling.RayMarkCategory.Undefined; <>8__1.marks[i].markPosition = Vector3.zero; } int maxRays = Math.Max(1, <>8__1.horizCount * vertCount * 2); int num3 = LayerMask.GetMask(new string[2] { "Scan", "Road" }); if (num3 == 0) { num3 = -5; } if ((Object)(object)<>8__1.config?.markMaterial != (Object)null) { try { float num4 = ((<>8__1.config.markIconSize > 0.001f) ? <>8__1.config.markIconSize : 1f); if (Mathf.Abs(<>8__1.config.markMaterial.GetFloat("_IconSize") - num4) > 0.0001f) { <>8__1.config.markMaterial.SetFloat("_IconSize", num4); } } catch (Exception ex) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)("[ScanMarkRenderer] _IconSize set failed: " + ex.Message)); } } try { <>8__1.config.markMaterial.SetColor("_SafeColor", <>8__1.config.markSafeColor); <>8__1.config.markMaterial.SetColor("_WarningColor", <>8__1.config.markWarningColor); <>8__1.config.markMaterial.SetColor("_DangerColor", <>8__1.config.markDangerColor); } catch (Exception ex2) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogWarning((object)("[ScanMarkRenderer] mark color set failed: " + ex2.Message)); } } } <>8__1.steepProb = <>8__1.config?.steepSpawnProb ?? 0.1f; <>8__1.midProb = <>8__1.config?.midSpawnProb ?? 0.3f; <>8__1.flatProb = <>8__1.config?.flatSpawnProb ?? 0.0002f; Action onHit = delegate(RaycastHit hit, int num10, int j) { //IL_0055: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) int num9 = num10 * <>8__1.horizCount + j; if (num9 >= 0 && num9 < <>8__1.marks.Length) { if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { <>8__1.marks[num9].markCategory = ScanRaySampling.RayMarkCategory.Undefined; <>8__1.marks[num9].markPosition = Vector3.zero; } else { Vector3 normal = ((RaycastHit)(ref hit)).normal; if (((RaycastHit)(ref hit)).collider.isTrigger) { <>8__1.marks[num9].markCategory = ScanRaySampling.RayMarkCategory.Road; <>8__1.marks[num9].markPosition = Vector3.zero; } else { float num11 = Vector3.Angle(Vector3.up, normal); if (num11 < 40f) { <>8__1.marks[num9].markCategory = ScanRaySampling.RayMarkCategory.Safe; <>8__1.marks[num9].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < <>8__1.flatProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 1, <>8__1.config); } } else if (num11 < 50f) { <>8__1.marks[num9].markCategory = ScanRaySampling.RayMarkCategory.Warning; <>8__1.marks[num9].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < <>8__1.midProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 2, <>8__1.config); } } else { <>8__1.marks[num9].markCategory = ScanRaySampling.RayMarkCategory.Danger; <>8__1.marks[num9].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < <>8__1.steepProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 3, <>8__1.config); } } } } } }; UniTask val = ScanRaySampling.PerformGridSamples(player, <>8__1.config, <>8__1.horizCount, vertCount, gridStep, num3, maxRays, onHit, scanId); val2 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref val2)).IsCompleted) { num = (<>1__state = 0); <>u__1 = val2; <>t__builder.AwaitUnsafeOnCompletedd__0>(ref val2, ref this); return; } } else { val2 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref val2)).GetResult(); int num5 = 0; for (int num6 = 0; num6 < <>8__1.marks.Length; num6++) { if (<>8__1.marks[num6].markCategory != ScanRaySampling.RayMarkCategory.Undefined || <>8__1.marks[num6].markPosition != Vector3.zero) { num5++; } } if (num5 <= 0) { result = null; } else { Marks[] array = new Marks[num5]; int num7 = 0; for (int num8 = 0; num8 < <>8__1.marks.Length; num8++) { if (<>8__1.marks[num8].markCategory != ScanRaySampling.RayMarkCategory.Undefined || <>8__1.marks[num8].markPosition != Vector3.zero) { array[num7++] = <>8__1.marks[num8]; } } result = array; } } catch (Exception exception) { <>1__state = -2; <>8__1 = null; <>t__builder.SetException(exception); return; } <>1__state = -2; <>8__1 = null; <>t__builder.SetResult(result); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { <>t__builder.SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__1 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; private Awaiter <>u__1; private void MoveNext() { //IL_0050: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; Marks[] result; try { Awaiter val2; if (num != 0) { UniTask val = UniTask.Delay(1, false, (PlayerLoopTiming)8, default(CancellationToken), false); val2 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref val2)).IsCompleted) { num = (<>1__state = 0); <>u__1 = val2; <>t__builder.AwaitUnsafeOnCompletedd__1>(ref val2, ref this); return; } } else { val2 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref val2)).GetResult(); result = new Marks[0]; } catch (Exception exception) { <>1__state = -2; <>t__builder.SetException(exception); return; } <>1__state = -2; <>t__builder.SetResult(result); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { <>t__builder.SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [AsyncStateMachine(typeof(d__0))] public static UniTask GenerateTerrainMarks(Transform player, ScanConfig config, int horizCount, int vertCount, float gridStep, int scanId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) d__0 d__ = default(d__0); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.player = player; d__.config = config; d__.horizCount = horizCount; d__.vertCount = vertCount; d__.gridStep = gridStep; d__.scanId = scanId; d__.<>1__state = -1; d__.<>t__builder.Start<d__0>(ref d__); return d__.<>t__builder.Task; } [AsyncStateMachine(typeof(d__1))] public static UniTask GenerateTerrainMarksPlus(Transform player, ScanConfig config, int horizCount, int vertCount, float gridStep, int scanId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) d__1 d__ = default(d__1); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>1__state = -1; d__.<>t__builder.Start<d__1>(ref d__); return d__.<>t__builder.Task; } public static void CreateResources(ScanConfig settings, int horizontalCount, int verticalCount, out Mesh mesh, out ComputeBuffer computeBuffer, out GraphicsBuffer graphicsBuffer, out IndirectDrawIndexedArgs[] commandData) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_004a: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0145: Unknown result type (might be due to invalid IL or missing references) graphicsBuffer = new GraphicsBuffer((Target)256, 1, 20); commandData = (IndirectDrawIndexedArgs[])(object)new IndirectDrawIndexedArgs[1]; computeBuffer = new ComputeBuffer(Math.Max(1, horizontalCount * verticalCount), 16); mesh = new Mesh(); Vector3[] vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, 0f, -0.5f), new Vector3(0.5f, 0f, -0.5f), new Vector3(0.5f, 0f, 0.5f), new Vector3(-0.5f, 0f, 0.5f) }; Vector2[] uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; int[] array = new int[6] { 0, 1, 2, 0, 2, 3 }; mesh.vertices = vertices; mesh.uv = uv; mesh.triangles = array; mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 100000f); try { if ((Object)(object)settings?.markMaterial != (Object)null) { settings.markMaterial.enableInstancing = true; } } catch { } ((IndirectDrawIndexedArgs)(ref commandData[0])).indexCountPerInstance = (uint)array.Length; ((IndirectDrawIndexedArgs)(ref commandData[0])).instanceCount = 0u; ((IndirectDrawIndexedArgs)(ref commandData[0])).startIndex = 0u; ((IndirectDrawIndexedArgs)(ref commandData[0])).startInstance = 0u; graphicsBuffer.SetData((Array)commandData); } public static void RenderMarks(RasterCommandBuffer cmd, Material markMaterial, ComputeBuffer computeBuffer, GraphicsBuffer graphicsBuffer, IndirectDrawIndexedArgs[] commandData, Mesh mesh, Marks[] renderMarks, bool showMark) { //IL_007a: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown if (!showMark && (renderMarks == null || renderMarks.Length == 0)) { return; } if ((Object)(object)markMaterial == (Object)null) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogError((object)"[ScanMarkRenderer] markMaterial is null - cannot render marks"); } return; } if (computeBuffer == null || graphicsBuffer == null || commandData == null || (Object)(object)mesh == (Object)null) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogError((object)"[ScanMarkRenderer] missing GPU resource(s) - computeBuffer/graphicsBuffer/commandData/mesh"); } return; } int num = 0; if (renderMarks != null) { for (int i = 0; i < renderMarks.Length; i++) { if (renderMarks[i].markCategory != ScanRaySampling.RayMarkCategory.Undefined || renderMarks[i].markPosition != Vector3.zero) { num++; } } } if (num <= 0) { return; } Marks[] array = new Marks[num]; int num2 = 0; for (int j = 0; j < ((renderMarks != null) ? renderMarks.Length : 0); j++) { if (renderMarks[j].markCategory != ScanRaySampling.RayMarkCategory.Undefined || renderMarks[j].markPosition != Vector3.zero) { array[num2++] = renderMarks[j]; } } try { computeBuffer.SetData((Array)array); } catch (Exception ex) { ManualLogSource logger3 = TerrainScannerPlugin.Logger; if (logger3 != null) { logger3.LogError((object)("[ScanMarkRenderer] computeBuffer.SetData failed: " + ex.Message)); } return; } MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetBuffer("markBuffer", computeBuffer); ((IndirectDrawIndexedArgs)(ref commandData[0])).indexCountPerInstance = 6u; ((IndirectDrawIndexedArgs)(ref commandData[0])).instanceCount = (uint)num; graphicsBuffer.SetData((Array)commandData); if (((IndirectDrawIndexedArgs)(ref commandData[0])).instanceCount == 0) { return; } try { if ((Object)(object)markMaterial != (Object)null) { markMaterial.enableInstancing = true; } } catch (Exception ex2) { ManualLogSource logger4 = TerrainScannerPlugin.Logger; if (logger4 != null) { logger4.LogError((object)("[ScanMarkRenderer] enableInstancing failed: " + ex2.Message)); } } try { cmd.DrawMeshInstancedIndirect(mesh, 0, markMaterial, 0, graphicsBuffer, 0, val); } catch (Exception arg) { ManualLogSource logger5 = TerrainScannerPlugin.Logger; if (logger5 != null) { logger5.LogError((object)$"[ScanMarkRenderer] DrawMeshInstancedIndirect failed: {arg}"); } } } } public static class ScanRaySampling { public enum RayMarkCategory { Road, Safe, Warning, Danger, Undefined } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__2 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; private void MoveNext() { int num = <>1__state; try { } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__1 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public Transform player; public ScanConfig config; public float gridStep; public int horizCount; public int layerMask; public Action onHit; public int maxRays; public int vertCount; private Camera 5__2; private Transform 5__3; private Vector3 5__4; private Vector3 5__5; private Vector3 5__6; private float 5__7; private float 5__8; private float 5__9; private float 5__10; private float 5__11; private int 5__12; private int 5__13; private Awaiter <>u__1; private void MoveNext() { //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { if (num == 0 || !((Object)(object)player == (Object)null)) { try { Awaiter val; if (num == 0) { val = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_042d; } 5__2 = Camera.main; if (!((Object)(object)5__2 == (Object)null)) { 5__3 = ((Component)5__2).transform; 5__4 = new Vector3(5__3.forward.x, 0f, 5__3.forward.z); if (((Vector3)(ref 5__4)).sqrMagnitude < 0.0001f) { 5__4 = new Vector3(player.forward.x, 0f, player.forward.z); } if (((Vector3)(ref 5__4)).sqrMagnitude < 0.0001f) { 5__4 = Vector3.forward; } ((Vector3)(ref 5__4)).Normalize(); 5__5 = Vector3.Cross(Vector3.up, 5__4); 5__6 = Vector3.down; 5__7 = config?.sampling_originHeightOffset ?? 10f; 5__8 = config?.sampling_forwardOffset ?? 1f; 5__9 = ((gridStep > 0.001f) ? gridStep : 0.5f); 5__10 = config?.sampling_jitterScale ?? 0.06f; 5__11 = config?.sampling_maxDistanceShort ?? 30f; 5__12 = 0; 5__13 = 0; goto IL_0446; } ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)"[ScanRaySampling] Camera.main is null."); } goto end_IL_001e; IL_042d: ((Awaiter)(ref val)).GetResult(); 5__13++; goto IL_0446; IL_0446: if (5__13 < vertCount) { float num2 = 5__8 + (float)5__13 * 5__9; Vector3 val2 = new Vector3(5__3.position.x, 5__3.position.y + 5__7, 5__3.position.z) + 5__4 * num2; int num3 = 0; RaycastHit arg = default(RaycastHit); while (true) { if (num3 >= horizCount) { YieldAwaitable val3 = UniTask.Yield(); val = ((YieldAwaitable)(ref val3)).GetAwaiter(); if (((Awaiter)(ref val)).IsCompleted) { break; } num = (<>1__state = 0); <>u__1 = val; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__1>(ref val, ref this); return; } float num4 = (float)(horizCount - 1) * 5__9 * 0.5f; float num5 = ((horizCount == 1) ? 0f : ((float)num3 / (float)(horizCount - 1) - 0.5f)); float num6 = Random.Range(0f - 5__10, 5__10) * 5__9; float num7 = Random.Range(0f - 5__10, 5__10) * 5__9; Vector3 val4 = val2 + 5__5 * (num5 * 2f * num4 + num6) + 5__4 * num7; if (!Physics.Raycast(val4, 5__6, ref arg, 5__11, layerMask)) { goto IL_03c3; } Vector3 val5 = 5__2.WorldToViewportPoint(((RaycastHit)(ref arg)).point); if (!(val5.z > 0f) || !(val5.x >= 0f) || !(val5.x <= 1f) || !(val5.y >= 0f) || !(val5.y <= 1f)) { goto IL_03c3; } try { onHit?.Invoke(arg, 5__13, num3); } catch (Exception ex) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.LogWarning((object)("[ScanRaySampling] onHit callback threw: " + ex.Message)); } } 5__12++; if (5__12 < maxRays) { goto IL_03c3; } goto end_IL_001e; IL_03c3: num3++; } goto IL_042d; } 5__2 = null; 5__3 = null; end_IL_001e:; } catch (Exception arg2) { ManualLogSource logger3 = TerrainScannerPlugin.Logger; if (logger3 != null) { logger3.LogWarning((object)$"[ScanRaySampling] PerformGridSamples failed: {arg2}"); } } } } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [AsyncStateMachine(typeof(d__1))] public static UniTask PerformGridSamples(Transform player, ScanConfig config, int horizCount, int vertCount, float gridStep, int layerMask, int maxRays, Action onHit, int scanId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) d__1 d__ = default(d__1); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.player = player; d__.config = config; d__.horizCount = horizCount; d__.vertCount = vertCount; d__.gridStep = gridStep; d__.layerMask = layerMask; d__.maxRays = maxRays; d__.onHit = onHit; d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__1>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } [AsyncStateMachine(typeof(d__2))] public static UniTask PerformGradientAscentSampling(Transform player, ScanConfig config, int horizCount, int vertCount, float gridStep, int layerMask, int maxRays, Action onHit, int scanId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) d__2 d__ = default(d__2); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__2>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }