using System; using System.Collections.Generic; using System.Diagnostics; 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 PEAKLib.Core; using TerrainScanner.DS; using UnityEngine; using UnityEngine.LowLevel; 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("moe.blumewmew.TerrainScanner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3+3c41629a46abcd57a6f5deea9fdd04c59ed72f2f")] [assembly: AssemblyProduct("moe.blumewmew.TerrainScanner")] [assembly: AssemblyTitle("TerrainScanner")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.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 = 2.48f; public float scanLineWidth = 1f; public float scanLineInterval = 1f; public float headScanLineWidth = 1f; public float scanLineBrightness = 2.5f; public float scanRange = 5f; public float outlineBrightness = 1.32f; public float headScanLineDistance = 13.2f; 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 = 12f; 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 KeyCode activeKey = (KeyCode)113; 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 cfgSteepSpawnProb; public ConfigEntry cfgMidSpawnProb; public ConfigEntry cfgFlatSpawnProb; public ConfigEntry cfgHorizontalCount; public ConfigEntry cfgVerticalCount; public ConfigEntry cfgGridStep; 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, "Key to trigger an active scan"); cfgScanColorHead = config.Bind("Style", "ScanColorHead", scanColorHead.r + "," + scanColorHead.g + "," + scanColorHead.b + "," + scanColorHead.a, "Scan head color as r,g,b,a"); cfgScanColor = config.Bind("Style", "ScanColor", scanColor.r + "," + scanColor.g + "," + scanColor.b + "," + scanColor.a, "Scan body color as r,g,b,a"); cfgOutlineWidth = config.Bind("Style", "OutlineWidth", outlineWidth, "Outline width"); cfgScanLineWidth = config.Bind("Style", "ScanLineWidth", scanLineWidth, "Scan line width"); cfgScanLineInterval = config.Bind("Style", "ScanLineInterval", scanLineInterval, "Scan line interval"); cfgHeadScanLineWidth = config.Bind("Style", "HeadScanLineWidth", headScanLineWidth, "Head scan line width"); cfgScanLineBrightness = config.Bind("Style", "ScanLineBrightness", scanLineBrightness, "Scan line brightness"); cfgScanRange = config.Bind("Style", "ScanRange", scanRange, "Scan range"); cfgOutlineBrightness = config.Bind("Style", "OutlineBrightness", outlineBrightness, "Outline brightness"); cfgHeadScanLineDistance = config.Bind("Style", "HeadScanLineDistance", headScanLineDistance, "Head scan line distance"); cfgScanCenterWS = config.Bind("Style", "ScanCenterWS", scanCenterWS.x + "," + scanCenterWS.y + "," + scanCenterWS.z, "Scan center world-space as x,y,z"); cfgOutlineStarDistance = config.Bind("Style", "OutlineStarDistance", outlineStarDistance, "Outline star distance"); cfgSteepSpawnProb = config.Bind("prob", "SteepSpawnProb", steepSpawnProb, "Probability to spawn particle on steep slopes (category 3)"); cfgMidSpawnProb = config.Bind("prob", "MidSpawnProb", midSpawnProb, "Probability to spawn particle on mid slopes (category 2)"); cfgFlatSpawnProb = config.Bind("prob", "FlatSpawnProb", flatSpawnProb, "Probability to spawn particle on flat slopes (category 1)"); cfgHorizontalCount = config.Bind("Performance", "HorizontalCount", horizontalCount, "Number of horizontal samples"); cfgVerticalCount = config.Bind("Performance", "VerticalCount", verticalCount, "Number of vertical samples"); cfgGridStep = config.Bind("Performance", "GridStep", gridStep, "Grid step size"); 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(); }; cfgSteepSpawnProb.SettingChanged += delegate { UpdateFromConfig(); }; cfgMidSpawnProb.SettingChanged += delegate { UpdateFromConfig(); }; cfgFlatSpawnProb.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) 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; steepSpawnProb = cfgSteepSpawnProb.Value; midSpawnProb = cfgMidSpawnProb.Value; flatSpawnProb = cfgFlatSpawnProb.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) 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; } } } 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("moe.blumewmew.TerrainScanner", "TerrainScanner", "1.1.3")] 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 = "moe.blumewmew.TerrainScanner"; public static string Name => "TerrainScanner"; public static string Version => "1.1.3"; 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() { BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "TerrainScanner.peakbundle", (Action)delegate(PeakBundle peakBundle) { Material val = peakBundle.LoadAsset("Assets/Material/Scan.mat"); Material val2 = peakBundle.LoadAsset("Assets/Shader/TerrianMarks.mat"); GameObject val3 = peakBundle.LoadAsset("Assets/Particles/LightParticle1.prefab"); GameObject val4 = peakBundle.LoadAsset("Assets/Particles/LightParticle2.prefab"); GameObject val5 = peakBundle.LoadAsset("Assets/Particles/LightParticle3.prefab"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[ERROR] Scan material failed to load from AssetBundle."); } else if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)"[ERROR] TerrianMarks.mat failed to load from AssetBundle."); } else if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { Logger.LogError((object)"[ERROR] One or more mark particles failed to load from AssetBundle."); } else { Logger.LogInfo((object)"[INFO] All assets loaded successfully from AssetBundle."); try { if (ScanConfigManager.Current != null) { ScanConfigManager.Current.scanMaterial = val; ScanConfigManager.Current.markMaterial = val2; ScanConfigManager.Current.markParticle1 = val3; ScanConfigManager.Current.markParticle2 = val4; ScanConfigManager.Current.markParticle3 = val5; } } catch (Exception ex) { Logger.LogWarning((object)("[WARN] Failed to assign loaded assets to ScanConfigManager.Current: " + ex.Message)); } assetsLoaded = true; try { if ((Object)(object)val != (Object)null) { ManualLogSource logger = Logger; Shader shader = val.shader; logger.LogInfo((object)("[DIAG] scanMaterial shader=" + (((shader != null) ? ((Object)shader).name : null) ?? "null"))); Logger.LogInfo((object)string.Format("[DIAG] scanMaterial has scanRange? {0}", val.HasProperty("scanRange"))); Logger.LogInfo((object)string.Format("[DIAG] scanMaterial has scanLineBrightness? {0}", val.HasProperty("scanLineBrightness"))); Logger.LogInfo((object)$"[DIAG] scanMaterial renderQueue={val.renderQueue} instancing={val.enableInstancing}"); } if ((Object)(object)val2 != (Object)null) { ManualLogSource logger2 = Logger; Shader shader2 = val2.shader; logger2.LogInfo((object)("[DIAG] markMaterial shader=" + (((shader2 != null) ? ((Object)shader2).name : null) ?? "null"))); Logger.LogInfo((object)$"[DIAG] markMaterial instancing={val2.enableInstancing} renderQueue={val2.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 feature) { Logger.LogInfo((object)"[DEBUG] ScanFeature already exists. Configuring..."); activeScanFeature = feature; try { ScanConfigManager.RegisterFeature(feature); } catch (Exception ex) { Logger.LogWarning((object)("[WARN] RegisterFeature failed: " + ex.Message)); } scanFeatureInitialized = true; return; } } ScanFeature scanFeature = ScriptableObject.CreateInstance(); ((Object)scanFeature).name = "TerrainScanner_ScanFeature"; ((ScriptableRendererData)val2).rendererFeatures.Add((ScriptableRendererFeature)(object)scanFeature); Logger.LogInfo((object)"[SUCCESS] ScanFeature created and added to renderer!"); activeScanFeature = scanFeature; try { ScanConfigManager.RegisterFeature(scanFeature); } catch (Exception ex2) { Logger.LogWarning((object)("[WARN] RegisterFeature failed: " + ex2.Message)); } scanFeatureInitialized = true; Logger.LogInfo((object)"[SUCCESS] ScanFeature initialized!"); } } } namespace TerrainScanner.DS { public class ActiveScan : MonoBehaviour { public static KeyCode activeKey; private void Start() { } private void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(activeKey)) { 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)); } } 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) UniversalResourceData val = frameData.Get(); TextureHandle activeColorTexture = val.activeColorTexture; TextureHandle activeDepthTexture = val.activeDepthTexture; PassData passData = default(PassData); IRasterRenderGraphBuilder val2 = renderGraph.AddRasterRenderPass(_passName, ref passData, "./src/TerrainScanner/DS/ScanFeature.cs", 160); 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); ((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_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown int num = <>1__state; try { if (num == 0) { goto IL_039e; } 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) { scanMaterial.SetVector(ScanCenterWs, Vector4.op_Implicit(val)); scanMaterial.SetFloat(HeadScanLineDistance, 4f); TweenerCore val2 = TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFloat(scanMaterial, 250f, 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, 5f, ScanRange, 1.5f), (Ease)2), 1f); scanMaterial.SetFloat(ScanLineBrightness, 0.3f); scanMaterial.SetFloat(HeadScanLineBrightness, 0f); TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, 1f, ScanLineBrightness, 0.2f), 0.25f); TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, 1f, 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, 1f); scanMaterial.SetFloat(OutlineStarDistance, 0f); TweenSettingsExtensions.SetEase>(TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOFloat(scanMaterial, 0f, OutlineBrightness, 0.5f), 2.25f), (Ease)1); TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFloat(scanMaterial, 30f, OutlineStarDistance, 1f), (Ease)8); } if ((Object)(object)markMaterial != (Object)null) { markMaterial.SetFloat(ColorAlpha, 0f); ShortcutExtensions.DOFloat(markMaterial, 1f, ColorAlpha, 1f); 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_039e; } ManualLogSource logger5 = TerrainScannerPlugin.Logger; if (logger5 != null) { logger5.LogError((object)"[ERROR] ScanFeature scanMaterial is null. Assets may not be loaded yet."); } } goto end_IL_0007; IL_039e: 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 logger6 = TerrainScannerPlugin.Logger; if (logger6 != null) { logger6.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 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 steepProb; public ScanConfig config; public float midProb; public float flatProb; 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_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_00f3: 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_00c9: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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; } else if (normal.y < Mathf.Cos(0.87266463f)) { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Steep; marks[num].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < steepProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 3, config); } } else if (normal.y < Mathf.Cos(MathF.PI / 6f)) { marks[num].markCategory = ScanRaySampling.RayMarkCategory.MidSlope; marks[num].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < midProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 1, config); } } else { marks[num].markCategory = ScanRaySampling.RayMarkCategory.Flat; marks[num].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < flatProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 1, 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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; } <>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 num9, 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_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_00f3: 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_00c9: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) int num8 = num9 * <>8__1.horizCount + j; if (num8 >= 0 && num8 < <>8__1.marks.Length) { if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { <>8__1.marks[num8].markCategory = ScanRaySampling.RayMarkCategory.Undefined; <>8__1.marks[num8].markPosition = Vector3.zero; } else { Vector3 normal = ((RaycastHit)(ref hit)).normal; if (((RaycastHit)(ref hit)).collider.isTrigger) { <>8__1.marks[num8].markCategory = ScanRaySampling.RayMarkCategory.Road; <>8__1.marks[num8].markPosition = Vector3.zero; } else if (normal.y < Mathf.Cos(0.87266463f)) { <>8__1.marks[num8].markCategory = ScanRaySampling.RayMarkCategory.Steep; <>8__1.marks[num8].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < <>8__1.steepProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 3, <>8__1.config); } } else if (normal.y < Mathf.Cos(MathF.PI / 6f)) { <>8__1.marks[num8].markCategory = ScanRaySampling.RayMarkCategory.MidSlope; <>8__1.marks[num8].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < <>8__1.midProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 1, <>8__1.config); } } else { <>8__1.marks[num8].markCategory = ScanRaySampling.RayMarkCategory.Flat; <>8__1.marks[num8].markPosition = ((RaycastHit)(ref hit)).point; if (Random.value < <>8__1.flatProb) { ParticleSpawner.ShootParticle(((RaycastHit)(ref hit)).point, normal, 1, <>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 num4 = 0; for (int num5 = 0; num5 < <>8__1.marks.Length; num5++) { if (<>8__1.marks[num5].markCategory != ScanRaySampling.RayMarkCategory.Undefined || <>8__1.marks[num5].markPosition != Vector3.zero) { num4++; } } if (num4 <= 0) { result = null; } else { Marks[] array = new Marks[num4]; int num6 = 0; for (int num7 = 0; num7 < <>8__1.marks.Length; num7++) { if (<>8__1.marks[num7].markCategory != ScanRaySampling.RayMarkCategory.Undefined || <>8__1.marks[num7].markPosition != Vector3.zero) { array[num6++] = <>8__1.marks[num7]; } } 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, Flat, MidSlope, Steep, 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 int horizCount; public float gridStep; public int layerMask; public Action onHit; public int maxRays; public int vertCount; private Vector3 5__2; private Vector3 5__3; private float 5__4; private float 5__5; private float 5__6; private float 5__7; private float 5__8; private int 5__9; private Vector3 5__10; private int 5__11; private Awaiter <>u__1; private void MoveNext() { //IL_0356: 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_0363: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0321: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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) //IL_00d9: 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_02aa: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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 { if (num != 0) { 5__2 = player.forward; 5__3 = player.right; float y = player.position.y; if ((Object)(object)Camera.main != (Object)null) { y = ((Component)Camera.main).transform.position.y; } y += config?.sampling_originHeightOffset ?? 0.9f; Vector3 val = new Vector3(player.position.x, y, player.position.z) + 5__2 * (config?.sampling_forwardOffset ?? 1f); 5__4 = config?.sampling_centerShapeExponent ?? 0.75f; 5__5 = config?.sampling_jitterScale ?? 0.06f; 5__6 = config?.sampling_rowStepMultiplier ?? 0.9f; 5__7 = (float)horizCount * gridStep * 0.5f; 5__8 = config?.sampling_maxDistanceShort ?? 12f; 5__9 = 0; 5__10 = val - 5__2 * (gridStep * 0.5f); 5__11 = 0; goto IL_038b; } Awaiter val2 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_0372; IL_038b: if (5__11 < vertCount) { float num2 = (float)5__11 * gridStep * 5__6; Vector3 val3 = 5__10 + 5__2 * num2; int num3 = 0; RaycastHit arg = default(RaycastHit); while (true) { if (num3 >= horizCount) { YieldAwaitable val4 = UniTask.Yield(); val2 = ((YieldAwaitable)(ref val4)).GetAwaiter(); if (((Awaiter)(ref val2)).IsCompleted) { break; } num = (<>1__state = 0); <>u__1 = val2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__1>(ref val2, ref this); return; } float num4 = ((horizCount == 1) ? 0f : ((float)num3 / (float)(horizCount - 1) - 0.5f)); float num5 = Mathf.Sign(num4) * Mathf.Pow(Mathf.Abs(num4), 5__4); float num6 = num5 * 5__7; float num7 = Random.Range(0f - 5__5, 5__5) * gridStep; float num8 = Random.Range(0f - 5__5, 5__5) * gridStep; Vector3 val5 = val3 - 5__3 * (num6 + num7) + 5__2 * num8; Physics.Raycast(val5, Vector3.down, ref arg, 5__8, layerMask); try { onHit?.Invoke(arg, 5__11, num3); } catch (Exception ex) { ManualLogSource logger = TerrainScannerPlugin.Logger; if (logger != null) { logger.LogWarning((object)("[ScanRaySampling] onHit callback threw: " + ex.Message)); } } 5__9++; if (5__9 < maxRays) { num3++; continue; } goto end_IL_001e; } goto IL_0372; } goto end_IL_001e; IL_0372: ((Awaiter)(ref val2)).GetResult(); 5__11++; goto IL_038b; end_IL_001e:; } catch (Exception arg2) { ManualLogSource logger2 = TerrainScannerPlugin.Logger; if (logger2 != null) { logger2.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) { } } }