using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Xml; using System.Xml.Serialization; using Atlas; using BepInEx; using BepInEx.Logging; using FistVR; using HarmonyLib; using Sodalite.Api; using Sodalite.Utilities; using Technie.PhysicsCreator.QHull; using UnityEditor; using UnityEngine; using UnityEngine.AI; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace MeatKit { public class HideInNormalInspectorAttribute : PropertyAttribute { } } namespace Danny.HitmeatSampleScene { [BepInPlugin("Danny.HitmeatSampleScene", "HitmeatSampleScene", "1.0.1")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("nrgill28.Atlas", "1.0.1")] public class HitmeatSampleScenePlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Danny.HitmeatSampleScene"); AtlasPlugin.RegisterScene(Path.Combine(BasePath, "hitmeat sample scene")); } } } namespace SimpleLightProbePlacer { [RequireComponent(typeof(LightProbeGroup))] [AddComponentMenu("Rendering/Light Probe Group Control")] public class LightProbeGroupControl : MonoBehaviour { [SerializeField] private float m_mergeDistance = 0.5f; [SerializeField] private bool m_usePointLights = true; [SerializeField] private float m_pointLightRange = 1f; private int m_mergedProbes; private LightProbeGroup m_lightProbeGroup; public float MergeDistance { get { return m_mergeDistance; } set { m_mergeDistance = value; } } public int MergedProbes => m_mergedProbes; public bool UsePointLights { get { return m_usePointLights; } set { m_usePointLights = value; } } public float PointLightRange { get { return m_pointLightRange; } set { m_pointLightRange = value; } } public LightProbeGroup LightProbeGroup { get { if ((Object)(object)m_lightProbeGroup != (Object)null) { return m_lightProbeGroup; } return m_lightProbeGroup = ((Component)this).GetComponent(); } } public void DeleteAll() { LightProbeGroup.probePositions = null; m_mergedProbes = 0; } public void Create() { DeleteAll(); List list = CreatePositions(); list.AddRange(CreateAroundPointLights(m_pointLightRange)); list = MergeClosestPositions(list, m_mergeDistance, out m_mergedProbes); ApplyPositions(list); } public void Merge() { if (LightProbeGroup.probePositions != null) { List source = MergeClosestPositions(LightProbeGroup.probePositions.ToList(), m_mergeDistance, out m_mergedProbes); source = source.Select((Vector3 x) => ((Component)this).transform.TransformPoint(x)).ToList(); ApplyPositions(source); } } private void ApplyPositions(List positions) { LightProbeGroup.probePositions = positions.Select((Vector3 x) => ((Component)this).transform.InverseTransformPoint(x)).ToArray(); } private static List CreatePositions() { LightProbeVolume[] array = Object.FindObjectsOfType(); if (array.Length == 0) { return new List(); } List list = new List(); for (int i = 0; i < array.Length; i++) { list.AddRange(array[i].CreatePositions()); } return list; } private static List CreateAroundPointLights(float range) { List list = (from x in Object.FindObjectsOfType() where (int)x.type == 2 select x).ToList(); if (list.Count == 0) { return new List(); } List list2 = new List(); for (int i = 0; i < list.Count; i++) { list2.AddRange(CreatePositionsAround(((Component)list[i]).transform, range)); } return list2; } private static List MergeClosestPositions(List positions, float distance, out int mergedCount) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) if (positions == null) { mergedCount = 0; return new List(); } int count = positions.Count; bool flag = false; while (!flag) { Dictionary> dictionary = new Dictionary>(); for (int i = 0; i < positions.Count; i++) { List list = positions.Where(delegate(Vector3 x) { //IL_0000: 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_001c: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = x - positions[i]; return ((Vector3)(ref val2)).magnitude < distance; }).ToList(); if (list.Count > 0 && !dictionary.ContainsKey(positions[i])) { dictionary.Add(positions[i], list); } } positions.Clear(); List list2 = dictionary.Keys.ToList(); for (int j = 0; j < list2.Count; j++) { Vector3 center = dictionary[list2[j]].Aggregate(Vector3.zero, (Vector3 result, Vector3 target) => result + target) / (float)dictionary[list2[j]].Count; if (!positions.Exists((Vector3 x) => x == center)) { positions.Add(center); } } flag = positions.Select((Vector3 x) => positions.Where(delegate(Vector3 y) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) int result2; if (y != x) { Vector3 val = y - x; result2 = ((((Vector3)(ref val)).magnitude < distance) ? 1 : 0); } else { result2 = 0; } return (byte)result2 != 0; })).All((IEnumerable x) => !x.Any()); } mergedCount = count - positions.Count; return positions; } public static List CreatePositionsAround(Transform transform, float range) { //IL_0031: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) Vector3[] source = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f) }; return source.Select((Vector3 x) => transform.TransformPoint(x * range)).ToList(); } } public enum LightProbeVolumeType { Fixed, Float } [AddComponentMenu("Rendering/Light Probe Volume")] public class LightProbeVolume : TransformVolume { [SerializeField] private LightProbeVolumeType m_type = LightProbeVolumeType.Fixed; [SerializeField] private Vector3 m_densityFixed = Vector3.one; [SerializeField] private Vector3 m_densityFloat = Vector3.one; public LightProbeVolumeType Type { get { return m_type; } set { m_type = value; } } public Vector3 Density { get { //IL_0018: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return (m_type != 0) ? m_densityFloat : m_densityFixed; } set { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (m_type == LightProbeVolumeType.Fixed) { m_densityFixed = value; } else { m_densityFloat = value; } } } public static Color EditorColor => new Color(1f, 0.9f, 0.25f); public List CreatePositions() { return CreatePositions(m_type); } public List CreatePositions(LightProbeVolumeType type) { //IL_0030: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return (type != 0) ? CreatePositionsFloat(((Component)this).transform, base.Origin, base.Size, Density) : CreatePositionsFixed(((Component)this).transform, base.Origin, base.Size, Density); } public static List CreatePositionsFixed(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 val = origin; float num = size.x / (float)Mathf.FloorToInt(density.x); float num2 = size.y / (float)Mathf.FloorToInt(density.y); float num3 = size.z / (float)Mathf.FloorToInt(density.z); val -= size * 0.5f; for (int i = 0; (float)i <= density.x; i++) { for (int j = 0; (float)j <= density.y; j++) { for (int k = 0; (float)k <= density.z; k++) { Vector3 val2 = val + new Vector3((float)i * num, (float)j * num2, (float)k * num3); val2 = volumeTransform.TransformPoint(val2); list.Add(val2); } } } return list; } public static List CreatePositionsFloat(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) //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_005a: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) List list = new List(); Vector3 val = origin; int num = Mathf.FloorToInt(size.x / density.x); int num2 = Mathf.FloorToInt(size.y / density.y); int num3 = Mathf.FloorToInt(size.z / density.z); val -= size * 0.5f; val.x += (size.x - (float)num * density.x) * 0.5f; val.y += (size.y - (float)num2 * density.y) * 0.5f; val.z += (size.z - (float)num3 * density.z) * 0.5f; for (int i = 0; i <= num; i++) { for (int j = 0; j <= num2; j++) { for (int k = 0; k <= num3; k++) { Vector3 val2 = val + new Vector3((float)i * density.x, (float)j * density.y, (float)k * density.z); val2 = volumeTransform.TransformPoint(val2); list.Add(val2); } } } return list; } } [AddComponentMenu("")] public class TransformVolume : MonoBehaviour { [SerializeField] private Volume m_volume = new Volume(Vector3.zero, Vector3.one); public Volume Volume { get { return m_volume; } set { m_volume = value; } } public Vector3 Origin => m_volume.Origin; public Vector3 Size => m_volume.Size; public bool IsInBounds(Vector3[] points) { //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_000c: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = GetBounds(); return ((Bounds)(ref bounds)).Intersects(GetBounds(points)); } public bool IsOnBorder(Vector3[] points) { if (points.All((Vector3 x) => !IsInVolume(x))) { return false; } return !points.All(IsInVolume); } public bool IsInVolume(Vector3[] points) { return points.All(IsInVolume); } public bool IsInVolume(Vector3 position) { //IL_000d: 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_0020: Unknown result type (might be due to invalid IL or missing references) Plane val = default(Plane); for (int i = 0; i < 6; i++) { ((Plane)(ref val))..ctor(GetSideDirection(i), GetSidePosition(i)); if (((Plane)(ref val)).GetSide(position)) { return false; } } return true; } public Vector3[] GetCorners() { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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) Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f) }; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference.x *= m_volume.Size.x; ref Vector3 reference2 = ref array[i]; reference2.y *= m_volume.Size.y; ref Vector3 reference3 = ref array[i]; reference3.z *= m_volume.Size.z; ref Vector3 reference4 = ref array[i]; reference4 = ((Component)this).transform.TransformPoint(m_volume.Origin + array[i]); } return array; } public Bounds GetBounds() { //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_0013: Unknown result type (might be due to invalid IL or missing references) return GetBounds(GetCorners()); } public Bounds GetBounds(Vector3[] points) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Vector3 val = points.Aggregate(Vector3.zero, (Vector3 result, Vector3 point) => result + point) / (float)points.Length; Bounds result2 = default(Bounds); ((Bounds)(ref result2))..ctor(val, Vector3.zero); for (int i = 0; i < points.Length; i++) { ((Bounds)(ref result2)).Encapsulate(points[i]); } return result2; } public GameObject[] GetGameObjectsInBounds(LayerMask layerMask) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) MeshRenderer[] array = Object.FindObjectsOfType(); List list = new List(); Bounds bounds = GetBounds(); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)((Component)array[i]).gameObject == (Object)(object)((Component)((Component)this).transform).gameObject) && !((Object)(object)((Component)array[i]).GetComponent() != (Object)null) && ((1 << ((Component)array[i]).gameObject.layer) & ((LayerMask)(ref layerMask)).value) != 0 && ((Bounds)(ref bounds)).Intersects(((Renderer)array[i]).bounds)) { list.Add(((Component)array[i]).gameObject); } } return list.ToArray(); } public Vector3 GetSideDirection(int side) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[6]; Vector3 right = Vector3.right; Vector3 up = Vector3.up; Vector3 forward = Vector3.forward; array[0] = right; ref Vector3 reference = ref array[1]; reference = -right; array[2] = up; ref Vector3 reference2 = ref array[3]; reference2 = -up; array[4] = forward; ref Vector3 reference3 = ref array[5]; reference3 = -forward; return ((Component)this).transform.TransformDirection(array[side]); } public Vector3 GetSidePosition(int side) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0090: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) Vector3[] array = (Vector3[])(object)new Vector3[6]; Vector3 right = Vector3.right; Vector3 up = Vector3.up; Vector3 forward = Vector3.forward; array[0] = right; ref Vector3 reference = ref array[1]; reference = -right; array[2] = up; ref Vector3 reference2 = ref array[3]; reference2 = -up; array[4] = forward; ref Vector3 reference3 = ref array[5]; reference3 = -forward; return ((Component)this).transform.TransformPoint(array[side] * GetSizeAxis(side) + m_volume.Origin); } public float GetSizeAxis(int side) { //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_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_0060: 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) switch (side) { case 0: case 1: return m_volume.Size.x * 0.5f; case 2: case 3: return m_volume.Size.y * 0.5f; default: return m_volume.Size.z * 0.5f; } } public static Volume EditorVolumeControl(TransformVolume transformVolume, float handleSize, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //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_00de: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0148: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: 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_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[6]; Transform transform = ((Component)transformVolume).transform; Handles.color = color; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference = transformVolume.GetSidePosition(i); } ref Vector3 reference2 = ref array[0]; reference2 = Handles.Slider(array[0], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference3 = ref array[1]; reference3 = Handles.Slider(array[1], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference4 = ref array[2]; reference4 = Handles.Slider(array[2], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference5 = ref array[3]; reference5 = Handles.Slider(array[3], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference6 = ref array[4]; reference6 = Handles.Slider(array[4], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference7 = ref array[5]; reference7 = Handles.Slider(array[5], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f); Vector3 origin = default(Vector3); origin.x = transform.InverseTransformPoint((array[0] + array[1]) * 0.5f).x; origin.y = transform.InverseTransformPoint((array[2] + array[3]) * 0.5f).y; origin.z = transform.InverseTransformPoint((array[4] + array[5]) * 0.5f).z; Vector3 size = default(Vector3); size.x = transform.InverseTransformPoint(array[0]).x - transform.InverseTransformPoint(array[1]).x; size.y = transform.InverseTransformPoint(array[2]).y - transform.InverseTransformPoint(array[3]).y; size.z = transform.InverseTransformPoint(array[4]).z - transform.InverseTransformPoint(array[5]).z; return new Volume(origin, size); } } [Serializable] public struct Volume { [SerializeField] private Vector3 m_origin; [SerializeField] private Vector3 m_size; public Vector3 Origin => m_origin; public Vector3 Size => m_size; public Volume(Vector3 origin, Vector3 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) m_origin = origin; m_size = size; } public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } public static bool operator !=(Volume left, Volume right) { return !left.Equals(right); } public bool Equals(Volume other) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) return Origin == other.Origin && Size == other.Size; } public override bool Equals(object obj) { if (object.ReferenceEquals(null, obj)) { return false; } return obj is Volume && Equals((Volume)obj); } public override int GetHashCode() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 origin = Origin; int num = ((object)(Vector3)(ref origin)).GetHashCode() * 397; Vector3 size = Size; return num ^ ((object)(Vector3)(ref size)).GetHashCode(); } public override string ToString() { //IL_0007: 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) return $"Origin: {Origin}, Size: {Size}"; } } } namespace nrgill28.AtlasSampleScene { public class CTF_CaptureZone : MonoBehaviour { public CTF_Manager Manager; public CTF_Team Team; public void OnTriggerEnter(Collider other) { CTF_Flag component = ((Component)other).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.Team != Team) { Manager.FlagCaptured(component); } } } public class CTF_Flag : FVRPhysicalObject { [Header("Flag stuffs")] public CTF_Team Team; public float RespawnDelay = 10f; public Vector3 FloorOffset = new Vector3(0f, 0.25f, 0f); private Vector3 _resetPosition; private Quaternion _resetRotation; private Transform _followTransform; private bool _isHeld; private bool _isTaken; private float _timer; private CTF_Sosig _heldBy; public override void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).Awake(); _resetPosition = ((Component)this).transform.position; _resetRotation = ((Component)this).transform.rotation; } private void Update() { if (_isTaken && !_isHeld) { _timer -= Time.deltaTime; if (_timer < 0f) { ReturnFlag(); } } } public void Take() { _isHeld = true; _isTaken = true; } public void Drop() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0040: 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) ((FVRInteractiveObject)this).IsHeld = false; _timer = RespawnDelay; NavMeshHit val = default(NavMeshHit); NavMesh.SamplePosition(((Component)this).transform.position, ref val, 100f, -1); ((Component)this).transform.position = ((NavMeshHit)(ref val)).position + FloorOffset; ((Component)this).transform.rotation = Quaternion.identity; } public void ReturnFlag() { //IL_0035: 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) if (((FVRInteractiveObject)this).IsHeld) { ((FVRInteractiveObject)this).ForceBreakInteraction(); } if (Object.op_Implicit((Object)(object)_heldBy)) { _heldBy.HeldFlag = null; } ((Component)this).transform.SetPositionAndRotation(_resetPosition, _resetRotation); _isTaken = false; } private void OnTriggerEnter(Collider other) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_isHeld) { return; } CTF_Sosig componentInParent = ((Component)other).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.Sosig.BodyState == 0) { if (componentInParent.Team == Team) { ReturnFlag(); return; } _heldBy = componentInParent; componentInParent.HeldFlag = this; Take(); } } public override void BeginInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).BeginInteraction(hand); Take(); } public override void EndInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).EndInteraction(hand); Drop(); } } public class CTF_Manager : MonoBehaviour { [Header("References")] public Text[] ScoreTexts; public Transform[] AttackPoints; public Text StartButtonText; [Header("Red Team")] public CTF_Flag RedFlag; public int RedTeamSize; public Transform[] RedSpawns; public SosigEnemyID[] RedTeam; [Header("Blue Team")] public CTF_Flag BlueFlag; public int BlueTeamSize; public Transform[] BlueSpawns; public SosigEnemyID[] BlueTeam; private int _blueScore; private int _redScore; private bool _running; private readonly List _sosigs = new List(); private readonly SpawnOptions _spawnOptions; public CTF_Manager() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown SpawnOptions val = new SpawnOptions(); val.SpawnState = (SosigOrder)7; val.SpawnActivated = true; val.EquipmentMode = (EquipmentSlots)7; val.SpawnWithFullAmmo = true; _spawnOptions = val; ((MonoBehaviour)this)..ctor(); } private void Start() { UpdateScoreText(); } public void ToggleGame() { if (_running) { EndGame(); StartButtonText.text = "Start Game"; } else { StartGame(); StartButtonText.text = "Stop Game"; } } private void StartGame() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ResetGame(); _running = true; GM.CurrentSceneSettings.SosigKillEvent += new SosigKill(CurrentSceneSettingsOnSosigKillEvent); ((MonoBehaviour)this).StartCoroutine(DoInitialSpawns()); } private void EndGame() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown GM.CurrentSceneSettings.SosigKillEvent -= new SosigKill(CurrentSceneSettingsOnSosigKillEvent); foreach (CTF_Sosig sosig in _sosigs) { sosig.Sosig.ClearSosig(); } _running = false; } private void CurrentSceneSettingsOnSosigKillEvent(Sosig s) { CTF_Sosig cTF_Sosig = _sosigs.FirstOrDefault((CTF_Sosig x) => (Object)(object)x.Sosig == (Object)(object)s); if (Object.op_Implicit((Object)(object)cTF_Sosig)) { ((MonoBehaviour)this).StartCoroutine(RespawnSosig(cTF_Sosig)); } } private void SpawnSosig(CTF_Team team) { //IL_001e: 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_006f: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) _spawnOptions.IFF = (int)team; _spawnOptions.SosigTargetPosition = SodaliteUtils.GetRandom((IList)AttackPoints).position; Transform transform; SosigEnemyID random; if (team == CTF_Team.Red) { transform = ((Component)SodaliteUtils.GetRandom((IList)RedSpawns)).transform; random = SodaliteUtils.GetRandom((IList)RedTeam); } else { transform = ((Component)SodaliteUtils.GetRandom((IList)BlueSpawns)).transform; random = SodaliteUtils.GetRandom((IList)BlueTeam); } Sosig val = SosigAPI.Spawn(ManagerSingleton.Instance.odicSosigObjsByID[random], _spawnOptions, transform.position, transform.rotation); CTF_Sosig cTF_Sosig = ((Component)val).gameObject.AddComponent(); _sosigs.Add(cTF_Sosig); cTF_Sosig.Sosig = val; cTF_Sosig.Team = team; } private IEnumerator DoInitialSpawns() { int i = 0; while (i < Mathf.Max(RedTeamSize, BlueTeamSize)) { if (i < RedTeamSize) { SpawnSosig(CTF_Team.Red); } if (i < BlueTeamSize) { SpawnSosig(CTF_Team.Blue); } i++; yield return (object)new WaitForSeconds(2.5f); } } private IEnumerator RespawnSosig(CTF_Sosig sosig) { yield return (object)new WaitForSeconds(5f); sosig.Sosig.ClearSosig(); _sosigs.Remove(sosig); yield return (object)new WaitForSeconds(5f); if (_running) { int sosigsLeft = _sosigs.Count((CTF_Sosig x) => x.Team == sosig.Team); int teamSize = ((sosig.Team != 0) ? BlueTeamSize : RedTeamSize); if (sosigsLeft < teamSize) { SpawnSosig(sosig.Team); } } } public void ResetGame() { _blueScore = 0; _redScore = 0; UpdateScoreText(); if (Object.op_Implicit((Object)(object)RedFlag)) { RedFlag.ReturnFlag(); } if (Object.op_Implicit((Object)(object)BlueFlag)) { BlueFlag.ReturnFlag(); } } public void FlagCaptured(CTF_Flag flag) { if (flag.Team == CTF_Team.Red) { _blueScore++; } else { _redScore++; } UpdateScoreText(); flag.ReturnFlag(); } public void UpdateScoreText() { Text[] scoreTexts = ScoreTexts; foreach (Text val in scoreTexts) { val.text = "" + _redScore + " - " + _blueScore + ""; } } private void OnDrawGizmos() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Gizmos.color = Color.red; Transform[] redSpawns = RedSpawns; foreach (Transform val in redSpawns) { Gizmos.DrawSphere(val.position, 0.15f); } Gizmos.color = Color.blue; Transform[] blueSpawns = BlueSpawns; foreach (Transform val2 in blueSpawns) { Gizmos.DrawSphere(val2.position, 0.15f); } Gizmos.color = Color.green; Transform[] attackPoints = AttackPoints; foreach (Transform val3 in attackPoints) { Gizmos.DrawSphere(val3.position, 0.15f); } } } public class CTF_Sosig : MonoBehaviour { public CTF_Team Team; public CTF_Flag HeldFlag; public Sosig Sosig; private void Awake() { Sosig = ((Component)this).GetComponent(); } private void Update() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0041: 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_0059: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)HeldFlag)) { Vector3 val = ((Component)Sosig).transform.position - ((Component)Sosig).transform.forward * 0.1f; ((Component)HeldFlag).transform.SetPositionAndRotation(val, ((Component)Sosig).transform.rotation); } } } public enum CTF_Team { Red, Blue } public class PopupTarget : MonoBehaviour, IFVRDamageable { [Flags] public enum TargetRange { Near = 1, Mid = 2, Far = 4, All = 7 } public PopupTargetManager Manager; public TargetRange Range; public Transform Pivot; public Vector3 SetRotation; private Quaternion _startRotation; private Quaternion _endRotation; private bool _set; public bool Set { get { return _set; } set { //IL_003e: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (_set != value) { _set = value; ((MonoBehaviour)this).StartCoroutine((!_set) ? RotateTo(_endRotation, _startRotation) : RotateTo(_startRotation, _endRotation)); } } } private void Awake() { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) _startRotation = Pivot.rotation; _endRotation = Quaternion.Euler(SetRotation + ((Quaternion)(ref _startRotation)).eulerAngles); } void IFVRDamageable.Damage(Damage dam) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (Set && (int)dam.Class == 1) { Set = false; Manager.TargetHit(this); } } private IEnumerator RotateTo(Quaternion from, Quaternion to) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float elapsed = 0f; while (elapsed < 0.25f) { yield return null; elapsed += Time.deltaTime; Pivot.localRotation = Quaternion.Slerp(from, to, elapsed / 0.25f); } Pivot.rotation = to; } } public class PopupTargetManager : MonoBehaviour { public List Targets; private readonly List _setTargets = new List(); private void Awake() { ((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All)); } private IEnumerator StartSetAsync(float minDelay, float maxDelay, int numTargets, PopupTarget.TargetRange ranges) { yield return (object)new WaitForSeconds(Random.Range(minDelay, maxDelay)); IListExtensions.Shuffle((IList)Targets); _setTargets.Clear(); foreach (PopupTarget target in Targets) { if ((target.Range & ranges) != 0) { target.Set = true; _setTargets.Add(target); numTargets--; } if (numTargets == 0) { break; } } } public void TargetHit(PopupTarget target) { if (_setTargets.Contains(target)) { _setTargets.Remove(target); if (_setTargets.Count == 0) { ((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All)); } } } } } public class HM_GameManager : MonoBehaviour { public int targets = 2; public int fillerSosigs = 18; public SosigEnemyID[] sosigTypes; public Transform[] sosigSpawnVolumes; public float timeBeforeSplodeAfterDeath = 5f; public HM_TargetNote notePrefab; public Transform noteSpawnPoint; public Text fillerSosigsText; public Text targetsText; private List livesosigs = new List(); private List targetsosigs = new List(); private List notes = new List(); private bool isgameactive = false; private int checkindex = 0; public Transform[] pathPoints; private void Update() { if (!isgameactive) { return; } if (livesosigs == null || livesosigs.Count <= 0) { checkindex = 0; return; } if (checkindex >= livesosigs.Count) { checkindex = 0; } SosigUpdate(); checkindex++; } private void SosigUpdate() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 if (livesosigs == null || livesosigs.Count == 0 || checkindex < 0 || checkindex >= livesosigs.Count) { return; } Sosig val = livesosigs[checkindex]; if ((Object)(object)val == (Object)null) { livesosigs.RemoveAt(checkindex); } else if ((int)val.BodyState == 3) { val.TickDownToClear(timeBeforeSplodeAfterDeath); if (targetsosigs.Contains(val)) { targetsosigs.Remove(val); } livesosigs.RemoveAt(checkindex); } } public void StartGame() { CleanUpGame(); SpawnFillerSosigs(); SpawnTargets(); isgameactive = true; } public void CleanUpGame() { foreach (HM_TargetNote note in notes) { if (((FVRInteractiveObject)note).IsHeld) { ((FVRInteractiveObject)note).EndInteraction(((FVRInteractiveObject)note).m_hand); } Object.Destroy((Object)(object)((Component)note).gameObject); } notes.Clear(); foreach (Sosig livesosig in livesosigs) { livesosig.DeSpawnSosig(); } livesosigs.Clear(); targetsosigs.Clear(); checkindex = 0; isgameactive = false; } public void SpawnFillerSosigs() { for (int i = 0; i < fillerSosigs; i++) { Sosig val = SpawnSosig(sosigTypes[Random.Range(0, sosigTypes.Length)], sosigSpawnVolumes[Random.Range(0, sosigSpawnVolumes.Length)]); livesosigs.Add(val); CreatePathPoints(val); } } public void SpawnTargets() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) for (int i = 0; i < targets; i++) { Sosig val = SpawnSosig(sosigTypes[Random.Range(0, sosigTypes.Length)], sosigSpawnVolumes[Random.Range(0, sosigSpawnVolumes.Length)]); livesosigs.Add(val); targetsosigs.Add(val); CreatePathPoints(val); Vector3 position = noteSpawnPoint.position; position += Vector3.up * ((float)i * 0.15f); CreateTargetNote(val, position); } } public void CreatePathPoints(Sosig sos) { //IL_00ab: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); for (int i = 0; i < pathPoints.Length; i++) { list3.Add(i); } for (int j = 0; j < list3.Count; j++) { int index = Random.Range(j, list3.Count); int value = list3[j]; list3[j] = list3[index]; list3[index] = value; } foreach (int item in list3) { Transform val = pathPoints[item]; list.Add(val.position); list2.Add(val.eulerAngles); } sos.CommandPathTo(list, list2, 1f, Vector2.one * 4f, 2f, (SosigMoveSpeed)3, (PathLoopType)4, (List)null, 0.2f, 1f, false, 50f); } public void CreateTargetNote(Sosig target, Vector3 spawnpos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) HM_TargetNote hM_TargetNote = Object.Instantiate(notePrefab, spawnpos, noteSpawnPoint.rotation); notes.Add(hM_TargetNote); hM_TargetNote.mytarget = target; ((MonoBehaviour)this).StartCoroutine(hM_TargetNote.TakeTargetSnapshot()); } public Sosig SpawnSosig(int sosid, Transform spawnpos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0034: 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_005e: 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) Vector3 spawnPositionInArea = GetSpawnPositionInArea(spawnpos); SpawnOptions val = new SpawnOptions(); val.SpawnState = (SosigOrder)6; val.SpawnActivated = true; val.EquipmentMode = (EquipmentSlots)7; val.SpawnWithFullAmmo = true; val.IFF = -3; val.SosigTargetPosition = spawnPositionInArea; val.SosigTargetRotation = ((Component)spawnpos).transform.eulerAngles; SpawnOptions val2 = val; Sosig val3 = SosigAPI.Spawn(ManagerSingleton.Instance.odicSosigObjsByID[(SosigEnemyID)sosid], val2, spawnPositionInArea, ((Component)spawnpos).transform.rotation); val3.IgnoresNeedForWeapons = true; return val3; } public Sosig SpawnSosig(SosigEnemyID sosid, Transform spawnpos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0034: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 spawnPositionInArea = GetSpawnPositionInArea(spawnpos); SpawnOptions val = new SpawnOptions(); val.SpawnState = (SosigOrder)6; val.SpawnActivated = true; val.EquipmentMode = (EquipmentSlots)7; val.SpawnWithFullAmmo = true; val.IFF = -3; val.SosigTargetPosition = spawnPositionInArea; val.SosigTargetRotation = ((Component)spawnpos).transform.eulerAngles; SpawnOptions val2 = val; Sosig val3 = SosigAPI.Spawn(ManagerSingleton.Instance.odicSosigObjsByID[sosid], val2, spawnPositionInArea, ((Component)spawnpos).transform.rotation); val3.IgnoresNeedForWeapons = true; return val3; } private Vector3 GetSpawnPositionInArea(Transform transform) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_007f: 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_0086: Unknown result type (might be due to invalid IL or missing references) Vector3 position = transform.position + Vector3.up * 1.7f; Vector3 val = transform.localScale / 2f; position.x += Random.Range(0f - val.x, val.x); position.z += Random.Range(0f - val.z, val.z); return GetValidNavPosition(position, 2f); } public static Vector3 RandomNavPointInVolume(Transform volume) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Vector3 position = volume.position; Vector3 val = volume.localScale * 0.5f; Vector3 val2 = Vector3.Scale(val, volume.lossyScale); float num = Random.Range(0f - val2.x, val2.x); float num2 = Random.Range(0f - val2.y, val2.y); float num3 = Random.Range(0f - val2.z, val2.z); return position + volume.right * num + volume.up * num2 + volume.forward * num3; } public static Vector3 GetClosestValidDownPoint(Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0045: 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) RaycastHit val = default(RaycastHit); if (Physics.Raycast(point, Vector3.down, ref val, 20f)) { point = ((RaycastHit)(ref val)).point; point = GetValidNavPosition(point, 2f); } else { point = GetValidNavPosition(point, 2f); } return point; } public static Vector3 GetValidNavPosition(Vector3 position, float distance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, distance, -1)) { return ((NavMeshHit)(ref val)).position; } return position; } public void ChangeFillerSosigs(int changeby) { if (fillerSosigs + changeby > 0) { fillerSosigs += changeby; fillerSosigsText.text = "Filler Sosigs: " + fillerSosigs; } } public void ChangeTargets(int changeby) { if (targets + changeby > 0) { targets += changeby; targetsText.text = "Targets: " + targets; } } } public class HM_TargetNote : FVRPhysicalObject { public Sosig mytarget; public MeshRenderer targetSnapshotRenderer; public MeshRenderer targetEliminatedRenderer; private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if ((Object)(object)mytarget != (Object)null && (int)mytarget.BodyState == 3) { ((Component)targetEliminatedRenderer).gameObject.SetActive(true); } } public IEnumerator TakeTargetSnapshot() { yield return (object)new WaitForSeconds(1f); GameObject camgo = new GameObject("TempCamera"); Camera cam = camgo.AddComponent(); cam.stereoTargetEye = (StereoTargetEyeMask)0; FrameTarget(camgo.transform); RenderTexture rt = (cam.targetTexture = new RenderTexture(512, 512, 24)); ((Behaviour)cam).enabled = true; cam.Render(); yield return (object)new WaitForEndOfFrame(); RenderTexture.active = rt; Texture2D photo = new Texture2D(512, 512, (TextureFormat)5, false); photo.ReadPixels(new Rect(0f, 0f, 512f, 512f), 0, 0); photo.Apply(); RenderTexture.active = null; cam.targetTexture = null; Object.Destroy((Object)(object)camgo); Object.Destroy((Object)(object)rt); ((Renderer)targetSnapshotRenderer).material.mainTexture = (Texture)(object)photo; } private void FrameTarget(Transform camPos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0089: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)mytarget.Links[0]).transform; Vector3 position = transform.position; Vector3 forward = transform.forward; Vector3 right = transform.right; camPos.position = position + forward * RandomBipolar(0.6f, 1.2f) + right * RandomBipolar(0.6f, 1.2f) + Vector3.up * Random.Range(-0.2f, 0.2f); camPos.LookAt(position); } private float RandomBipolar(float absMin, float absMax) { if (Random.value < 0.5f) { return Random.Range(0f - absMax, 0f - absMin); } return Random.Range(absMin, absMax); } } namespace Technie.PhysicsCreator { public class AxisAlignedBoxFitter { public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_000a: 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) Vector3[] selectedVertices = FaceAlignmentBoxFitter.GetSelectedVertices(hull, meshVertices, meshIndices); ConstructionPlane plane = new ConstructionPlane(Vector3.zero, Vector3.up, Vector3.right); RotatedBox computedBox = RotatedBoxFitter.FindTightestBox(plane, selectedVertices); RotatedBoxFitter.ApplyToHull(computedBox, hull); } } public class Pose { public Vector3 forward; public Vector3 up; public Vector3 right; } public class Triangle { public Vector3 normal; public float area; public Vector3 center; public Triangle(Vector3 p0, Vector3 p1, Vector3 p2) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Vector3 val = p1 - p0; Vector3 val2 = p2 - p0; Vector3 val3 = Vector3.Cross(val, val2); area = ((Vector3)(ref val3)).magnitude * 0.5f; normal = ((Vector3)(ref val3)).normalized; center = (p0 + p1 + p2) / 3f; } } public class TriangleBucket { private List triangles; private Vector3 averagedNormal; private Vector3 averagedCenter; private float totalArea; public float Area => totalArea; public TriangleBucket(Triangle initialTriangle) { triangles = new List(); triangles.Add(initialTriangle); CalculateNormal(); CalcTotalArea(); } public void Add(Triangle t) { triangles.Add(t); CalculateNormal(); CalcTotalArea(); } public void Add(TriangleBucket otherBucket) { foreach (Triangle triangle in otherBucket.triangles) { triangles.Add(triangle); } CalculateNormal(); CalcTotalArea(); } private void CalculateNormal() { //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) //IL_002f: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) averagedNormal = Vector3.zero; foreach (Triangle triangle in triangles) { averagedNormal += triangle.normal * triangle.area; } ((Vector3)(ref averagedNormal)).Normalize(); } public Vector3 GetAverageNormal() { //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_000d: Unknown result type (might be due to invalid IL or missing references) return averagedNormal; } public Vector3 GetAverageCenter() { //IL_000d: 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_0018: Unknown result type (might be due to invalid IL or missing references) return triangles[0].center; } private void CalcTotalArea() { totalArea = 0f; foreach (Triangle triangle in triangles) { totalArea += triangle.area; } } } public class TriangleAreaSorter : IComparer { public int Compare(Triangle lhs, Triangle rhs) { if (lhs.area < rhs.area) { return 1; } if (lhs.area > rhs.area) { return -1; } return 0; } } public class TriangleBucketSorter : IComparer { public int Compare(TriangleBucket lhs, TriangleBucket rhs) { if (lhs.Area < rhs.Area) { return 1; } if (lhs.Area > rhs.Area) { return -1; } return 0; } } public class FaceAlignmentBoxFitter { public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { if (meshIndices.Length < 3) { return; } List list = FindTriangles(meshVertices, meshIndices, hull.selectedFaces); list.Sort(new TriangleAreaSorter()); List list2 = new List(); foreach (Triangle item in list) { TriangleBucket triangleBucket = FindBestBucket(item, 30f, list2); if (triangleBucket != null) { triangleBucket.Add(item); continue; } triangleBucket = new TriangleBucket(item); list2.Add(triangleBucket); } while (list2.Count > 3) { MergeClosestBuckets(list2); } list2.Sort(new TriangleBucketSorter()); Vector3[] selectedVertices = GetSelectedVertices(hull, meshVertices, meshIndices); ConstructionPlane plane = CreateConstructionPlane(list2[0], (list2.Count <= 1) ? null : list2[1], (list2.Count <= 2) ? null : list2[2]); RotatedBox computedBox = RotatedBoxFitter.FindTightestBox(plane, selectedVertices); RotatedBoxFitter.ApplyToHull(computedBox, hull); } public static List FindTriangles(Vector3[] meshVertices, int[] meshIndices, List selectedFaces) { //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_004b: 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_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_0061: 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_0065: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (int selectedFace in selectedFaces) { int num = meshIndices[selectedFace * 3]; int num2 = meshIndices[selectedFace * 3 + 1]; int num3 = meshIndices[selectedFace * 3 + 2]; Vector3 p = meshVertices[num]; Vector3 p2 = meshVertices[num2]; Vector3 p3 = meshVertices[num3]; Triangle item = new Triangle(p, p2, p3); list.Add(item); } return list; } public static void FindTriangles(Hull hull, Vector3[] meshVertices, int[] meshIndices, out Vector3[] hullVertices, out int[] hullIndices) { //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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0077: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (int selectedFace in hull.selectedFaces) { int num = meshIndices[selectedFace * 3]; int num2 = meshIndices[selectedFace * 3 + 1]; int num3 = meshIndices[selectedFace * 3 + 2]; Vector3 item = meshVertices[num]; Vector3 item2 = meshVertices[num2]; Vector3 item3 = meshVertices[num3]; list.Add(item); list.Add(item2); list.Add(item3); } hullVertices = list.ToArray(); hullIndices = new int[hullVertices.Length]; for (int i = 0; i < hullIndices.Length; i++) { hullIndices[i] = i; } } public static Vector3[] GetSelectedVertices(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (int selectedFace in hull.selectedFaces) { int num = meshIndices[selectedFace * 3]; int num2 = meshIndices[selectedFace * 3 + 1]; int num3 = meshIndices[selectedFace * 3 + 2]; dictionary[num] = num; dictionary[num2] = num2; dictionary[num3] = num3; } List list = new List(); foreach (int key in dictionary.Keys) { list.Add(meshVertices[key]); } return list.ToArray(); } private TriangleBucket FindBestBucket(Triangle tri, float thresholdAngleDeg, List buckets) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) TriangleBucket result = null; float num = float.PositiveInfinity; foreach (TriangleBucket bucket in buckets) { float num2 = Vector3.Angle(tri.normal, bucket.GetAverageNormal()); if (num2 < thresholdAngleDeg && num2 < num) { num = num2; result = bucket; continue; } float num3 = Vector3.Angle(tri.normal * -1f, bucket.GetAverageNormal()); if (num3 < thresholdAngleDeg && num3 < num) { tri.normal *= -1f; num = num3; result = bucket; } } return result; } private void MergeClosestBuckets(List buckets) { //IL_0033: 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) TriangleBucket triangleBucket = null; TriangleBucket triangleBucket2 = null; float num = float.PositiveInfinity; for (int i = 0; i < buckets.Count; i++) { for (int j = i + 1; j < buckets.Count; j++) { TriangleBucket triangleBucket3 = buckets[i]; TriangleBucket triangleBucket4 = buckets[j]; float num2 = Vector3.Angle(triangleBucket3.GetAverageNormal(), triangleBucket4.GetAverageNormal()); if (num2 < num) { num = num2; triangleBucket = triangleBucket3; triangleBucket2 = triangleBucket4; } } } if (triangleBucket != null && triangleBucket2 != null) { buckets.Remove(triangleBucket2); triangleBucket.Add(triangleBucket2); } } private ConstructionPlane CreateConstructionPlane(TriangleBucket primaryBucket, TriangleBucket secondaryBucket, TriangleBucket tertiaryBucket) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002a: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (primaryBucket != null && secondaryBucket != null) { Vector3 averageNormal = primaryBucket.GetAverageNormal(); Vector3 t = Vector3.Cross(averageNormal, secondaryBucket.GetAverageNormal()); Vector3 averageCenter = primaryBucket.GetAverageCenter(); return new ConstructionPlane(averageCenter, averageNormal, t); } if (primaryBucket != null) { Vector3 averageNormal2 = primaryBucket.GetAverageNormal(); Vector3 averageCenter2 = primaryBucket.GetAverageCenter(); Vector3 t2 = Vector3.Cross(averageNormal2, (!(Vector3.Dot(averageNormal2, Vector3.up) > 0.5f)) ? Vector3.up : Vector3.right); return new ConstructionPlane(averageCenter2, averageNormal2, t2); } return null; } } public class GizmoUtils { public static void ToggleGizmos(bool gizmosOn) { int num = (gizmosOn ? 1 : 0); Assembly assembly = Assembly.GetAssembly(typeof(Editor)); Type type = assembly.GetType("UnityEditor.AnnotationUtility"); if ((object)type == null) { return; } MethodInfo method = type.GetMethod("GetAnnotations", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method2 = type.GetMethod("SetGizmoEnabled", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method3 = type.GetMethod("SetIconEnabled", BindingFlags.Static | BindingFlags.NonPublic); object obj = method.Invoke(null, null); foreach (object item in (IEnumerable)obj) { Type type2 = item.GetType(); FieldInfo field = type2.GetField("classID", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = type2.GetField("scriptClass", BindingFlags.Instance | BindingFlags.Public); if ((object)field == null || (object)field2 == null) { continue; } int num2 = (int)field.GetValue(item); string text = (string)field2.GetValue(item); if (text == "HullPainter") { switch (method2.GetParameters().Length) { case 3: method2.Invoke(null, new object[3] { num2, text, num }); break; case 4: method2.Invoke(null, new object[4] { num2, text, num, true }); break; } int num3 = method3.GetParameters().Length; if (num3 == 3) { method3.Invoke(null, new object[3] { num2, text, num }); } } } } } public class HullData : ScriptableObject { } public class HullMapping { public Hull sourceHull; public Collider generatedCollider; public MeshCollider[] autoGeneratedColliders; public HullPainterChild targetChild; public HullPainterChild[] targetAutoGeneratedChilds; public void AddAutoChild(HullPainterChild newChild, MeshCollider newCollider) { if ((Object)(object)newChild != (Object)null) { List list = new List(); if (targetAutoGeneratedChilds != null) { list.AddRange(targetAutoGeneratedChilds); } if (!list.Contains(newChild)) { list.Add(newChild); targetAutoGeneratedChilds = list.ToArray(); } } if ((Object)(object)newCollider != (Object)null) { List list2 = new List(); if (autoGeneratedColliders != null) { list2.AddRange(autoGeneratedColliders); } if (!list2.Contains(newCollider)) { list2.Add(newCollider); autoGeneratedColliders = list2.ToArray(); } } } } public class HullPainter : MonoBehaviour { public PaintingData paintingData; public HullData hullData; private List hullMapping; private Mesh debugMesh; private void OnDestroy() { SceneView.RepaintAll(); } public void CreateColliderComponents(Mesh[] autoHulls) { CreateHullMapping(); foreach (Hull hull in paintingData.hulls) { UpdateCollider(hull); } foreach (Hull hull2 in paintingData.hulls) { CreateAutoHulls(hull2, autoHulls); } } public void RemoveAllColliders() { if (hullMapping == null) { return; } foreach (HullMapping item in hullMapping) { DestroyImmediateWithUndo((Object)(object)item.generatedCollider); if (item.autoGeneratedColliders != null) { MeshCollider[] autoGeneratedColliders = item.autoGeneratedColliders; foreach (MeshCollider obj in autoGeneratedColliders) { DestroyImmediateWithUndo((Object)(object)obj); } } } for (int num = hullMapping.Count - 1; num >= 0; num--) { if ((Object)(object)hullMapping[num].targetChild != (Object)null) { hullMapping.RemoveAt(num); } } } public void RemoveAllGenerated() { CreateHullMapping(); foreach (HullMapping item in hullMapping) { DestroyImmediateWithUndo((Object)(object)item.generatedCollider); if ((Object)(object)item.targetChild != (Object)null) { DestroyImmediateWithUndo((Object)(object)((Component)item.targetChild).gameObject); } if (item.autoGeneratedColliders != null) { MeshCollider[] autoGeneratedColliders = item.autoGeneratedColliders; foreach (MeshCollider obj in autoGeneratedColliders) { DestroyImmediateWithUndo((Object)(object)obj); } } if (item.targetAutoGeneratedChilds == null) { continue; } HullPainterChild[] targetAutoGeneratedChilds = item.targetAutoGeneratedChilds; foreach (HullPainterChild hullPainterChild in targetAutoGeneratedChilds) { GameObject gameObject = ((Component)hullPainterChild).gameObject; DestroyImmediateWithUndo((Object)(object)hullPainterChild); if (gameObject.transform.childCount == 0 && gameObject.GetComponents().Length == 1) { DestroyImmediateWithUndo((Object)(object)gameObject); } } } } private static bool IsDeletable(GameObject obj) { Component[] components = obj.GetComponents(); int num = 0; Component[] array = components; foreach (Component val in array) { if (val is Transform || val is Collider || val is HullPainter || val is HullPainterChild) { num++; } } return components.Length == num; } private static void DestroyImmediateWithUndo(Object obj) { if (!(obj == (Object)null)) { Undo.DestroyObjectImmediate(obj); } } private void CreateHullMapping() { //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) if (this.hullMapping == null) { this.hullMapping = new List(); } for (int num = this.hullMapping.Count - 1; num >= 0; num--) { HullMapping hullMapping = this.hullMapping[num]; if (hullMapping == null || hullMapping.sourceHull == null || ((Object)(object)hullMapping.generatedCollider == (Object)null && (Object)(object)hullMapping.targetChild == (Object)null)) { this.hullMapping.RemoveAt(num); } } foreach (Hull hull4 in paintingData.hulls) { if (IsMapped(hull4)) { Collider val = FindExistingCollider(this.hullMapping, hull4); bool flag = hull4.type == HullType.ConvexHull && val is MeshCollider; bool flag2 = hull4.type == HullType.Box && val is BoxCollider; bool flag3 = hull4.type == HullType.Sphere && val is SphereCollider; bool flag4 = hull4.type == HullType.Face && val is MeshCollider; bool flag5 = hull4.type == HullType.FaceAsBox && val is BoxCollider; bool flag6 = hull4.type == HullType.Auto && val is MeshCollider && hull4.autoMeshes != null && hull4.autoMeshes.Length > 0; bool flag7 = flag || flag2 || flag3 || flag4 || flag5 || flag6; bool flag8 = (Object)(object)val == (Object)null || hull4.isChildCollider == ((Object)(object)((Component)val).transform.parent == (Object)(object)((Component)this).transform) || hull4.type == HullType.Auto; if (!flag7 || !flag8) { DestroyImmediateWithUndo((Object)(object)val); RemoveMapping(hull4); } } } List list = new List(); List list2 = new List(); List list3 = new List(); foreach (Hull hull5 in paintingData.hulls) { if (!IsMapped(hull5)) { list.Add(hull5); } } foreach (Collider item in FindLocal()) { if (!IsMapped(item)) { list2.Add(item); } } foreach (HullPainterChild item2 in FindLocal()) { if (!IsMapped(item2)) { list3.Add(item2); } } for (int num2 = list.Count - 1; num2 >= 0; num2--) { Hull hull = list[num2]; bool flag9 = false; for (int num3 = list2.Count - 1; num3 >= 0; num3--) { Collider val2 = list2[num3]; MeshCollider val3 = (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null); BoxCollider val4 = (BoxCollider)(object)((val2 is BoxCollider) ? val2 : null); SphereCollider val5 = (SphereCollider)(object)((val2 is SphereCollider) ? val2 : null); HullPainterChild hullPainterChild = null; if ((Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)this).transform) { hullPainterChild = ((Component)val2).gameObject.GetComponent(); } bool flag10 = hull.isChildCollider && (Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)this).transform; if ((Object)(object)hullPainterChild != (Object)null && hullPainterChild.isAutoHull && hull.type == HullType.Auto && (Object)(object)val3 != (Object)null && hull.ContainsAutoMesh(val3.sharedMesh)) { HullMapping hullMapping2 = FindMapping(hull); if (hullMapping2 == null) { hullMapping2 = new HullMapping(); hullMapping2.sourceHull = hull; this.hullMapping.Add(hullMapping2); } hullMapping2.AddAutoChild(hullPainterChild, (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null)); hullPainterChild.parent = this; list2.RemoveAt(num3); list3.Remove(hullPainterChild); flag9 = true; } else if (flag10) { bool flag11 = hull.type == HullType.Box && val2 is BoxCollider && Approximately(((Bounds)(ref hull.collisionBox)).center, val4.center) && Approximately(((Bounds)(ref hull.collisionBox)).size, val4.size); bool flag12 = hull.type == HullType.Sphere && val2 is SphereCollider && hull.collisionSphere != null && Approximately(hull.collisionSphere.center, val5.center) && Approximately(hull.collisionSphere.radius, val5.radius); bool flag13 = hull.type == HullType.ConvexHull && val2 is MeshCollider && (Object)(object)val3.sharedMesh == (Object)(object)hull.collisionMesh; bool flag14 = hull.type == HullType.Face && val2 is MeshCollider && (Object)(object)val3.sharedMesh == (Object)(object)hull.faceCollisionMesh; bool flag15 = hull.type == HullType.FaceAsBox && val2 is BoxCollider && Approximately(hull.faceBoxCenter, val4.center) && Approximately(hull.faceBoxSize, val4.size); if (flag11 || flag12 || flag13 || flag14 || flag15) { AddMapping(hull, val2, hullPainterChild); list.RemoveAt(num2); list2.RemoveAt(num3); for (int i = 0; i < list3.Count; i++) { if ((Object)(object)list3[i] == (Object)(object)hullPainterChild) { list3.RemoveAt(i); break; } } break; } } } if (flag9) { list.RemoveAt(num2); } } for (int num4 = list.Count - 1; num4 >= 0; num4--) { Hull hull2 = list[num4]; if (hull2.isChildCollider) { for (int num5 = list3.Count - 1; num5 >= 0; num5--) { HullPainterChild child = list3[num5]; HullMapping hullMapping3 = FindMapping(child); if (hullMapping3 != null && hullMapping3.sourceHull != null) { if ((Object)(object)hullMapping3.generatedCollider == (Object)null) { RecreateChildCollider(hullMapping3); } list.RemoveAt(num4); list3.RemoveAt(num5); break; } } } } for (int num6 = list.Count - 1; num6 >= 0; num6--) { Hull hull3 = list[num6]; if (hull3.isChildCollider && hull3.type == HullType.Auto) { bool flag16 = false; for (int num7 = list3.Count - 1; num7 >= 0; num7--) { HullPainterChild hullPainterChild2 = list3[num7]; if (hullPainterChild2.isAutoHull && ((Object)((Component)hullPainterChild2).gameObject).name.StartsWith(hull3.name)) { HullMapping hullMapping4 = FindMapping(hull3); if (hullMapping4 == null) { hullMapping4 = new HullMapping(); hullMapping4.sourceHull = hull3; this.hullMapping.Add(hullMapping4); } hullMapping4.AddAutoChild(hullPainterChild2, null); list3.RemoveAt(num7); flag16 = true; } } if (flag16) { list.RemoveAt(num6); } } } foreach (HullMapping item3 in this.hullMapping) { if ((Object)(object)item3.targetChild != (Object)null && (Object)(object)item3.generatedCollider == (Object)null) { RecreateChildCollider(item3); } } foreach (HullMapping item4 in this.hullMapping) { if ((Object)(object)item4.targetChild == (Object)null && (Object)(object)item4.generatedCollider != (Object)null && (Object)(object)((Component)item4.generatedCollider).transform.parent == (Object)(object)((Component)this).transform) { HullPainterChild hullPainterChild3 = AddComponent(((Component)item4.generatedCollider).gameObject); hullPainterChild3.parent = this; item4.targetChild = hullPainterChild3; } } foreach (Hull item5 in list) { if (item5.type == HullType.Box) { CreateCollider(item5); } else if (item5.type == HullType.Sphere) { CreateCollider(item5); } else if (item5.type == HullType.ConvexHull) { CreateCollider(item5); } else if (item5.type == HullType.Face) { CreateCollider(item5); } else if (item5.type == HullType.FaceAsBox) { CreateCollider(item5); } } foreach (Collider item6 in list2) { if ((Object)(object)item6 == (Object)null) { continue; } if ((Object)(object)((Component)item6).gameObject == (Object)(object)((Component)this).gameObject) { DestroyImmediateWithUndo((Object)(object)item6); continue; } GameObject gameObject = ((Component)item6).gameObject; DestroyImmediateWithUndo((Object)(object)item6); DestroyImmediateWithUndo((Object)(object)gameObject.GetComponent()); if (IsDeletable(gameObject)) { DestroyImmediateWithUndo((Object)(object)gameObject); } } foreach (HullPainterChild item7 in list3) { if (!((Object)(object)item7 == (Object)null)) { GameObject gameObject2 = ((Component)item7).gameObject; DestroyImmediateWithUndo((Object)(object)item7); DestroyImmediateWithUndo((Object)(object)gameObject2.GetComponent()); if (IsDeletable(gameObject2)) { DestroyImmediateWithUndo((Object)(object)gameObject2); } } } } private static bool Approximately(Vector3 lhs, Vector3 rhs) { return Mathf.Approximately(lhs.x, rhs.x) && Mathf.Approximately(lhs.y, rhs.y) && Mathf.Approximately(lhs.z, rhs.z); } private static bool Approximately(float lhs, float rhs) { return Mathf.Approximately(lhs, rhs); } private void CreateCollider(Hull sourceHull) where T : Collider { //IL_0031: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (sourceHull.isChildCollider) { GameObject val = CreateGameObject(sourceHull.name); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; HullPainterChild hullPainterChild = AddComponent(val); hullPainterChild.parent = this; T val2 = AddComponent(val); AddMapping(sourceHull, (Collider)(object)val2, hullPainterChild); } else { T val3 = AddComponent(((Component)this).gameObject); AddMapping(sourceHull, (Collider)(object)val3, null); } } private void RecreateChildCollider(HullMapping mapping) { if (mapping != null && mapping.sourceHull != null && mapping.sourceHull.isChildCollider) { if (mapping.sourceHull.type == HullType.Box) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.Sphere) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.ConvexHull) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.Face) { RecreateChildCollider(mapping); } else if (mapping.sourceHull.type == HullType.FaceAsBox) { RecreateChildCollider(mapping); } } } private void RecreateChildCollider(HullMapping mapping) where T : Collider { if (mapping.sourceHull != null && mapping.sourceHull.isChildCollider) { T val = AddComponent(((Component)mapping.targetChild).gameObject); mapping.generatedCollider = (Collider)(object)val; } } private void UpdateCollider(Hull hull) { //IL_0028: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) Collider val = null; if (hull.type == HullType.Box) { Collider obj = FindExistingCollider(hullMapping, hull); BoxCollider val2 = (BoxCollider)(object)((obj is BoxCollider) ? obj : null); val2.center = ((Bounds)(ref hull.collisionBox)).center; val2.size = ((Bounds)(ref hull.collisionBox)).size + ((!hull.enableInflation) ? Vector3.zero : (Vector3.one * hull.inflationAmount)); if (hull.isChildCollider) { ((Component)val2).transform.localPosition = hull.boxPosition; ((Component)val2).transform.localRotation = hull.boxRotation; } val = (Collider)(object)val2; } else if (hull.type == HullType.Sphere) { Collider obj2 = FindExistingCollider(hullMapping, hull); SphereCollider val3 = (SphereCollider)(object)((obj2 is SphereCollider) ? obj2 : null); val3.center = hull.collisionSphere.center; val3.radius = hull.collisionSphere.radius + ((!hull.enableInflation) ? 0f : hull.inflationAmount); val = (Collider)(object)val3; } else if (hull.type == HullType.ConvexHull) { Collider obj3 = FindExistingCollider(hullMapping, hull); MeshCollider val4 = (MeshCollider)(object)((obj3 is MeshCollider) ? obj3 : null); val4.sharedMesh = hull.collisionMesh; val4.convex = true; val4.inflateMesh = hull.enableInflation; val4.skinWidth = hull.inflationAmount; val = (Collider)(object)val4; } else if (hull.type == HullType.Face) { Collider obj4 = FindExistingCollider(hullMapping, hull); MeshCollider val5 = (MeshCollider)(object)((obj4 is MeshCollider) ? obj4 : null); val5.sharedMesh = hull.faceCollisionMesh; val5.convex = true; val5.inflateMesh = hull.enableInflation; val5.skinWidth = hull.inflationAmount; val = (Collider)(object)val5; } else if (hull.type == HullType.FaceAsBox) { Collider obj5 = FindExistingCollider(hullMapping, hull); BoxCollider val6 = (BoxCollider)(object)((obj5 is BoxCollider) ? obj5 : null); val6.center = hull.faceBoxCenter; val6.size = hull.faceBoxSize + ((!hull.enableInflation) ? Vector3.zero : (Vector3.one * hull.inflationAmount)); if (hull.isChildCollider) { ((Component)val6).transform.localRotation = hull.faceAsBoxRotation; } val = (Collider)(object)val6; } else if (hull.type != HullType.Auto) { } if ((Object)(object)val != (Object)null) { val.material = hull.material; val.isTrigger = hull.isTrigger; if (hull.isChildCollider) { ((Object)((Component)val).gameObject).name = hull.name; } } } public void SetAllTypes(HullType newType) { foreach (Hull hull in paintingData.hulls) { hull.type = newType; } } public void SetAllMaterials(PhysicMaterial newMaterial) { foreach (Hull hull in paintingData.hulls) { hull.material = newMaterial; } } public void SetAllAsChild(bool isChild) { foreach (Hull hull in paintingData.hulls) { hull.isChildCollider = isChild; } } public void SetAllAsTrigger(bool isTrigger) { foreach (Hull hull in paintingData.hulls) { hull.isTrigger = isTrigger; } } private List FindLocal() where T : Component { List list = new List(); list.AddRange(((Component)this).gameObject.GetComponents()); for (int i = 0; i < ((Component)this).transform.childCount; i++) { list.AddRange(((Component)((Component)this).transform.GetChild(i)).GetComponents()); } return list; } private bool IsMapped(Hull hull) { if (hullMapping == null) { return false; } foreach (HullMapping item in hullMapping) { if (item.sourceHull == hull) { return true; } } return false; } private bool IsMapped(Collider col) { if (hullMapping == null) { return false; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.generatedCollider == (Object)(object)col) { return true; } } return false; } private bool IsMapped(HullPainterChild child) { if (hullMapping == null) { return false; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.targetChild == (Object)(object)child) { return true; } } return false; } private void AddMapping(Hull hull, Collider col, HullPainterChild painterChild) { HullMapping hullMapping = new HullMapping(); hullMapping.sourceHull = hull; hullMapping.generatedCollider = col; hullMapping.targetChild = painterChild; HullMapping item = hullMapping; this.hullMapping.Add(item); } private void RemoveMapping(Hull hull) { for (int i = 0; i < hullMapping.Count; i++) { if (hullMapping[i].sourceHull == hull) { hullMapping.RemoveAt(i); break; } } } private HullMapping FindMapping(HullPainterChild child) { if (hullMapping == null) { return null; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.targetChild == (Object)(object)child) { return item; } } return null; } private HullMapping FindMapping(Hull hull) { if (hullMapping == null) { return null; } foreach (HullMapping item in hullMapping) { if (item.sourceHull == hull) { return item; } } return null; } public Hull FindSourceHull(HullPainterChild child) { if (hullMapping == null) { return null; } foreach (HullMapping item in hullMapping) { if ((Object)(object)item.targetChild == (Object)(object)child) { return item.sourceHull; } HullPainterChild[] targetAutoGeneratedChilds = item.targetAutoGeneratedChilds; foreach (HullPainterChild hullPainterChild in targetAutoGeneratedChilds) { if ((Object)(object)hullPainterChild == (Object)(object)child) { return item.sourceHull; } } } return null; } private static Collider FindExistingCollider(List mappings, Hull hull) { foreach (HullMapping mapping in mappings) { if (mapping.sourceHull == hull) { return mapping.generatedCollider; } } return null; } private void CreateAutoHulls(Hull hull, Mesh[] autoHulls) { if (hull.type != HullType.Auto) { return; } HullMapping hullMapping = FindMapping(hull); if (hullMapping == null) { hullMapping = new HullMapping(); hullMapping.sourceHull = hull; this.hullMapping.Add(hullMapping); } Mesh[] autoMeshes = hull.autoMeshes; List list = new List(); if (hullMapping.targetAutoGeneratedChilds != null) { for (int i = 0; i < hullMapping.targetAutoGeneratedChilds.Length; i++) { if (hullMapping.autoGeneratedColliders != null && i < hullMapping.autoGeneratedColliders.Length) { list.Add(hullMapping.autoGeneratedColliders[i]); continue; } MeshCollider val = ((Component)hullMapping.targetAutoGeneratedChilds[i]).gameObject.AddComponent(); val.convex = true; list.Add(val); } } for (int num = list.Count - 1; num >= 0; num--) { bool flag = (Object)(object)((Component)list[num]).transform != (Object)(object)((Component)this).transform; if (flag != Object.op_Implicit((Object)(object)((Component)this).transform) && hull.isChildCollider) { if (flag) { Object.DestroyImmediate((Object)(object)((Component)list[num]).gameObject); } else { Object.DestroyImmediate((Object)(object)list[num]); } list.RemoveAt(num); } } for (int j = 0; j < autoMeshes.Length; j++) { Mesh sharedMesh = autoMeshes[j]; MeshCollider val2; if (j < list.Count) { val2 = list[j]; } else if (hull.isChildCollider) { GameObject val3 = CreateGameObject("New child"); val3.transform.SetParent(((Component)this).transform, false); HullPainterChild hullPainterChild = val3.AddComponent(); hullPainterChild.parent = this; hullPainterChild.isAutoHull = true; val2 = val3.AddComponent(); list.Add(val2); } else { val2 = ((Component)this).gameObject.AddComponent(); list.Add(val2); } val2.sharedMesh = sharedMesh; val2.convex = true; ((Collider)val2).isTrigger = hull.isTrigger; ((Collider)val2).material = hull.material; } if (hull.isChildCollider) { for (int k = 0; k < list.Count; k++) { ((Object)((Component)list[k]).gameObject).name = $"{hull.name}.{k + 1}"; } } List list2 = new List(); foreach (MeshCollider item in list) { list2.Add(((Component)item).GetComponent()); } hullMapping.autoGeneratedColliders = list.ToArray(); hullMapping.targetAutoGeneratedChilds = list2.ToArray(); } private static GameObject CreateGameObject(string goName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(goName); Undo.RegisterCreatedObjectUndo((Object)(object)val, "Created " + goName); return val; } private static T AddComponent(GameObject targetObj) where T : Component { return (T)(object)Undo.AddComponent(targetObj, typeof(T)); } private void OnDrawGizmos() { } } public class HullPainterChild : MonoBehaviour { public HullPainter parent; public bool isAutoHull; } } public class CuttableMesh { private MeshRenderer inputMeshRenderer; private bool hasUvs; private bool hasUv1s; private bool hasColours; private List subMeshes; public CuttableMesh(Mesh inputMesh) { Init(inputMesh, ((Object)inputMesh).name); } public CuttableMesh(MeshRenderer input) { inputMeshRenderer = input; MeshFilter component = ((Component)input).GetComponent(); Mesh sharedMesh = component.sharedMesh; Init(sharedMesh, ((Object)input).name); } public CuttableMesh(CuttableMesh inputMesh, List newSubMeshes) { inputMeshRenderer = inputMesh.inputMeshRenderer; hasUvs = inputMesh.hasUvs; hasUv1s = inputMesh.hasUv1s; hasColours = inputMesh.hasColours; subMeshes = new List(); subMeshes.AddRange(newSubMeshes); } private void Init(Mesh inputMesh, string debugName) { subMeshes = new List(); if (inputMesh.isReadable) { Vector3[] vertices = inputMesh.vertices; Vector3[] normals = inputMesh.normals; Vector2[] uv = inputMesh.uv; Vector2[] uv2 = inputMesh.uv2; Color32[] colors = inputMesh.colors32; hasUvs = uv != null && uv.Length > 0; hasUv1s = uv2 != null && uv2.Length > 0; hasColours = colors != null && colors.Length > 0; for (int i = 0; i < inputMesh.subMeshCount; i++) { int[] indices = inputMesh.GetIndices(i); CuttableSubMesh item = new CuttableSubMesh(indices, vertices, normals, colors, uv, uv2); subMeshes.Add(item); } } else { Debug.LogError((object)("CuttableMesh's input mesh is not readable: " + debugName), (Object)(object)inputMesh); } } public void Add(CuttableMesh other) { if (subMeshes.Count != other.subMeshes.Count) { throw new Exception("Mismatched submesh count"); } for (int i = 0; i < subMeshes.Count; i++) { subMeshes[i].Add(other.subMeshes[i]); } } public int NumSubMeshes() { return subMeshes.Count; } public bool HasUvs() { return hasUvs; } public bool HasColours() { return hasColours; } public List GetSubMeshes() { return subMeshes; } public CuttableSubMesh GetSubMesh(int index) { return subMeshes[index]; } public Transform GetTransform() { if ((Object)(object)inputMeshRenderer != (Object)null) { return ((Component)inputMeshRenderer).transform; } return null; } public MeshRenderer ConvertToRenderer(string newObjectName) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003d: 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_005d: 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_0097: 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) Mesh val = CreateMesh(); if (val.vertexCount == 0) { return null; } GameObject val2 = new GameObject(newObjectName); val2.transform.SetParent(((Component)inputMeshRenderer).transform); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; MeshFilter val3 = val2.AddComponent(); val3.mesh = val; MeshRenderer val4 = val2.AddComponent(); ((Renderer)val4).shadowCastingMode = ((Renderer)inputMeshRenderer).shadowCastingMode; ((Renderer)val4).reflectionProbeUsage = ((Renderer)inputMeshRenderer).reflectionProbeUsage; ((Renderer)val4).lightProbeUsage = ((Renderer)inputMeshRenderer).lightProbeUsage; ((Renderer)val4).sharedMaterials = ((Renderer)inputMeshRenderer).sharedMaterials; return val4; } public Mesh CreateMesh() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Mesh val = new Mesh(); int num = 0; for (int i = 0; i < subMeshes.Count; i++) { num += subMeshes[i].NumIndices(); } List list = new List(); List list2 = new List(); List list3 = ((!hasColours) ? null : new List()); List list4 = ((!hasUvs) ? null : new List()); List list5 = ((!hasUv1s) ? null : new List()); List list6 = new List(); foreach (CuttableSubMesh subMesh in subMeshes) { list6.Add(list.Count); subMesh.AddTo(list, list2, list3, list4, list5); } val.vertices = list.ToArray(); val.normals = list2.ToArray(); val.colors32 = ((!hasColours) ? null : list3.ToArray()); val.uv = ((!hasUvs) ? null : list4.ToArray()); val.uv2 = ((!hasUv1s) ? null : list5.ToArray()); val.subMeshCount = subMeshes.Count; for (int j = 0; j < subMeshes.Count; j++) { CuttableSubMesh cuttableSubMesh = subMeshes[j]; int num2 = list6[j]; int[] array = cuttableSubMesh.GenIndices(); for (int k = 0; k < array.Length; k++) { array[k] += num2; } val.SetTriangles(array, j, true); } return val; } } public class CuttableSubMesh { private List vertices; private List normals; private List colours; private List uvs; private List uv1s; public CuttableSubMesh(bool hasNormals, bool hasColours, bool hasUvs, bool hasUv1) { vertices = new List(); if (hasNormals) { normals = new List(); } if (hasColours) { colours = new List(); } if (hasUvs) { uvs = new List(); } if (hasUv1) { uv1s = new List(); } } public CuttableSubMesh(int[] indices, Vector3[] inputVertices, Vector3[] inputNormals, Color32[] inputColours, Vector2[] inputUvs, Vector2[] inputUv1) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) vertices = new List(); if (inputNormals != null && inputNormals.Length > 0) { normals = new List(); } if (inputColours != null && inputColours.Length > 0) { colours = new List(); } if (inputUvs != null && inputUvs.Length > 0) { uvs = new List(); } if (inputUv1 != null && inputUv1.Length > 0) { uv1s = new List(); } foreach (int num in indices) { vertices.Add(inputVertices[num]); if (normals != null) { normals.Add(inputNormals[num]); } if (colours != null) { colours.Add(inputColours[num]); } if (uvs != null) { uvs.Add(inputUvs[num]); } if (uv1s != null) { uv1s.Add(inputUv1[num]); } } } public void Add(CuttableSubMesh other) { for (int i = 0; i < other.vertices.Count; i++) { CopyVertex(i, other); } } public int NumVertices() { return vertices.Count; } public Vector3 GetVertex(int index) { //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_0013: Unknown result type (might be due to invalid IL or missing references) return vertices[index]; } public bool HasNormals() { return normals != null; } public bool HasColours() { return colours != null; } public bool HasUvs() { return uvs != null; } public bool HasUv1() { return uv1s != null; } public void CopyVertex(int srcIndex, CuttableSubMesh srcMesh) { //IL_000e: 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_0052: 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) //IL_0096: Unknown result type (might be due to invalid IL or missing references) vertices.Add(srcMesh.vertices[srcIndex]); if (normals != null) { normals.Add(srcMesh.normals[srcIndex]); } if (colours != null) { colours.Add(srcMesh.colours[srcIndex]); } if (uvs != null) { uvs.Add(srcMesh.uvs[srcIndex]); } if (uv1s != null) { uv1s.Add(srcMesh.uv1s[srcIndex]); } } public void AddInterpolatedVertex(int i0, int i1, float weight, CuttableSubMesh srcMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00c0: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = srcMesh.GetVertex(i0); Vector3 vertex2 = srcMesh.GetVertex(i1); vertices.Add(Vector3.Lerp(vertex, vertex2, weight)); if (normals != null) { List list = normals; Vector3 val = Vector3.Lerp(srcMesh.normals[i0], srcMesh.normals[i1], weight); list.Add(((Vector3)(ref val)).normalized); } if (colours != null) { colours.Add(Color32.Lerp(srcMesh.colours[i0], srcMesh.colours[i1], weight)); } if (uvs != null) { uvs.Add(Vector2.Lerp(srcMesh.uvs[i0], srcMesh.uvs[i1], weight)); } if (uv1s != null) { uv1s.Add(Vector2.Lerp(srcMesh.uv1s[i0], srcMesh.uv1s[i1], weight)); } } public void AddTo(List destVertices, List destNormals, List destColours, List destUvs, List destUv1s) { destVertices.AddRange(vertices); if (normals != null) { destNormals.AddRange(normals); } if (colours != null) { destColours.AddRange(colours); } if (uvs != null) { destUvs.AddRange(uvs); } if (uv1s != null) { destUv1s.AddRange(uv1s); } } public int NumIndices() { return vertices.Count; } public int[] GenIndices() { int[] array = new int[vertices.Count]; for (int i = 0; i < array.Length; i++) { array[i] = i; } return array; } } public enum VertexClassification { Front = 1, Back = 2, OnPlane = 4 } public class MeshCutter { private CuttableMesh inputMesh; private List outputFrontSubMeshes; private List outputBackSubMeshes; public void Cut(CuttableMesh input, Plane worldCutPlane) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_008a: Unknown result type (might be due to invalid IL or missing references) inputMesh = input; outputFrontSubMeshes = new List(); outputBackSubMeshes = new List(); Transform transform = inputMesh.GetTransform(); Plane cutPlane = default(Plane); if ((Object)(object)transform != (Object)null) { Vector3 val = transform.InverseTransformPoint(ClosestPointOnPlane(worldCutPlane, Vector3.zero)); Vector3 val2 = transform.InverseTransformDirection(((Plane)(ref worldCutPlane)).normal); ((Plane)(ref cutPlane))..ctor(val2, val); } else { cutPlane = worldCutPlane; } foreach (CuttableSubMesh subMesh in input.GetSubMeshes()) { Cut(subMesh, cutPlane); } } private static Vector3 ClosestPointOnPlane(Plane plane, Vector3 point) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_004b: Unknown result type (might be due to invalid IL or missing references) float distanceToPoint = ((Plane)(ref plane)).GetDistanceToPoint(point); if (((Plane)(ref plane)).GetSide(point)) { return point - ((Plane)(ref plane)).normal * distanceToPoint; } return point + ((Plane)(ref plane)).normal * distanceToPoint; } public CuttableMesh GetFrontOutput() { return new CuttableMesh(inputMesh, outputFrontSubMeshes); } public CuttableMesh GetBackOutput() { return new CuttableMesh(inputMesh, outputBackSubMeshes); } private void Cut(CuttableSubMesh inputSubMesh, Plane cutPlane) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0121: 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) //IL_015b: 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_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: 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_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) bool hasNormals = inputSubMesh.HasNormals(); bool hasColours = inputSubMesh.HasColours(); bool hasUvs = inputSubMesh.HasUvs(); bool hasUv = inputSubMesh.HasUv1(); CuttableSubMesh cuttableSubMesh = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv); CuttableSubMesh cuttableSubMesh2 = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv); for (int i = 0; i < inputSubMesh.NumVertices(); i += 3) { int num = i; int num2 = i + 1; int num3 = i + 2; Vector3 vertex = inputSubMesh.GetVertex(num); Vector3 vertex2 = inputSubMesh.GetVertex(num2); Vector3 vertex3 = inputSubMesh.GetVertex(num3); VertexClassification vertexClassification = Classify(vertex, cutPlane); VertexClassification vertexClassification2 = Classify(vertex2, cutPlane); VertexClassification vertexClassification3 = Classify(vertex3, cutPlane); int numFront = 0; int numBehind = 0; CountSides(vertexClassification, ref numFront, ref numBehind); CountSides(vertexClassification2, ref numFront, ref numBehind); CountSides(vertexClassification3, ref numFront, ref numBehind); if (numFront > 0 && numBehind == 0) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh); } else if (numFront == 0 && numBehind > 0) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2); } else if (numFront == 2 && numBehind == 1) { if (vertexClassification == VertexClassification.Back) { SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } else if (vertexClassification2 == VertexClassification.Back) { SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } else { SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } } else if (numFront == 1 && numBehind == 2) { if (vertexClassification == VertexClassification.Front) { SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else if (vertexClassification2 == VertexClassification.Front) { SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } } else if (numFront == 1 && numBehind == 1) { if (vertexClassification == VertexClassification.OnPlane) { if (vertexClassification3 == VertexClassification.Front) { SplitB(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitBFlipped(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } continue; } switch (vertexClassification2) { case VertexClassification.OnPlane: if (vertexClassification == VertexClassification.Front) { SplitB(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitBFlipped(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } break; case VertexClassification.Front: SplitB(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); break; default: SplitBFlipped(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); break; } } else if (numFront == 0 && numBehind == 0) { Vector3 val = vertex2 - vertex; Vector3 val2 = vertex3 - vertex; Vector3 val3 = Vector3.Cross(val, val2); if (Vector3.Dot(val3, ((Plane)(ref cutPlane)).normal) > 0f) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2); } else { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh); } } } outputFrontSubMeshes.Add(cuttableSubMesh); outputBackSubMeshes.Add(cuttableSubMesh2); } private VertexClassification Classify(Vector3 vertex, Plane cutPlane) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(vertex.x, vertex.y, vertex.z); float distanceToPoint = ((Plane)(ref cutPlane)).GetDistanceToPoint(val); double num = 9.999999747378752E-06; if ((double)distanceToPoint > 0.0 - num && (double)distanceToPoint < num) { return VertexClassification.OnPlane; } if (distanceToPoint > 0f) { return VertexClassification.Front; } return VertexClassification.Back; } private void CountSides(VertexClassification c, ref int numFront, ref int numBehind) { switch (c) { case VertexClassification.Front: numFront++; break; case VertexClassification.Back: numBehind++; break; } } private void KeepTriangle(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, CuttableSubMesh destSubMesh) { destSubMesh.CopyVertex(i0, inputSubMesh); destSubMesh.CopyVertex(i1, inputSubMesh); destSubMesh.CopyVertex(i2, inputSubMesh); } private void SplitA(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references) //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_002c: 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) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i1); Vector3 vertex3 = inputSubMesh.GetVertex(i2); CalcIntersection(vertex, vertex2, cutPlane, out var weight); CalcIntersection(vertex3, vertex, cutPlane, out var weight2); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); } private void SplitB(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i2); CalcIntersection(vertex2, vertex, cutPlane, out var weight); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.CopyVertex(i1, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh); } private void SplitBFlipped(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i1); CalcIntersection(vertex, vertex2, cutPlane, out var weight); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); frontSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); } private Vector3 CalcIntersection(Vector3 v0, Vector3 v1, Plane plane, out float weight) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0016: 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_002d: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Vector3 val = v1 - v0; float magnitude = ((Vector3)(ref val)).magnitude; Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(v0, val / magnitude); float num = default(float); ((Plane)(ref plane)).Raycast(val2, ref num); Vector3 result = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * num; weight = num / magnitude; return result; } } namespace Technie.PhysicsCreator { public enum HullType { Box, ConvexHull, Sphere, Face, FaceAsBox, Auto } public enum AutoHullPreset { Low, Medium, High, Placebo, Custom } [Serializable] public class Hull { public string name = ""; public bool isVisible = true; public HullType type = HullType.ConvexHull; public Color colour = Color.white; public PhysicMaterial material; public bool enableInflation = false; public float inflationAmount = 0.01f; public BoxFitMethod boxFitMethod = BoxFitMethod.MinimumVolume; public bool isTrigger = false; public bool isChildCollider = false; public List selectedFaces = new List(); public Mesh collisionMesh; public Bounds collisionBox; public Vector3 boxPosition; public Quaternion boxRotation; public Sphere collisionSphere; public Mesh faceCollisionMesh; public Vector3 faceBoxCenter; public Vector3 faceBoxSize; public Quaternion faceAsBoxRotation; public Mesh[] autoMeshes = (Mesh[])(object)new Mesh[0]; public bool hasColliderError; public int numColliderFaces; public void Destroy() { } public bool ContainsAutoMesh(Mesh m) { if (autoMeshes != null) { Mesh[] array = autoMeshes; foreach (Mesh val in array) { if ((Object)(object)val == (Object)(object)m) { return true; } } } return false; } } public class PaintingData : ScriptableObject { public readonly Color[] hullColours = (Color[])(object)new Color[13] { new Color(0f, 1f, 1f, 0.7f), new Color(1f, 0f, 1f, 0.7f), new Color(1f, 1f, 0f, 0.7f), new Color(1f, 0f, 0f, 0.7f), new Color(0f, 1f, 0f, 0.7f), new Color(0f, 0f, 1f, 0.7f), new Color(1f, 1f, 1f, 0.7f), new Color(1f, 0.5f, 0f, 0.7f), new Color(1f, 0f, 0.5f, 0.7f), new Color(0.5f, 1f, 0f, 0.7f), new Color(0f, 1f, 0.5f, 0.7f), new Color(0.5f, 0f, 1f, 0.7f), new Color(0f, 0.5f, 1f, 0.7f) }; public HullData hullData; public Mesh sourceMesh; public int activeHull = -1; public float faceThickness = 0.1f; public List hulls = new List(); public AutoHullPreset autoHullPreset = AutoHullPreset.Medium; public VhacdParameters vhacdParams = new VhacdParameters(); public bool hasLastVhacdTimings = false; public AutoHullPreset lastVhacdPreset = AutoHullPreset.Medium; public float lastVhacdDurationSecs = 0f; public int TotalOutputColliders { get { int num = 0; foreach (Hull hull in hulls) { num = ((hull.type != HullType.Auto) ? (num + 1) : (num + ((hull.autoMeshes != null) ? hull.autoMeshes.Length : 0))); } return num; } } public void AddHull(HullType type, PhysicMaterial material, bool isChild, bool isTrigger) { //IL_008d: 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) hulls.Add(new Hull()); hulls[hulls.Count - 1].name = "Hull " + hulls.Count; activeHull = hulls.Count - 1; hulls[hulls.Count - 1].colour = hullColours[activeHull % hullColours.Length]; hulls[hulls.Count - 1].type = type; hulls[hulls.Count - 1].material = material; hulls[hulls.Count - 1].isTrigger = isTrigger; hulls[hulls.Count - 1].isChildCollider = isChild; } public void RemoveHull(int index) { hulls[index].Destroy(); hulls.RemoveAt(index); } public void RemoveAllHulls() { for (int i = 0; i < hulls.Count; i++) { hulls[i].Destroy(); } hulls.Clear(); } public bool HasActiveHull() { return activeHull >= 0 && activeHull < hulls.Count; } public Hull GetActiveHull() { if (activeHull < 0 || activeHull >= hulls.Count) { return null; } return hulls[activeHull]; } public void GenerateCollisionMesh(Hull hull, Vector3[] meshVertices, int[] meshIndices, Mesh[] autoHulls) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_00df: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Expected O, but got Unknown //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: 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_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0338: 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_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03be: 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_03e3: 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_03e7: 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_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: 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_041e: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Expected O, but got Unknown hull.hasColliderError = false; if (hull.type == HullType.Box) { if (hull.selectedFaces.Count <= 0) { return; } if (hull.isChildCollider) { if (hull.boxFitMethod == BoxFitMethod.MinimumVolume) { RotatedBoxFitter rotatedBoxFitter = new RotatedBoxFitter(); rotatedBoxFitter.Fit(hull, meshVertices, meshIndices); } else if (hull.boxFitMethod == BoxFitMethod.AlignFaces) { FaceAlignmentBoxFitter faceAlignmentBoxFitter = new FaceAlignmentBoxFitter(); faceAlignmentBoxFitter.Fit(hull, meshVertices, meshIndices); } else if (hull.boxFitMethod == BoxFitMethod.AxisAligned) { AxisAlignedBoxFitter axisAlignedBoxFitter = new AxisAlignedBoxFitter(); axisAlignedBoxFitter.Fit(hull, meshVertices, meshIndices); } return; } Vector3 val = meshVertices[meshIndices[hull.selectedFaces[0] * 3]]; Vector3 min = val; Vector3 max = val; for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 point = meshVertices[meshIndices[num * 3]]; Vector3 point2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 point3 = meshVertices[meshIndices[num * 3 + 2]]; Inflate(point, ref min, ref max); Inflate(point2, ref min, ref max); Inflate(point3, ref min, ref max); } ((Bounds)(ref hull.collisionBox)).center = (min + max) * 0.5f; ((Bounds)(ref hull.collisionBox)).size = max - min; hull.boxRotation = Quaternion.identity; } else if (hull.type == HullType.Sphere) { if (hull.collisionSphere == null) { hull.collisionSphere = new Sphere(); } if (CalculateBoundingSphere(hull, meshVertices, meshIndices, out var sphereCenter, out var sphereRadius)) { hull.collisionSphere.center = sphereCenter; hull.collisionSphere.radius = sphereRadius; } else { hull.collisionSphere.center = Vector3.zero; hull.collisionSphere.radius = 0f; } } else if (hull.type == HullType.ConvexHull) { if ((Object)(object)hull.collisionMesh == (Object)null) { hull.collisionMesh = new Mesh(); } ((Object)hull.collisionMesh).name = hull.name; hull.collisionMesh.triangles = new int[0]; hull.collisionMesh.vertices = (Vector3[])(object)new Vector3[0]; GenerateConvexHull(hull, meshVertices, meshIndices, hull.collisionMesh); } else if (hull.type == HullType.Face) { if ((Object)(object)hull.faceCollisionMesh == (Object)null) { hull.faceCollisionMesh = new Mesh(); } ((Object)hull.faceCollisionMesh).name = hull.name; hull.faceCollisionMesh.triangles = new int[0]; hull.faceCollisionMesh.vertices = (Vector3[])(object)new Vector3[0]; GenerateFace(hull, meshVertices, meshIndices, faceThickness); } else if (hull.type == HullType.FaceAsBox) { if (hull.selectedFaces.Count <= 0) { return; } if (hull.isChildCollider) { Vector3[] vertices = ExtractUniqueVertices(hull, meshVertices, meshIndices); Vector3 val2 = CalcPrimaryAxis(hull, meshVertices, meshIndices, !hull.isChildCollider); Vector3 val3 = ((!(Vector3.Dot(val2, Vector3.up) > 0.8f)) ? Vector3.up : Vector3.right); Vector3 val4 = Vector3.Cross(val2, val3); Vector3 primaryUp = Vector3.Cross(val2, val4); float num2 = 0f; float num3 = float.MaxValue; Vector3 val5 = Vector3.zero; Vector3 val6 = Vector3.zero; Quaternion faceAsBoxRotation = Quaternion.identity; float num4 = 5f; float num5 = 0.05f; for (float num6 = 0f; num6 <= 360f; num6 += num4) { Vector3 min2; Vector3 max2; Quaternion outBasis; float num7 = CalcRequiredArea(num6, val2, primaryUp, vertices, out min2, out max2, out outBasis); if (num7 < num3) { num2 = num6; num3 = num7; val5 = min2; val6 = max2; faceAsBoxRotation = outBasis; } } float num8 = num2 - num4; float num9 = num2 + num4; for (float num10 = num8; num10 <= num9; num10 += num5) { Vector3 min3; Vector3 max3; Quaternion outBasis2; float num11 = CalcRequiredArea(num10, val2, primaryUp, vertices, out min3, out max3, out outBasis2); if (num11 < num3) { num2 = num10; num3 = num11; val5 = min3; val6 = max3; faceAsBoxRotation = outBasis2; } } Vector3 faceBoxCenter = (val5 + val6) / 2f; Vector3 faceBoxSize = val6 - val5; float num12 = faceBoxSize.z - faceThickness; faceBoxCenter.z += num12 * 0.5f; faceBoxSize.z += num12; hull.faceBoxCenter = faceBoxCenter; hull.faceBoxSize = faceBoxSize; hull.faceAsBoxRotation = faceAsBoxRotation; } else { Vector3[] array = ExtractUniqueVertices(hull, meshVertices, meshIndices); Vector3 val7 = CalcPrimaryAxis(hull, meshVertices, meshIndices, !hull.isChildCollider); Vector3 val8 = array[0]; Vector3 min4 = val8; Vector3 max4 = val8; Vector3[] array2 = array; foreach (Vector3 point4 in array2) { Inflate(point4, ref min4, ref max4); } Vector3 faceBoxCenter2 = (min4 + max4) / 2f; Vector3 faceBoxSize2 = max4 - min4; if (Mathf.Abs(val7.x) > 0f) { float num13 = ((!(val7.x > 0f)) ? (-1f) : 1f); float num14 = faceBoxSize2.x - faceThickness; faceBoxCenter2.x += num14 * 0.5f * num13; faceBoxSize2.x += num14; } else if (Mathf.Abs(val7.y) > 0f) { float num15 = ((!(val7.y > 0f)) ? (-1f) : 1f); float num16 = faceBoxSize2.y - faceThickness; faceBoxCenter2.y += num16 * 0.5f * num15; faceBoxSize2.y += num16; } else { float num17 = ((!(val7.z > 0f)) ? (-1f) : 1f); float num18 = faceBoxSize2.z - faceThickness; faceBoxCenter2.z += num18 * 0.5f * num17; faceBoxSize2.z += num18; } hull.faceBoxCenter = faceBoxCenter2; hull.faceBoxSize = faceBoxSize2; hull.faceAsBoxRotation = Quaternion.identity; } } else { if (hull.type != HullType.Auto) { return; } if ((Object)(object)hull.collisionMesh == (Object)null) { hull.collisionMesh = new Mesh(); } ((Object)hull.collisionMesh).name = $"{hull.name} bounds"; hull.collisionMesh.triangles = new int[0]; hull.collisionMesh.vertices = (Vector3[])(object)new Vector3[0]; GenerateConvexHull(hull, meshVertices, meshIndices, hull.collisionMesh); List list = new List(); if (hull.selectedFaces.Count == sourceMesh.triangles.Length / 3) { list.AddRange(autoHulls); } else { foreach (Mesh inputMesh in autoHulls) { Mesh val9 = Clip(hull.collisionMesh, inputMesh); if ((Object)(object)val9 != (Object)null) { list.Add(val9); } } } for (int l = 0; l < list.Count; l++) { ((Object)list[l]).name = $"{hull.name}.{l + 1}"; } List list2 = new List(); if (hull.autoMeshes != null) { list2.AddRange(hull.autoMeshes); } while (list2.Count > list.Count) { list2.RemoveAt(list2.Count - 1); } while (list2.Count < list.Count) { list2.Add(new Mesh()); } for (int m = 0; m < list.Count; m++) { list2[m].Clear(); ((Object)list2[m]).name = ((Object)list[m]).name; list2[m].vertices = list[m].vertices; list2[m].triangles = list[m].triangles; } hull.autoMeshes = list2.ToArray(); } } private Mesh Clip(Mesh boundingMesh, Mesh inputMesh) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)boundingMesh == (Object)null || boundingMesh.triangles.Length == 0) { return null; } if ((Object)(object)inputMesh == (Object)null || inputMesh.triangles.Length == 0) { return null; } CuttableMesh cuttableMesh = new CuttableMesh(inputMesh); MeshCutter meshCutter = new MeshCutter(); Plane[] array = ConvertToPlanes(boundingMesh, show: false); foreach (Plane worldCutPlane in array) { meshCutter.Cut(cuttableMesh, worldCutPlane); Mesh inputMesh2 = meshCutter.GetBackOutput().CreateMesh(); Mesh inputMesh3 = QHullUtil.FindConvexHull("", inputMesh2, showErrorInLog: false); cuttableMesh = new CuttableMesh(inputMesh3); } Mesh val = cuttableMesh.CreateMesh(); if (val.triangles.Length > 0) { return val; } return null; } private Plane[] ConvertToPlanes(Mesh convexMesh, bool show) { //IL_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_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_005e: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_011b: 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_011f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3[] vertices = convexMesh.vertices; int[] triangles = convexMesh.triangles; Plane val7 = default(Plane); for (int i = 0; i < triangles.Length; i += 3) { Vector3 val = vertices[triangles[i]]; Vector3 val2 = vertices[triangles[i + 1]]; Vector3 val3 = vertices[triangles[i + 2]]; Vector3 val4 = val2 - val; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = val3 - val; Vector3 normalized2 = ((Vector3)(ref val5)).normalized; Vector3 val6 = Vector3.Cross(normalized, normalized2); Vector3 normalized3 = ((Vector3)(ref val6)).normalized; if (!(((Vector3)(ref normalized3)).magnitude > 0.01f)) { continue; } ((Plane)(ref val7))..ctor(normalized3, val); if (!Contains(val7, list)) { list.Add(val7); if (show) { GameObject val8 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val8).name = $"{i} : {triangles[i]} / {triangles[i + 1]} / {triangles[i + 2]}"; val8.transform.SetPositionAndRotation(val, Quaternion.LookRotation(normalized3)); } } } return list.ToArray(); } private static bool Contains(Plane toTest, List planes) { //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) foreach (Plane plane in planes) { Plane current = plane; if (Mathf.Abs(((Plane)(ref toTest)).distance - ((Plane)(ref current)).distance) < 0.01f && Vector3.Angle(((Plane)(ref toTest)).normal, ((Plane)(ref current)).normal) < 0.01f) { return true; } } return false; } private Vector3 CalcPrimaryAxis(Hull hull, Vector3[] meshVertices, int[] meshIndices, bool snapToAxies) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006c: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_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_00ae: 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_00b6: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) int num = 0; Vector3 val = Vector3.zero; for (int i = 0; i < hull.selectedFaces.Count; i++) { int num2 = hull.selectedFaces[i]; Vector3 val2 = meshVertices[meshIndices[num2 * 3]]; Vector3 val3 = meshVertices[meshIndices[num2 * 3 + 1]]; Vector3 val4 = meshVertices[meshIndices[num2 * 3 + 2]]; Vector3 val5 = val3 - val2; Vector3 normalized = ((Vector3)(ref val5)).normalized; Vector3 val6 = val4 - val2; Vector3 normalized2 = ((Vector3)(ref val6)).normalized; Vector3 val7 = Vector3.Cross(normalized, normalized2); val += val7; num++; } Vector3 val8 = val / (float)num; if (((Vector3)(ref val8)).magnitude < 0.0001f) { return Vector3.up; } if (snapToAxies) { float num3 = Mathf.Abs(val8.x); float num4 = Mathf.Abs(val8.y); float num5 = Mathf.Abs(val8.z); if (num3 > num4 && num3 > num5) { return new Vector3((!((double)val8.x > 0.0)) ? (-1f) : 1f, 0f, 0f); } if (num4 > num5) { return new Vector3(0f, (!((double)val8.y > 0.0)) ? (-1f) : 1f, 0f); } return new Vector3(0f, 0f, (!((double)val8.z > 0.0)) ? (-1f) : 1f); } return ((Vector3)(ref val8)).normalized; } private Vector3[] ExtractUniqueVertices(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 val = meshVertices[meshIndices[num * 3]]; Vector3 val2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 val3 = meshVertices[meshIndices[num * 3 + 2]]; if (!Contains(list, val)) { list.Add(val); } if (!Contains(list, val2)) { list.Add(val2); } if (!Contains(list, val3)) { list.Add(val3); } } return list.ToArray(); } private static bool Contains(List list, Vector3 p) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) foreach (Vector3 item in list) { float num = Vector3.Distance(item, p); if (num < 0.0001f) { return true; } } return false; } private static float CalcRequiredArea(float angleDeg, Vector3 primaryAxis, Vector3 primaryUp, Vector3[] vertices, out Vector3 min, out Vector3 max, out Quaternion outBasis) { //IL_003a: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004a: 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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (vertices.Length == 0) { min = Vector3.zero; max = Vector3.zero; outBasis = Quaternion.identity; return 0f; } Quaternion val = Quaternion.AngleAxis(angleDeg, primaryAxis); Vector3 val2 = val * primaryUp; Quaternion val3 = Quaternion.LookRotation(primaryAxis, val2); Quaternion val4 = Quaternion.Inverse(val3); max = (min = val4 * vertices[0]); foreach (Vector3 val5 in vertices) { Vector3 point = val4 * val5; Inflate(point, ref min, ref max); } outBasis = val3; Vector3 val6 = max - min; return val6.x * val6.y; } private bool CalculateBoundingSphere(Hull hull, Vector3[] meshVertices, int[] meshIndices, out Vector3 sphereCenter, out float sphereRadius) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (hull.selectedFaces.Count == 0) { sphereCenter = Vector3.zero; sphereRadius = 0f; return false; } List list = new List(); for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 item = meshVertices[meshIndices[num * 3]]; Vector3 item2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 item3 = meshVertices[meshIndices[num * 3 + 2]]; list.Add(item); list.Add(item2); list.Add(item3); } Sphere sphere = SphereUtils.MinSphere(list); sphereCenter = sphere.center; sphereRadius = sphere.radius; return true; } private void GenerateConvexHull(Hull hull, Vector3[] meshVertices, int[] meshIndices, Mesh destMesh) { QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var hullIndices, showErrorInLog: true); hull.numColliderFaces = hullIndices.Length / 3; Debug.Log((object)("Calculated collider for '" + hull.name + "' has " + hull.numColliderFaces + " faces")); if (hull.numColliderFaces >= 256) { hull.hasColliderError = true; hull.enableInflation = true; } hull.collisionMesh.vertices = hullVertices; hull.collisionMesh.triangles = hullIndices; hull.collisionMesh.RecalculateBounds(); hull.faceCollisionMesh = null; } private void GenerateFace(Hull hull, Vector3[] meshVertices, int[] meshIndices, float thickness) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) int count = hull.selectedFaces.Count; Vector3[] array = (Vector3[])(object)new Vector3[count * 3 * 2]; for (int i = 0; i < hull.selectedFaces.Count; i++) { int num = hull.selectedFaces[i]; Vector3 val = meshVertices[meshIndices[num * 3]]; Vector3 val2 = meshVertices[meshIndices[num * 3 + 1]]; Vector3 val3 = meshVertices[meshIndices[num * 3 + 2]]; Vector3 val4 = val2 - val; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = val3 - val; Vector3 normalized2 = ((Vector3)(ref val5)).normalized; Vector3 val6 = Vector3.Cross(normalized2, normalized); int num2 = i * 3 * 2; array[num2] = val; array[num2 + 1] = val2; array[num2 + 2] = val3; ref Vector3 reference = ref array[num2 + 3]; reference = val + val6 * faceThickness; ref Vector3 reference2 = ref array[num2 + 4]; reference2 = val2 + val6 * faceThickness; ref Vector3 reference3 = ref array[num2 + 5]; reference3 = val3 + val6 * faceThickness; } int[] array2 = new int[count * 3 * 2]; for (int j = 0; j < array2.Length; j++) { array2[j] = j; } hull.faceCollisionMesh.vertices = array; hull.faceCollisionMesh.triangles = array2; hull.faceCollisionMesh.RecalculateBounds(); hull.collisionMesh = null; } public bool ContainsMesh(Mesh m) { foreach (Hull hull in hulls) { if ((Object)(object)hull.collisionMesh == (Object)(object)m) { return true; } if ((Object)(object)hull.faceCollisionMesh == (Object)(object)m) { return true; } if (hull.autoMeshes == null) { continue; } Mesh[] autoMeshes = hull.autoMeshes; foreach (Mesh val in autoMeshes) { if ((Object)(object)val == (Object)(object)m) { return true; } } } return false; } private static void Inflate(Vector3 point, ref Vector3 min, ref Vector3 max) { min.x = Mathf.Min(min.x, point.x); min.y = Mathf.Min(min.y, point.y); min.z = Mathf.Min(min.z, point.z); max.x = Mathf.Max(max.x, point.x); max.y = Mathf.Max(max.y, point.y); max.z = Mathf.Max(max.z, point.z); } public bool HasAutoHulls() { foreach (Hull hull in hulls) { if (hull.type == HullType.Auto) { return true; } } return false; } } public class PhysicsCreatorInstallRoot : ScriptableObject { } } namespace Technie.PhysicsCreator.QHull { public class Face { public HalfEdge he0; private Vector3d normal; public double area; private Point3d centroid; public double planeOffset; public int index; public int numVerts; public Face next; public const int VISIBLE = 1; public const int NON_CONVEX = 2; public const int DELETED = 3; public int mark = 1; public Vertex outside; public Face() { normal = new Vector3d(); centroid = new Point3d(); mark = 1; } public void computeCentroid(Point3d centroid) { centroid.setZero(); HalfEdge halfEdge = he0; do { centroid.add(halfEdge.head().pnt); halfEdge = halfEdge.next; } while (halfEdge != he0); centroid.scale(1.0 / (double)numVerts); } public void computeNormal(Vector3d normal, double minArea) { computeNormal(normal); if (!(area < minArea)) { return; } HalfEdge halfEdge = null; double num = 0.0; HalfEdge halfEdge2 = he0; do { double num2 = halfEdge2.lengthSquared(); if (num2 > num) { halfEdge = halfEdge2; num = num2; } halfEdge2 = halfEdge2.next; } while (halfEdge2 != he0); Point3d pnt = halfEdge.head().pnt; Point3d pnt2 = halfEdge.tail().pnt; double num3 = Math.Sqrt(num); double num4 = (pnt.x - pnt2.x) / num3; double num5 = (pnt.y - pnt2.y) / num3; double num6 = (pnt.z - pnt2.z) / num3; double num7 = normal.x * num4 + normal.y * num5 + normal.z * num6; normal.x -= num7 * num4; normal.y -= num7 * num5; normal.z -= num7 * num6; normal.normalize(); } public void computeNormal(Vector3d normal) { HalfEdge halfEdge = he0.next; HalfEdge halfEdge2 = halfEdge.next; Point3d pnt = he0.head().pnt; Point3d pnt2 = halfEdge.head().pnt; double num = pnt2.x - pnt.x; double num2 = pnt2.y - pnt.y; double num3 = pnt2.z - pnt.z; normal.setZero(); numVerts = 2; while (halfEdge2 != he0) { double num4 = num; double num5 = num2; double num6 = num3; pnt2 = halfEdge2.head().pnt; num = pnt2.x - pnt.x; num2 = pnt2.y - pnt.y; num3 = pnt2.z - pnt.z; normal.x += num5 * num3 - num6 * num2; normal.y += num6 * num - num4 * num3; normal.z += num4 * num2 - num5 * num; halfEdge = halfEdge2; halfEdge2 = halfEdge2.next; numVerts++; } area = normal.norm(); normal.scale(1.0 / area); } private void computeNormalAndCentroid() { computeNormal(normal); computeCentroid(centroid); planeOffset = normal.dot(centroid); int num = 0; HalfEdge halfEdge = he0; do { num++; halfEdge = halfEdge.next; } while (halfEdge != he0); if (num != numVerts) { throw new InternalErrorException("face " + getVertexString() + " numVerts=" + numVerts + " should be " + num); } } private void computeNormalAndCentroid(double minArea) { computeNormal(normal, minArea); computeCentroid(centroid); planeOffset = normal.dot(centroid); } public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2) { return createTriangle(v0, v1, v2, 0.0); } public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2, double minArea) { Face face = new Face(); HalfEdge halfEdge = new HalfEdge(v0, face); HalfEdge halfEdge2 = new HalfEdge(v1, face); HalfEdge halfEdge3 = (halfEdge.prev = new HalfEdge(v2, face)); halfEdge.next = halfEdge2; halfEdge2.prev = halfEdge; halfEdge2.next = halfEdge3; halfEdge3.prev = halfEdge2; halfEdge3.next = halfEdge; face.he0 = halfEdge; face.computeNormalAndCentroid(minArea); return face; } public static Face create(Vertex[] vtxArray, int[] indices) { Face face = new Face(); HalfEdge halfEdge = null; for (int i = 0; i < indices.Length; i++) { HalfEdge halfEdge2 = new HalfEdge(vtxArray[indices[i]], face); if (halfEdge != null) { halfEdge2.setPrev(halfEdge); halfEdge.setNext(halfEdge2); } else { face.he0 = halfEdge2; } halfEdge = halfEdge2; } face.he0.setPrev(halfEdge); halfEdge.setNext(face.he0); face.computeNormalAndCentroid(); return face; } public HalfEdge getEdge(int i) { HalfEdge prev = he0; while (i > 0) { prev = prev.next; i--; } while (i < 0) { prev = prev.prev; i++; } return prev; } public HalfEdge getFirstEdge() { return he0; } public HalfEdge findEdge(Vertex vt, Vertex vh) { HalfEdge halfEdge = he0; do { if (halfEdge.head() == vh && halfEdge.tail() == vt) { return halfEdge; } halfEdge = halfEdge.next; } while (halfEdge != he0); return null; } public double distanceToPlane(Point3d p) { return normal.x * p.x + normal.y * p.y + normal.z * p.z - planeOffset; } public Vector3d getNormal() { return normal; } public Point3d getCentroid() { return centroid; } public int numVertices() { return numVerts; } public string getVertexString() { string text = null; HalfEdge halfEdge = he0; do { text = ((text != null) ? (text + " " + halfEdge.head().index) : ("" + halfEdge.head().index)); halfEdge = halfEdge.next; } while (halfEdge != he0); return text; } public void getVertexIndices(int[] idxs) { HalfEdge halfEdge = he0; int num = 0; do { idxs[num++] = halfEdge.head().index; halfEdge = halfEdge.next; } while (halfEdge != he0); } private Face connectHalfEdges(HalfEdge hedgePrev, HalfEdge hedge) { Face result = null; if (hedgePrev.oppositeFace() == hedge.oppositeFace()) { Face face = hedge.oppositeFace(); if (hedgePrev == he0) { he0 = hedge; } HalfEdge opposite; if (face.numVertices() == 3) { opposite = hedge.getOpposite().prev.getOpposite(); face.mark = 3; result = face; } else { opposite = hedge.getOpposite().next; if (face.he0 == opposite.prev) { face.he0 = opposite; } opposite.prev = opposite.prev.prev; opposite.prev.next = opposite; } hedge.prev = hedgePrev.prev; hedge.prev.next = hedge; hedge.opposite = opposite; opposite.opposite = hedge; face.computeNormalAndCentroid(); } else { hedgePrev.next = hedge; hedge.prev = hedgePrev; } return result; } public void checkConsistency() { HalfEdge halfEdge = he0; double num = 0.0; int num2 = 0; if (numVerts < 3) { throw new InternalErrorException("degenerate face: " + getVertexString()); } do { HalfEdge opposite = halfEdge.getOpposite(); if (opposite == null) { throw new InternalErrorException("face " + getVertexString() + ": unreflected half edge " + halfEdge.getVertexString()); } if (opposite.getOpposite() != halfEdge) { throw new InternalErrorException("face " + getVertexString() + ": opposite half edge " + opposite.getVertexString() + " has opposite " + opposite.getOpposite().getVertexString()); } if (opposite.head() != halfEdge.tail() || halfEdge.head() != opposite.tail()) { throw new InternalErrorException("face " + getVertexString() + ": half edge " + halfEdge.getVertexString() + " reflected by " + opposite.getVertexString()); } Face face = opposite.face; if (face == null) { throw new InternalErrorException("face " + getVertexString() + ": no face on half edge " + opposite.getVertexString()); } if (face.mark == 3) { throw new InternalErrorException("face " + getVertexString() + ": opposite face " + face.getVertexString() + " not on hull"); } double num3 = Math.Abs(distanceToPlane(halfEdge.head().pnt)); if (num3 > num) { num = num3; } num2++; halfEdge = halfEdge.next; } while (halfEdge != he0); if (num2 != numVerts) { throw new InternalErrorException("face " + getVertexString() + " numVerts=" + numVerts + " should be " + num2); } } public int mergeAdjacentFace(HalfEdge hedgeAdj, Face[] discarded) { Face face = hedgeAdj.oppositeFace(); int result = 0; discarded[result++] = face; face.mark = 3; HalfEdge opposite = hedgeAdj.getOpposite(); HalfEdge prev = hedgeAdj.prev; HalfEdge halfEdge = hedgeAdj.next; HalfEdge prev2 = opposite.prev; HalfEdge halfEdge2 = opposite.next; while (prev.oppositeFace() == face) { prev = prev.prev; halfEdge2 = halfEdge2.next; } while (halfEdge.oppositeFace() == face) { prev2 = prev2.prev; halfEdge = halfEdge.next; } for (HalfEdge halfEdge3 = halfEdge2; halfEdge3 != prev2.next; halfEdge3 = halfEdge3.next) { halfEdge3.face = this; } if (hedgeAdj == he0) { he0 = halfEdge; } Face face2 = connectHalfEdges(prev2, halfEdge); if (face2 != null) { discarded[result++] = face2; } face2 = connectHalfEdges(prev, halfEdge2); if (face2 != null) { discarded[result++] = face2; } computeNormalAndCentroid(); checkConsistency(); return result; } private double areaSquared(HalfEdge hedge0, HalfEdge hedge1) { Point3d pnt = hedge0.tail().pnt; Point3d pnt2 = hedge0.head().pnt; Point3d pnt3 = hedge1.head().pnt; double num = pnt2.x - pnt.x; double num2 = pnt2.y - pnt.y; double num3 = pnt2.z - pnt.z; double num4 = pnt3.x - pnt.x; double num5 = pnt3.y - pnt.y; double num6 = pnt3.z - pnt.z; double num7 = num2 * num6 - num3 * num5; double num8 = num3 * num4 - num * num6; double num9 = num * num5 - num2 * num4; return num7 * num7 + num8 * num8 + num9 * num9; } public void triangulate(FaceList newFaces, double minArea) { if (numVertices() < 4) { return; } Vertex v = he0.head(); HalfEdge halfEdge = he0.next; HalfEdge opposite = halfEdge.opposite; Face face = null; for (halfEdge = halfEdge.next; halfEdge != he0.prev; halfEdge = halfEdge.next) { Face face2 = createTriangle(v, halfEdge.prev.head(), halfEdge.head(), minArea); face2.he0.next.setOpposite(opposite); face2.he0.prev.setOpposite(halfEdge.opposite); opposite = face2.he0; newFaces.add(face2); if (face == null) { face = face2; } } halfEdge = new HalfEdge(he0.prev.prev.head(), this); halfEdge.setOpposite(opposite); halfEdge.prev = he0; halfEdge.prev.next = halfEdge; halfEdge.next = he0.prev; halfEdge.next.prev = halfEdge; computeNormalAndCentroid(minArea); checkConsistency(); for (Face face3 = face; face3 != null; face3 = face3.next) { face3.checkConsistency(); } } } public class FaceList { private Face head; private Face tail; public void clear() { head = (tail = null); } public void add(Face vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.next = null; tail = vtx; } public Face first() { return head; } public bool isEmpty() { return head == null; } } public class HalfEdge { public Vertex vertex; public Face face; public HalfEdge next; public HalfEdge prev; public HalfEdge opposite; public HalfEdge(Vertex v, Face f) { vertex = v; face = f; } public HalfEdge() { } public void setNext(HalfEdge edge) { next = edge; } public HalfEdge getNext() { return next; } public void setPrev(HalfEdge edge) { prev = edge; } public HalfEdge getPrev() { return prev; } public Face getFace() { return face; } public HalfEdge getOpposite() { return opposite; } public void setOpposite(HalfEdge edge) { opposite = edge; edge.opposite = this; } public Vertex head() { return vertex; } public Vertex tail() { return (prev == null) ? null : prev.vertex; } public Face oppositeFace() { return (opposite == null) ? null : opposite.face; } public string getVertexString() { if (tail() != null) { return "" + tail().index + "-" + head().index; } return "?-" + head().index; } public double length() { if (tail() != null) { return head().pnt.distance(tail().pnt); } return -1.0; } public double lengthSquared() { if (tail() != null) { return head().pnt.distanceSquared(tail().pnt); } return -1.0; } } public class InternalErrorException : SystemException { public InternalErrorException(string msg) : base(msg) { } } public class Point3d : Vector3d { public Point3d() { } public Point3d(Vector3d v) { set(v); } public Point3d(double x, double y, double z) { set(x, y, z); } } } namespace Technie.PhysicsCreator { public class QHullUtil { public static Mesh FindConvexHull(string debugName, Mesh inputMesh, bool showErrorInLog) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown Vector3[] vertices = inputMesh.vertices; int[] triangles = inputMesh.triangles; Point3d[] array = new Point3d[triangles.Length]; for (int i = 0; i < triangles.Length; i += 3) { Vector3 val = vertices[triangles[i]]; Vector3 val2 = vertices[triangles[i + 1]]; Vector3 val3 = vertices[triangles[i + 2]]; array[i] = new Point3d(val.x, val.y, val.z); array[i + 1] = new Point3d(val2.x, val2.y, val2.z); array[i + 2] = new Point3d(val3.x, val3.y, val3.z); } QuickHull3D quickHull3D = new QuickHull3D(); try { quickHull3D.build(array); } catch (Exception) { if (showErrorInLog) { Debug.LogError((object)("Could not generate convex hull for " + debugName)); } } Point3d[] vertices2 = quickHull3D.getVertices(); int[][] faces = quickHull3D.getFaces(); Vector3[] array2 = (Vector3[])(object)new Vector3[vertices2.Length]; for (int j = 0; j < array2.Length; j++) { ref Vector3 reference = ref array2[j]; reference = new Vector3((float)vertices2[j].x, (float)vertices2[j].y, (float)vertices2[j].z); } List list = new List(); for (int k = 0; k < faces.Length; k++) { int num = faces[k].Length; for (int l = 1; l < num - 1; l++) { list.Add(faces[k][0]); list.Add(faces[k][l]); list.Add(faces[k][l + 1]); } } int[] triangles2 = list.ToArray(); Mesh val4 = new Mesh(); val4.vertices = array2; val4.triangles = triangles2; return val4; } public static void FindConvexHull(string debugName, int[] selectedFaces, Vector3[] meshVertices, int[] meshIndices, out Vector3[] hullVertices, out int[] hullIndices, bool showErrorInLog) { //IL_0045: 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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) if (selectedFaces.Length == 0) { hullVertices = (Vector3[])(object)new Vector3[0]; hullIndices = new int[0]; return; } int num = selectedFaces.Length; Point3d[] array = new Point3d[num * 3]; for (int i = 0; i < selectedFaces.Length; i++) { int num2 = selectedFaces[i]; Vector3 val = meshVertices[meshIndices[num2 * 3]]; Vector3 val2 = meshVertices[meshIndices[num2 * 3 + 1]]; Vector3 val3 = meshVertices[meshIndices[num2 * 3 + 2]]; array[i * 3] = new Point3d(val.x, val.y, val.z); array[i * 3 + 1] = new Point3d(val2.x, val2.y, val2.z); array[i * 3 + 2] = new Point3d(val3.x, val3.y, val3.z); } QuickHull3D quickHull3D = new QuickHull3D(); try { quickHull3D.build(array); } catch (Exception) { if (showErrorInLog) { Debug.LogError((object)("Could not generate convex hull for " + debugName)); } } Point3d[] vertices = quickHull3D.getVertices(); int[][] faces = quickHull3D.getFaces(); hullVertices = (Vector3[])(object)new Vector3[vertices.Length]; for (int j = 0; j < hullVertices.Length; j++) { ref Vector3 reference = ref hullVertices[j]; reference = new Vector3((float)vertices[j].x, (float)vertices[j].y, (float)vertices[j].z); } List list = new List(); for (int k = 0; k < faces.Length; k++) { int num3 = faces[k].Length; for (int l = 1; l < num3 - 1; l++) { list.Add(faces[k][0]); list.Add(faces[k][l]); list.Add(faces[k][l + 1]); } } hullIndices = list.ToArray(); } } } namespace Technie.PhysicsCreator.QHull { internal class QhullTest { } public class QuickHull3D { public const int CLOCKWISE = 1; public const int INDEXED_FROM_ONE = 2; public const int INDEXED_FROM_ZERO = 4; public const int POINT_RELATIVE = 8; public const double AUTOMATIC_TOLERANCE = -1.0; protected int findIndex = -1; protected double charLength; protected bool debug = false; protected Vertex[] pointBuffer = new Vertex[0]; protected int[] vertexPointIndices = new int[0]; private Face[] discardedFaces = new Face[3]; private Vertex[] maxVtxs = new Vertex[3]; private Vertex[] minVtxs = new Vertex[3]; protected List faces = new List(16); protected List horizon = new List(16); private FaceList newFaces = new FaceList(); private VertexList unclaimed = new VertexList(); private VertexList claimed = new VertexList(); protected int numVertices; protected int numFaces; protected int numPoints; protected double explicitTolerance = -1.0; protected double tolerance; private const double DOUBLE_PREC = 2.220446049250313E-16; private const int NONCONVEX_WRT_LARGER_FACE = 1; private const int NONCONVEX = 2; public QuickHull3D() { } public QuickHull3D(double[] coords) { build(coords, coords.Length / 3); } public QuickHull3D(Point3d[] points) { build(points, points.Length); } public bool getDebug() { return debug; } public void setDebug(bool enable) { debug = enable; } public double getDistanceTolerance() { return tolerance; } public void setExplicitDistanceTolerance(double tol) { explicitTolerance = tol; } public double getExplicitDistanceTolerance() { return explicitTolerance; } private void addPointToFace(Vertex vtx, Face face) { vtx.face = face; if (face.outside == null) { claimed.add(vtx); } else { claimed.insertBefore(vtx, face.outside); } face.outside = vtx; } private void removePointFromFace(Vertex vtx, Face face) { if (vtx == face.outside) { if (vtx.next != null && vtx.next.face == face) { face.outside = vtx.next; } else { face.outside = null; } } claimed.delete(vtx); } private Vertex removeAllPointsFromFace(Face face) { if (face.outside != null) { Vertex vertex = face.outside; while (vertex.next != null && vertex.next.face == face) { vertex = vertex.next; } claimed.delete(face.outside, vertex); vertex.next = null; return face.outside; } return null; } private HalfEdge findHalfEdge(Vertex tail, Vertex head) { foreach (Face face in faces) { HalfEdge halfEdge = face.findEdge(tail, head); if (halfEdge != null) { return halfEdge; } } return null; } protected void setHull(double[] coords, int nump, int[][] faceIndices, int numf) { initBuffers(nump); setPoints(coords, nump); computeMaxAndMin(); for (int i = 0; i < numf; i++) { Face face = Face.create(pointBuffer, faceIndices[i]); HalfEdge halfEdge = face.he0; do { HalfEdge halfEdge2 = findHalfEdge(halfEdge.head(), halfEdge.tail()); if (halfEdge2 != null) { halfEdge.setOpposite(halfEdge2); } halfEdge = halfEdge.next; } while (halfEdge != face.he0); faces.Add(face); } } public void build(double[] coords) { build(coords, coords.Length / 3); } public void build(double[] coords, int nump) { if (nump < 4) { throw new SystemException("Less than four input points specified"); } if (coords.Length / 3 < nump) { throw new SystemException("Coordinate array too small for specified number of points"); } initBuffers(nump); setPoints(coords, nump); buildHull(); } public void build(Point3d[] points) { build(points, points.Length); } public void build(Point3d[] points, int nump) { if (nump < 4) { throw new SystemException("Less than four input points specified"); } if (points.Length < nump) { throw new SystemException("Point array too small for specified number of points"); } initBuffers(nump); setPoints(points, nump); buildHull(); } public void triangulate() { double minArea = 1000.0 * charLength * 2.220446049250313E-16; newFaces.clear(); foreach (Face face2 in faces) { if (face2.mark == 1) { face2.triangulate(newFaces, minArea); } } for (Face face = newFaces.first(); face != null; face = face.next) { faces.Add(face); } } protected void initBuffers(int nump) { if (pointBuffer.Length < nump) { Vertex[] array = new Vertex[nump]; vertexPointIndices = new int[nump]; for (int i = 0; i < pointBuffer.Length; i++) { array[i] = pointBuffer[i]; } for (int j = pointBuffer.Length; j < nump; j++) { array[j] = new Vertex(); } pointBuffer = array; } faces.Clear(); claimed.clear(); numFaces = 0; numPoints = nump; } protected void setPoints(double[] coords, int nump) { for (int i = 0; i < nump; i++) { Vertex vertex = pointBuffer[i]; vertex.pnt.set(coords[i * 3], coords[i * 3 + 1], coords[i * 3 + 2]); vertex.index = i; } } protected void setPoints(Point3d[] pnts, int nump) { for (int i = 0; i < nump; i++) { Vertex vertex = pointBuffer[i]; vertex.pnt.set(pnts[i]); vertex.index = i; } } protected void computeMaxAndMin() { Vector3d vector3d = new Vector3d(); Vector3d vector3d2 = new Vector3d(); for (int i = 0; i < 3; i++) { maxVtxs[i] = (minVtxs[i] = pointBuffer[0]); } vector3d.set(pointBuffer[0].pnt); vector3d2.set(pointBuffer[0].pnt); for (int j = 1; j < numPoints; j++) { Point3d pnt = pointBuffer[j].pnt; if (pnt.x > vector3d.x) { vector3d.x = pnt.x; maxVtxs[0] = pointBuffer[j]; } else if (pnt.x < vector3d2.x) { vector3d2.x = pnt.x; minVtxs[0] = pointBuffer[j]; } if (pnt.y > vector3d.y) { vector3d.y = pnt.y; maxVtxs[1] = pointBuffer[j]; } else if (pnt.y < vector3d2.y) { vector3d2.y = pnt.y; minVtxs[1] = pointBuffer[j]; } if (pnt.z > vector3d.z) { vector3d.z = pnt.z; maxVtxs[2] = pointBuffer[j]; } else if (pnt.z < vector3d2.z) { vector3d2.z = pnt.z; minVtxs[2] = pointBuffer[j]; } } charLength = Math.Max(vector3d.x - vector3d2.x, vector3d.y - vector3d2.y); charLength = Math.Max(vector3d.z - vector3d2.z, charLength); if (explicitTolerance == -1.0) { tolerance = 6.661338147750939E-16 * (Math.Max(Math.Abs(vector3d.x), Math.Abs(vector3d2.x)) + Math.Max(Math.Abs(vector3d.y), Math.Abs(vector3d2.y)) + Math.Max(Math.Abs(vector3d.z), Math.Abs(vector3d2.z))); } else { tolerance = explicitTolerance; } } protected void createInitialSimplex() { double num = 0.0; int num2 = 0; for (int i = 0; i < 3; i++) { double num3 = maxVtxs[i].pnt.get(i) - minVtxs[i].pnt.get(i); if (num3 > num) { num = num3; num2 = i; } } if (num <= tolerance) { throw new SystemException("Input points appear to be coincident"); } Vertex[] array = new Vertex[4] { maxVtxs[num2], minVtxs[num2], null, null }; Vector3d vector3d = new Vector3d(); Vector3d vector3d2 = new Vector3d(); Vector3d vector3d3 = new Vector3d(); Vector3d vector3d4 = new Vector3d(); double num4 = 0.0; vector3d.sub(array[1].pnt, array[0].pnt); vector3d.normalize(); for (int j = 0; j < numPoints; j++) { vector3d2.sub(pointBuffer[j].pnt, array[0].pnt); vector3d4.cross(vector3d, vector3d2); double num5 = vector3d4.normSquared(); if (num5 > num4 && pointBuffer[j] != array[0] && pointBuffer[j] != array[1]) { num4 = num5; array[2] = pointBuffer[j]; vector3d3.set(vector3d4); } } if (Math.Sqrt(num4) <= 100.0 * tolerance) { throw new SystemException("Input points appear to be colinear"); } vector3d3.normalize(); double num6 = 0.0; double num7 = array[2].pnt.dot(vector3d3); for (int k = 0; k < numPoints; k++) { double num8 = Math.Abs(pointBuffer[k].pnt.dot(vector3d3) - num7); if (num8 > num6 && pointBuffer[k] != array[0] && pointBuffer[k] != array[1] && pointBuffer[k] != array[2]) { num6 = num8; array[3] = pointBuffer[k]; } } if (Math.Abs(num6) <= 100.0 * tolerance) { throw new SystemException("Input points appear to be coplanar"); } Face[] array2 = new Face[4]; if (array[3].pnt.dot(vector3d3) - num7 < 0.0) { array2[0] = Face.createTriangle(array[0], array[1], array[2]); array2[1] = Face.createTriangle(array[3], array[1], array[0]); array2[2] = Face.createTriangle(array[3], array[2], array[1]); array2[3] = Face.createTriangle(array[3], array[0], array[2]); for (int l = 0; l < 3; l++) { int num9 = (l + 1) % 3; array2[l + 1].getEdge(1).setOpposite(array2[num9 + 1].getEdge(0)); array2[l + 1].getEdge(2).setOpposite(array2[0].getEdge(num9)); } } else { array2[0] = Face.createTriangle(array[0], array[2], array[1]); array2[1] = Face.createTriangle(array[3], array[0], array[1]); array2[2] = Face.createTriangle(array[3], array[1], array[2]); array2[3] = Face.createTriangle(array[3], array[2], array[0]); for (int m = 0; m < 3; m++) { int num10 = (m + 1) % 3; array2[m + 1].getEdge(0).setOpposite(array2[num10 + 1].getEdge(1)); array2[m + 1].getEdge(2).setOpposite(array2[0].getEdge((3 - m) % 3)); } } for (int n = 0; n < 4; n++) { faces.Add(array2[n]); } for (int num11 = 0; num11 < numPoints; num11++) { Vertex vertex = pointBuffer[num11]; if (vertex == array[0] || vertex == array[1] || vertex == array[2] || vertex == array[3]) { continue; } num6 = tolerance; Face face = null; for (int num12 = 0; num12 < 4; num12++) { double num13 = array2[num12].distanceToPlane(vertex.pnt); if (num13 > num6) { face = array2[num12]; num6 = num13; } } if (face != null) { addPointToFace(vertex, face); } } } public int getNumVertices() { return numVertices; } public Point3d[] getVertices() { Point3d[] array = new Point3d[numVertices]; for (int i = 0; i < numVertices; i++) { array[i] = pointBuffer[vertexPointIndices[i]].pnt; } return array; } public int getVertices(double[] coords) { for (int i = 0; i < numVertices; i++) { Point3d pnt = pointBuffer[vertexPointIndices[i]].pnt; coords[i * 3] = pnt.x; coords[i * 3 + 1] = pnt.y; coords[i * 3 + 2] = pnt.z; } return numVertices; } public int[] getVertexPointIndices() { int[] array = new int[numVertices]; for (int i = 0; i < numVertices; i++) { array[i] = vertexPointIndices[i]; } return array; } public int getNumFaces() { return faces.Count; } public int[][] getFaces() { return getFaces(0); } public int[][] getFaces(int indexFlags) { int[][] array = new int[faces.Count][]; int num = 0; foreach (Face face in faces) { array[num] = new int[face.numVertices()]; getFaceIndices(array[num], face, indexFlags); num++; } return array; } private void getFaceIndices(int[] indices, Face face, int flags) { bool flag = (flags & 1) == 0; bool flag2 = (flags & 2) != 0; bool flag3 = (flags & 8) != 0; HalfEdge halfEdge = face.he0; int num = 0; do { int num2 = halfEdge.head().index; if (flag3) { num2 = vertexPointIndices[num2]; } if (flag2) { num2++; } indices[num++] = num2; halfEdge = ((!flag) ? halfEdge.prev : halfEdge.next); } while (halfEdge != face.he0); } protected void resolveUnclaimedPoints(FaceList newFaces) { Vertex vertex = unclaimed.first(); for (Vertex vertex2 = vertex; vertex2 != null; vertex2 = vertex) { vertex = vertex2.next; double num = tolerance; Face face = null; for (Face face2 = newFaces.first(); face2 != null; face2 = face2.next) { if (face2.mark == 1) { double num2 = face2.distanceToPlane(vertex2.pnt); if (num2 > num) { num = num2; face = face2; } if (num > 1000.0 * tolerance) { break; } } } if (face != null) { addPointToFace(vertex2, face); if (debug && vertex2.index != findIndex) { } } else if (debug && vertex2.index != findIndex) { } } } protected void deleteFacePoints(Face face, Face absorbingFace) { Vertex vertex = removeAllPointsFromFace(face); if (vertex == null) { return; } if (absorbingFace == null) { unclaimed.addAll(vertex); return; } Vertex vertex2 = vertex; for (Vertex vertex3 = vertex2; vertex3 != null; vertex3 = vertex2) { vertex2 = vertex3.next; double num = absorbingFace.distanceToPlane(vertex3.pnt); if (num > tolerance) { addPointToFace(vertex3, absorbingFace); } else { unclaimed.add(vertex3); } } } protected double oppFaceDistance(HalfEdge he) { return he.face.distanceToPlane(he.opposite.face.getCentroid()); } private bool doAdjacentMerge(Face face, int mergeType) { HalfEdge halfEdge = face.he0; bool flag = true; do { Face face2 = halfEdge.oppositeFace(); bool flag2 = false; if (mergeType == 2) { if (oppFaceDistance(halfEdge) > 0.0 - tolerance || oppFaceDistance(halfEdge.opposite) > 0.0 - tolerance) { flag2 = true; } } else if (face.area > face2.area) { double num = oppFaceDistance(halfEdge); if (num > 0.0 - tolerance) { flag2 = true; } else if (oppFaceDistance(halfEdge.opposite) > 0.0 - tolerance) { flag = false; } } else if (oppFaceDistance(halfEdge.opposite) > 0.0 - tolerance) { flag2 = true; } else if (oppFaceDistance(halfEdge) > 0.0 - tolerance) { flag = false; } if (flag2) { if (debug) { } int num2 = face.mergeAdjacentFace(halfEdge, discardedFaces); for (int i = 0; i < num2; i++) { deleteFacePoints(discardedFaces[i], face); } if (debug) { } return true; } halfEdge = halfEdge.next; } while (halfEdge != face.he0); if (!flag) { face.mark = 2; } return false; } protected void calculateHorizon(Point3d eyePnt, HalfEdge edge0, Face face, List horizon) { deleteFacePoints(face, null); face.mark = 3; if (debug) { } HalfEdge halfEdge; if (edge0 == null) { edge0 = face.getEdge(0); halfEdge = edge0; } else { halfEdge = edge0.getNext(); } do { Face face2 = halfEdge.oppositeFace(); if (face2.mark == 1) { if (face2.distanceToPlane(eyePnt) > tolerance) { calculateHorizon(eyePnt, halfEdge.getOpposite(), face2, horizon); } else { horizon.Add(halfEdge); if (!debug) { } } } halfEdge = halfEdge.getNext(); } while (halfEdge != edge0); } private HalfEdge addAdjoiningFace(Vertex eyeVtx, HalfEdge he) { Face face = Face.createTriangle(eyeVtx, he.tail(), he.head()); faces.Add(face); face.getEdge(-1).setOpposite(he.getOpposite()); return face.getEdge(0); } protected void addNewFaces(FaceList newFaces, Vertex eyeVtx, List horizon) { newFaces.clear(); HalfEdge halfEdge = null; HalfEdge halfEdge2 = null; foreach (HalfEdge item in horizon) { HalfEdge halfEdge3 = addAdjoiningFace(eyeVtx, item); if (debug) { } if (halfEdge != null) { halfEdge3.next.setOpposite(halfEdge); } else { halfEdge2 = halfEdge3; } newFaces.add(halfEdge3.getFace()); halfEdge = halfEdge3; } halfEdge2.next.setOpposite(halfEdge); } protected Vertex nextPointToAdd() { if (!claimed.isEmpty()) { Face face = claimed.first().face; Vertex result = null; double num = 0.0; Vertex vertex = face.outside; while (vertex != null && vertex.face == face) { double num2 = face.distanceToPlane(vertex.pnt); if (num2 > num) { num = num2; result = vertex; } vertex = vertex.next; } return result; } return null; } protected void addPointToHull(Vertex eyeVtx) { horizon.Clear(); unclaimed.clear(); if (debug) { } removePointFromFace(eyeVtx, eyeVtx.face); calculateHorizon(eyeVtx.pnt, null, eyeVtx.face, horizon); newFaces.clear(); addNewFaces(newFaces, eyeVtx, horizon); for (Face face = newFaces.first(); face != null; face = face.next) { if (face.mark == 1) { while (doAdjacentMerge(face, 1)) { } } } for (Face face2 = newFaces.first(); face2 != null; face2 = face2.next) { if (face2.mark == 2) { face2.mark = 1; while (doAdjacentMerge(face2, 2)) { } } } resolveUnclaimedPoints(newFaces); } protected void buildHull() { int num = 0; computeMaxAndMin(); createInitialSimplex(); Vertex eyeVtx; while ((eyeVtx = nextPointToAdd()) != null) { addPointToHull(eyeVtx); num++; } reindexFacesAndVertices(); } private void markFaceVertices(Face face, int mark) { HalfEdge firstEdge = face.getFirstEdge(); HalfEdge halfEdge = firstEdge; do { halfEdge.head().index = mark; halfEdge = halfEdge.next; } while (halfEdge != firstEdge); } protected void reindexFacesAndVertices() { for (int i = 0; i < numPoints; i++) { pointBuffer[i].index = -1; } numFaces = 0; for (int j = 0; j < faces.Count; j++) { Face face = faces[j]; if (face.mark != 1) { faces.RemoveAt(j); j--; } else { markFaceVertices(face, 0); numFaces++; } } numVertices = 0; for (int k = 0; k < numPoints; k++) { Vertex vertex = pointBuffer[k]; if (vertex.index == 0) { vertexPointIndices[numVertices] = k; vertex.index = numVertices++; } } } protected bool checkFaceConvexity(Face face, double tol) { HalfEdge halfEdge = face.he0; do { face.checkConsistency(); double num = oppFaceDistance(halfEdge); if (num > tol) { return false; } num = oppFaceDistance(halfEdge.opposite); if (num > tol) { return false; } if (halfEdge.next.oppositeFace() == halfEdge.oppositeFace()) { return false; } halfEdge = halfEdge.next; } while (halfEdge != face.he0); return true; } protected bool checkFaces(double tol) { bool result = true; foreach (Face face in faces) { if (face.mark == 1 && !checkFaceConvexity(face, tol)) { result = false; } } return result; } public bool check() { return check(getDistanceTolerance()); } public bool check(double tol) { double num = 10.0 * tol; if (!checkFaces(tolerance)) { return false; } for (int i = 0; i < numPoints; i++) { Point3d pnt = pointBuffer[i].pnt; foreach (Face face in faces) { if (face.mark == 1) { double num2 = face.distanceToPlane(pnt); if (num2 > num) { return false; } } } } return true; } } public class SimpleExample { public static void main(string[] args) { Point3d[] points = new Point3d[7] { new Point3d(0.0, 0.0, 0.0), new Point3d(1.0, 0.5, 0.0), new Point3d(2.0, 0.0, 0.0), new Point3d(0.5, 0.5, 0.5), new Point3d(0.0, 0.0, 2.0), new Point3d(0.1, 0.2, 0.3), new Point3d(0.0, 2.0, 0.0) }; QuickHull3D quickHull3D = new QuickHull3D(); quickHull3D.build(points); } } public class Vector3d { private const double DOUBLE_PREC = 2.220446049250313E-16; public double x; public double y; public double z; public Vector3d() { } public Vector3d(Vector3d v) { set(v); } public Vector3d(double x, double y, double z) { set(x, y, z); } public double get(int i) { return i switch { 0 => x, 1 => y, 2 => z, _ => throw new IndexOutOfRangeException("" + i), }; } public void set(int i, double value) { switch (i) { case 0: x = value; break; case 1: y = value; break; case 2: z = value; break; default: throw new IndexOutOfRangeException("" + i); } } public void set(Vector3d v1) { x = v1.x; y = v1.y; z = v1.z; } public void add(Vector3d v1, Vector3d v2) { x = v1.x + v2.x; y = v1.y + v2.y; z = v1.z + v2.z; } public void add(Vector3d v1) { x += v1.x; y += v1.y; z += v1.z; } public void sub(Vector3d v1, Vector3d v2) { x = v1.x - v2.x; y = v1.y - v2.y; z = v1.z - v2.z; } public void sub(Vector3d v1) { x -= v1.x; y -= v1.y; z -= v1.z; } public void scale(double s) { x = s * x; y = s * y; z = s * z; } public void scale(double s, Vector3d v1) { x = s * v1.x; y = s * v1.y; z = s * v1.z; } public double norm() { return Math.Sqrt(x * x + y * y + z * z); } public double normSquared() { return x * x + y * y + z * z; } public double distance(Vector3d v) { double num = x - v.x; double num2 = y - v.y; double num3 = z - v.z; return Math.Sqrt(num * num + num2 * num2 + num3 * num3); } public double distanceSquared(Vector3d v) { double num = x - v.x; double num2 = y - v.y; double num3 = z - v.z; return num * num + num2 * num2 + num3 * num3; } public double dot(Vector3d v1) { return x * v1.x + y * v1.y + z * v1.z; } public void normalize() { double num = x * x + y * y + z * z; double num2 = num - 1.0; if (num2 > 4.440892098500626E-16 || num2 < -4.440892098500626E-16) { double num3 = Math.Sqrt(num); x /= num3; y /= num3; z /= num3; } } public void setZero() { x = 0.0; y = 0.0; z = 0.0; } public void set(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } public void cross(Vector3d v1, Vector3d v2) { double num = v1.y * v2.z - v1.z * v2.y; double num2 = v1.z * v2.x - v1.x * v2.z; double num3 = v1.x * v2.y - v1.y * v2.x; x = num; y = num2; z = num3; } protected void setRandom(double lower, double upper, Random generator) { double num = upper - lower; x = generator.NextDouble() * num + lower; y = generator.NextDouble() * num + lower; z = generator.NextDouble() * num + lower; } public string toString() { return x + " " + y + " " + z; } } public class Vertex { public Point3d pnt; public int index; public Vertex prev; public Vertex next; public Face face; public Vertex() { pnt = new Point3d(); } public Vertex(double x, double y, double z, int idx) { pnt = new Point3d(x, y, z); index = idx; } } internal class VertexList { private Vertex head; private Vertex tail; public void clear() { head = (tail = null); } public void add(Vertex vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.prev = tail; vtx.next = null; tail = vtx; } public void addAll(Vertex vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.prev = tail; while (vtx.next != null) { vtx = vtx.next; } tail = vtx; } public void delete(Vertex vtx) { if (vtx.prev == null) { head = vtx.next; } else { vtx.prev.next = vtx.next; } if (vtx.next == null) { tail = vtx.prev; } else { vtx.next.prev = vtx.prev; } } public void delete(Vertex vtx1, Vertex vtx2) { if (vtx1.prev == null) { head = vtx2.next; } else { vtx1.prev.next = vtx2.next; } if (vtx2.next == null) { tail = vtx1.prev; } else { vtx2.next.prev = vtx1.prev; } } public void insertBefore(Vertex vtx, Vertex next) { vtx.prev = next.prev; if (next.prev == null) { head = vtx; } else { next.prev.next = vtx; } vtx.next = next; next.prev = vtx; } public Vertex first() { return head; } public bool isEmpty() { return head == null; } } } namespace Technie.PhysicsCreator { public enum BoxFitMethod { AxisAligned, MinimumVolume, AlignFaces } public class ConstructionPlane { public Vector3 center; public Vector3 normal; public Vector3 tangent; public Quaternion rotation; public Matrix4x4 planeToWorld; public Matrix4x4 worldToPlane; public ConstructionPlane(Vector3 c, Vector3 n, Vector3 t) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) center = c; normal = n; tangent = t; Init(); } public ConstructionPlane(ConstructionPlane basePlane, float angle) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003a: 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) Quaternion val = Quaternion.AngleAxis(angle, basePlane.normal); Vector3 val2 = val * basePlane.tangent; center = basePlane.center; normal = basePlane.normal; tangent = val2; Init(); } private void Init() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (((Vector3)(ref normal)).magnitude < 0.01f) { Debug.LogError((object)"!"); } rotation = Quaternion.LookRotation(normal, tangent); planeToWorld = Matrix4x4.TRS(center, rotation, Vector3.one); worldToPlane = ((Matrix4x4)(ref planeToWorld)).inverse; } } public class RotatedBox { public ConstructionPlane plane; public Vector3 localCenter; public Vector3 center; public Vector3 size; public float volume; public float VolumeCm3 => volume * 1000000f; public RotatedBox(ConstructionPlane p, Vector3 localCenter, Vector3 c, Vector3 s) { //IL_000f: 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_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) plane = p; this.localCenter = localCenter; center = c; size = s; volume = size.x * size.y * size.z; } } public class VolumeSorter : IComparer { public int Compare(RotatedBox lhs, RotatedBox rhs) { if (Mathf.Approximately(lhs.volume, rhs.volume)) { return 0; } if (lhs.volume > rhs.volume) { return 1; } return -1; } } public class RotatedBoxFitter { public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices) { //IL_007b: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c9: 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_00d0: 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_00db: 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_00e7: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var hullIndices, showErrorInLog: false); if (hullVertices == null || hullVertices.Length == 0) { FaceAlignmentBoxFitter.FindTriangles(hull, meshVertices, meshIndices, out hullVertices, out hullIndices); } List list = new List(); int num = 64; int numVariants = 128; float angleRange = 360f / (float)num; for (int i = 0; i < hullIndices.Length; i += 3) { int num2 = hullIndices[i]; int num3 = hullIndices[i + 1]; int num4 = hullIndices[i + 2]; Vector3 val = hullVertices[num2]; Vector3 val2 = hullVertices[num3]; Vector3 val3 = hullVertices[num4]; Vector3 c = (val + val2 + val3) / 3f; Vector3 val4 = val2 - val; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = val3 - val; Vector3 val6 = Vector3.Cross(normalized, ((Vector3)(ref val5)).normalized); Vector3 val7 = ((!(Mathf.Abs(Vector3.Dot(val6, Vector3.up)) > 0.9f)) ? Vector3.up : Vector3.right); Vector3 t = Vector3.Cross(val6, val7); if (((Vector3)(ref val6)).magnitude > 0.0001f) { ConstructionPlane basePlane = new ConstructionPlane(c, val6, t); for (int j = 0; j < num; j++) { float angle = (float)j / (float)(num - 1) * 360f; ConstructionPlane item = new ConstructionPlane(basePlane, angle); list.Add(item); } } } List list2 = FindTightestBoxes(list, hullVertices); if (list2.Count > 0) { list2.Sort(new VolumeSorter()); RotatedBox rotatedBox = list2[0]; List list3 = new List(); GeneratePlaneVariants(list2[0].plane, numVariants, angleRange, list3); List list4 = FindTightestBoxes(list3, hullVertices); list4.Sort(new VolumeSorter()); RotatedBox computedBox = list4[0]; ApplyToHull(computedBox, hull); } else { Debug.LogError((object)("Couldn't fit box rotation to hull for " + hull.name)); } } private static void GeneratePlaneVariants(ConstructionPlane basePlane, int numVariants, float angleRange, List variantPlanes) { variantPlanes.Add(basePlane); for (int i = 0; i < numVariants; i++) { float num = (float)i / (float)(numVariants - 1); float angle = Mathf.Lerp(0f - angleRange, angleRange, num); variantPlanes.Add(new ConstructionPlane(basePlane, angle)); } } public static void ApplyToHull(RotatedBox computedBox, Hull targetHull) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0040: Unknown result type (might be due to invalid IL or missing references) ((Bounds)(ref targetHull.collisionBox)).center = computedBox.localCenter; ((Bounds)(ref targetHull.collisionBox)).size = computedBox.size; targetHull.boxPosition = computedBox.plane.center; targetHull.boxRotation = computedBox.plane.rotation; } private static List FindTightestBoxes(List planes, Vector3[] inputVertices) { if (inputVertices == null || inputVertices.Length == 0) { return new List(); } List list = new List(); foreach (ConstructionPlane plane in planes) { RotatedBox item = FindTightestBox(plane, inputVertices); list.Add(item); } return list; } public static RotatedBox FindTightestBox(ConstructionPlane plane, Vector3[] inputVertices) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) //IL_0052: 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_005a: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007f: 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_008a: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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) if (inputVertices == null || inputVertices.Length == 0) { return null; } Vector3 val; Vector3 val2 = (val = ((Matrix4x4)(ref plane.worldToPlane)).MultiplyPoint(inputVertices[0])); foreach (Vector3 val3 in inputVertices) { Vector3 val4 = ((Matrix4x4)(ref plane.worldToPlane)).MultiplyPoint(val3); val2 = Vector3.Min(val4, val2); val = Vector3.Max(val4, val); } Vector3 val5 = Vector3.Lerp(val2, val, 0.5f); Vector3 c = ((Matrix4x4)(ref plane.planeToWorld)).MultiplyPoint(val5); Vector3 s = val - val2; return new RotatedBox(plane, val5, c, s); } } public class Sphere { public Vector3 center; public float radius = 1f; } public class SphereUtils { public class Support { public int m_iQuantity; public int[] m_aiIndex = new int[4]; public bool Contains(int iIndex, List points) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_iQuantity; i++) { Vector3 val = points[iIndex] - points[m_aiIndex[i]]; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { return true; } } return false; } } private const float kEpsilon = 0.001f; private const float kOnePlusEpsilon = 1.001f; private static bool PointInsideSphere(Vector3 rkP, Sphere rkS) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rkP - rkS.center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; return sqrMagnitude <= 1.001f * rkS.radius; } private static Sphere ExactSphere1(Vector3 rkP) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Sphere sphere = new Sphere(); sphere.center = rkP; sphere.radius = 0f; return sphere; } private static Sphere ExactSphere2(Vector3 rkP0, Vector3 rkP1) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Sphere sphere = new Sphere(); sphere.center = 0.5f * (rkP0 + rkP1); Vector3 val = rkP1 - rkP0; sphere.radius = 0.25f * ((Vector3)(ref val)).sqrMagnitude; return sphere; } private static Sphere ExactSphere3(Vector3 rkP0, Vector3 rkP1, Vector3 rkP2) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0094: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rkP0 - rkP2; Vector3 val2 = rkP1 - rkP2; float num = Vector3.Dot(val, val); float num2 = Vector3.Dot(val, val2); float num3 = Vector3.Dot(val2, val2); float num4 = num * num3 - num2 * num2; Sphere sphere = new Sphere(); float num5 = 0.5f / num4; float num6 = num5 * num3 * (num - num2); float num7 = num5 * num * (num3 - num2); float num8 = 1f - num6 - num7; sphere.center = num6 * rkP0 + num7 * rkP1 + num8 * rkP2; Vector3 val3 = num6 * val + num7 * val2; sphere.radius = ((Vector3)(ref val3)).sqrMagnitude; return sphere; } private static Sphere ExactSphere4(Vector3 rkP0, Vector3 rkP1, Vector3 rkP2, Vector3 rkP3) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: 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_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03db: 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_03e6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rkP0 - rkP3; Vector3 val2 = rkP1 - rkP3; Vector3 val3 = rkP2 - rkP3; float[,] array = new float[3, 3]; array[0, 0] = Vector3.Dot(val, val); array[0, 1] = Vector3.Dot(val, val2); array[0, 2] = Vector3.Dot(val, val3); array[1, 0] = array[0, 1]; array[1, 1] = Vector3.Dot(val2, val2); array[1, 2] = Vector3.Dot(val2, val3); array[2, 0] = array[0, 2]; array[2, 1] = array[1, 2]; array[2, 2] = Vector3.Dot(val3, val3); float[] array2 = new float[3] { 0.5f * array[0, 0], 0.5f * array[1, 1], 0.5f * array[2, 2] }; float[,] array3 = new float[3, 3] { { array[1, 1] * array[2, 2] - array[1, 2] * array[2, 1], array[0, 2] * array[2, 1] - array[0, 1] * array[2, 2], array[0, 1] * array[1, 2] - array[0, 2] * array[1, 1] }, { array[1, 2] * array[2, 0] - array[1, 0] * array[2, 2], array[0, 0] * array[2, 2] - array[0, 2] * array[2, 0], array[0, 2] * array[1, 0] - array[0, 0] * array[1, 2] }, { array[1, 0] * array[2, 1] - array[1, 1] * array[2, 0], array[0, 1] * array[2, 0] - array[0, 0] * array[2, 1], array[0, 0] * array[1, 1] - array[0, 1] * array[1, 0] } }; float num = array[0, 0] * array3[0, 0] + array[0, 1] * array3[1, 0] + array[0, 2] * array3[2, 0]; Sphere sphere = new Sphere(); float num2 = 1f / num; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { array3[i, j] *= num2; } } float[] array4 = new float[4]; for (int i = 0; i < 3; i++) { array4[i] = 0f; for (int j = 0; j < 3; j++) { array4[i] += array3[i, j] * array2[j]; } } array4[3] = 1f - array4[0] - array4[1] - array4[2]; sphere.center = array4[0] * rkP0 + array4[1] * rkP1 + array4[2] * rkP2 + array4[3] * rkP3; Vector3 val4 = array4[0] * val + array4[1] * val2 + array4[2] * val3; sphere.radius = ((Vector3)(ref val4)).sqrMagnitude; return sphere; } private static Sphere UpdateSupport1(int i, List apkPerm, Support rkSupp) { //IL_000a: 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_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Vector3 rkP = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 rkP2 = apkPerm[i]; Sphere result = ExactSphere2(rkP, rkP2); rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[1] = i; return result; } private static Sphere UpdateSupport2(int i, List apkPerm, Support rkSupp) { //IL_000a: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) Vector3 val = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 val2 = apkPerm[rkSupp.m_aiIndex[1]]; Vector3 val3 = apkPerm[i]; Sphere[] array = new Sphere[3]; float num = float.PositiveInfinity; int num2 = -1; array[0] = ExactSphere2(val, val3); if (PointInsideSphere(val2, array[0])) { num = array[0].radius; num2 = 0; } array[1] = ExactSphere2(val2, val3); if (PointInsideSphere(val, array[1]) && array[1].radius < num) { num = array[1].radius; num2 = 1; } Sphere result; if (num2 != -1) { result = array[num2]; rkSupp.m_aiIndex[1 - num2] = i; } else { result = ExactSphere3(val, val2, val3); rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[2] = i; } return result; } private static Sphere UpdateSupport3(int i, List apkPerm, Support rkSupp) { //IL_000a: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0035: 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) //IL_004c: 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_0084: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00d0: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) Vector3 val = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 val2 = apkPerm[rkSupp.m_aiIndex[1]]; Vector3 val3 = apkPerm[rkSupp.m_aiIndex[2]]; Vector3 val4 = apkPerm[i]; Sphere[] array = new Sphere[6]; float num = float.PositiveInfinity; int num2 = -1; array[0] = ExactSphere2(val, val4); if (PointInsideSphere(val2, array[0]) && PointInsideSphere(val3, array[0])) { num = array[0].radius; num2 = 0; } array[1] = ExactSphere2(val2, val4); if (PointInsideSphere(val, array[1]) && PointInsideSphere(val3, array[1]) && array[1].radius < num) { num = array[1].radius; num2 = 1; } array[2] = ExactSphere2(val3, val4); if (PointInsideSphere(val, array[2]) && PointInsideSphere(val2, array[2]) && array[2].radius < num) { num = array[2].radius; num2 = 2; } array[3] = ExactSphere3(val, val2, val4); if (PointInsideSphere(val3, array[3]) && array[3].radius < num) { num = array[3].radius; num2 = 3; } array[4] = ExactSphere3(val, val3, val4); if (PointInsideSphere(val2, array[4]) && array[4].radius < num) { num = array[4].radius; num2 = 4; } array[5] = ExactSphere3(val2, val3, val4); if (PointInsideSphere(val, array[5]) && array[5].radius < num) { num = array[5].radius; num2 = 5; } Sphere result; switch (num2) { case 0: result = array[0]; rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[1] = i; break; case 1: result = array[1]; rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = i; break; case 2: result = array[2]; rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[2]; rkSupp.m_aiIndex[1] = i; break; case 3: result = array[3]; rkSupp.m_aiIndex[2] = i; break; case 4: result = array[4]; rkSupp.m_aiIndex[1] = i; break; case 5: result = array[5]; rkSupp.m_aiIndex[0] = i; break; default: result = ExactSphere4(val, val2, val3, val4); rkSupp.m_iQuantity = 4; rkSupp.m_aiIndex[3] = i; break; } return result; } public static Sphere UpdateSupport4(int i, List apkPerm, Support rkSupp) { //IL_000a: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_00bd: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033a: 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_0303: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0415: 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_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) Vector3 val = apkPerm[rkSupp.m_aiIndex[0]]; Vector3 val2 = apkPerm[rkSupp.m_aiIndex[1]]; Vector3 val3 = apkPerm[rkSupp.m_aiIndex[2]]; Vector3 val4 = apkPerm[rkSupp.m_aiIndex[3]]; Vector3 val5 = apkPerm[i]; Sphere[] array = new Sphere[14]; float num = float.PositiveInfinity; int num2 = -1; array[0] = ExactSphere2(val, val5); if (PointInsideSphere(val2, array[0]) && PointInsideSphere(val3, array[0]) && PointInsideSphere(val4, array[0])) { num = array[0].radius; num2 = 0; } array[1] = ExactSphere2(val2, val5); if (PointInsideSphere(val, array[1]) && PointInsideSphere(val3, array[1]) && PointInsideSphere(val4, array[1]) && array[1].radius < num) { num = array[1].radius; num2 = 1; } array[2] = ExactSphere2(val3, val5); if (PointInsideSphere(val, array[2]) && PointInsideSphere(val2, array[2]) && PointInsideSphere(val4, array[2]) && array[2].radius < num) { num = array[2].radius; num2 = 2; } array[3] = ExactSphere2(val4, val5); if (PointInsideSphere(val, array[3]) && PointInsideSphere(val2, array[3]) && PointInsideSphere(val3, array[3]) && array[3].radius < num) { num = array[3].radius; num2 = 3; } array[4] = ExactSphere3(val, val2, val5); if (PointInsideSphere(val3, array[4]) && PointInsideSphere(val4, array[4]) && array[4].radius < num) { num = array[4].radius; num2 = 4; } array[5] = ExactSphere3(val, val3, val5); if (PointInsideSphere(val2, array[5]) && PointInsideSphere(val4, array[5]) && array[5].radius < num) { num = array[5].radius; num2 = 5; } array[6] = ExactSphere3(val, val4, val5); if (PointInsideSphere(val2, array[6]) && PointInsideSphere(val3, array[6]) && array[6].radius < num) { num = array[6].radius; num2 = 6; } array[7] = ExactSphere3(val2, val3, val5); if (PointInsideSphere(val, array[7]) && PointInsideSphere(val4, array[7]) && array[7].radius < num) { num = array[7].radius; num2 = 7; } array[8] = ExactSphere3(val2, val4, val5); if (PointInsideSphere(val, array[8]) && PointInsideSphere(val3, array[8]) && array[8].radius < num) { num = array[8].radius; num2 = 8; } array[9] = ExactSphere3(val3, val4, val5); if (PointInsideSphere(val, array[9]) && PointInsideSphere(val2, array[9]) && array[9].radius < num) { num = array[9].radius; num2 = 9; } array[10] = ExactSphere4(val, val2, val3, val5); if (PointInsideSphere(val4, array[10]) && array[10].radius < num) { num = array[10].radius; num2 = 10; } array[11] = ExactSphere4(val, val2, val4, val5); if (PointInsideSphere(val3, array[11]) && array[11].radius < num) { num = array[11].radius; num2 = 11; } array[12] = ExactSphere4(val, val3, val4, val5); if (PointInsideSphere(val2, array[12]) && array[12].radius < num) { num = array[12].radius; num2 = 12; } array[13] = ExactSphere4(val2, val3, val4, val5); if (PointInsideSphere(val, array[13]) && array[13].radius < num) { num = array[13].radius; num2 = 13; } Sphere result = array[num2]; switch (num2) { case 0: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[1] = i; break; case 1: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = i; break; case 2: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[2]; rkSupp.m_aiIndex[1] = i; break; case 3: rkSupp.m_iQuantity = 2; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[1] = i; break; case 4: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[2] = i; break; case 5: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[1] = i; break; case 6: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[1] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[2] = i; break; case 7: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[0] = i; break; case 8: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[2] = i; break; case 9: rkSupp.m_iQuantity = 3; rkSupp.m_aiIndex[0] = rkSupp.m_aiIndex[3]; rkSupp.m_aiIndex[1] = i; break; case 10: rkSupp.m_aiIndex[3] = i; break; case 11: rkSupp.m_aiIndex[2] = i; break; case 12: rkSupp.m_aiIndex[1] = i; break; case 13: rkSupp.m_aiIndex[0] = i; break; } return result; } private static Sphere Update(int funcIndex, int numPoints, List points, Support support) { return funcIndex switch { 0 => null, 1 => UpdateSupport1(numPoints, points, support), 2 => UpdateSupport2(numPoints, points, support), 3 => UpdateSupport3(numPoints, points, support), 4 => UpdateSupport4(numPoints, points, support), _ => null, }; } public static Sphere MinSphere(List inputPoints) { //IL_0029: 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) Sphere sphere = new Sphere(); Support support = new Support(); if (inputPoints.Count >= 1) { List list = new List(inputPoints); Shuffle(list); sphere = ExactSphere1(list[0]); support.m_iQuantity = 1; support.m_aiIndex[0] = 0; int num = 1; while (num < inputPoints.Count) { if (!support.Contains(num, list) && !PointInsideSphere(list[num], sphere)) { sphere = Update(support.m_iQuantity, num, list, support); num = 0; } else { num++; } } } sphere.radius = Mathf.Sqrt(sphere.radius); return sphere; } public static void Shuffle(List list) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < list.Count; i++) { int index = i + Random.Range(0, list.Count - i); Vector3 value = list[index]; list[index] = list[i]; list[i] = value; } } } [Serializable] public class VhacdParameters { [Tooltip("maximum concavity")] [Range(0f, 1f)] public float concavity; [Tooltip("controls the bias toward clipping along symmetry planes")] [Range(0f, 1f)] public float alpha; [Tooltip("controls the bias toward clipping along revolution axes")] [Range(0f, 1f)] public float beta; [Tooltip("controls the adaptive sampling of the generated convex-hulls")] [Range(0f, 0.01f)] public float minVolumePerCH; [Tooltip("maximum number of voxels generated during the voxelization stage")] [Range(10000f, 64000000f)] public uint resolution; [Tooltip("controls the maximum number of triangles per convex-hull")] [Range(4f, 1024f)] public uint maxNumVerticesPerCH; [Tooltip("controls the granularity of the search for the \"best\" clipping plane")] [Range(1f, 16f)] public uint planeDownsampling; [Tooltip("controls the precision of the convex-hull generation process during the clipping plane selection stage")] [Range(1f, 16f)] public uint convexhullDownsampling; [Tooltip("enable/disable normalizing the mesh before applying the convex decomposition")] [Range(0f, 1f)] public uint pca; [Tooltip("0: voxel-based (recommended), 1: tetrahedron-based")] [Range(0f, 1f)] public uint mode; [Range(0f, 1f)] public uint convexhullApproximation; [Tooltip("Enable OpenCL acceleration")] [Range(0f, 1f)] public uint oclAcceleration; public uint maxConvexHulls; [Tooltip("This will project the output convex hull vertices onto the original source mesh to increase the floating point accuracy of the results")] public bool projectHullVertices; public VhacdParameters() { resolution = 100000u; concavity = 0.001f; planeDownsampling = 4u; convexhullDownsampling = 4u; alpha = 0.05f; beta = 0.05f; pca = 0u; mode = 0u; maxNumVerticesPerCH = 64u; minVolumePerCH = 0.0001f; convexhullApproximation = 1u; oclAcceleration = 0u; maxConvexHulls = 1024u; projectHullVertices = true; } } } public class TOD_Animation : MonoBehaviour { [Tooltip("How much to move the clouds when the camera moves.")] [TOD_Min(0f)] public float CameraMovement = 1f; [Tooltip("Wind direction in degrees.")] [TOD_Range(0f, 360f)] public float WindDegrees = 0f; [Tooltip("Speed of the wind that is acting on the clouds.")] [TOD_Min(0f)] public float WindSpeed = 1f; private TOD_Sky sky; public Vector3 CloudUV { get; set; } public Vector3 OffsetUV { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_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_004a: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) Vector3 val = ((Component)this).transform.position * (CameraMovement * 0.0001f); Quaternion rotation = ((Component)this).transform.rotation; Quaternion val2 = Quaternion.Euler(0f, 0f - ((Quaternion)(ref rotation)).eulerAngles.y, 0f); return val2 * val; } } protected void Start() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) sky = ((Component)this).GetComponent(); CloudUV = new Vector3(Random.value, Random.value, Random.value); } protected void Update() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) float num = Mathf.Sin((float)Math.PI / 180f * WindDegrees); float num2 = Mathf.Cos((float)Math.PI / 180f * WindDegrees); float num3 = 0.001f * Time.deltaTime; float num4 = WindSpeed * num3; float x = CloudUV.x; float y = CloudUV.y; float z = CloudUV.z; y += num3 * 0.1f; x -= num4 * num; z -= num4 * num2; x -= Mathf.Floor(x); y -= Mathf.Floor(y); z -= Mathf.Floor(z); CloudUV = new Vector3(x, y, z); sky.Components.BillboardTransform.localRotation = Quaternion.Euler(0f, y * 360f, 0f); } } [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] public class TOD_MinAttribute : PropertyAttribute { public float min; public TOD_MinAttribute(float min) { this.min = min; } } [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] public class TOD_MaxAttribute : PropertyAttribute { public float max; public TOD_MaxAttribute(float max) { this.max = max; } } [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] public class TOD_RangeAttribute : PropertyAttribute { public float min; public float max; public TOD_RangeAttribute(float min, float max) { this.min = min; this.max = max; } } public class TOD_Billboard : MonoBehaviour { public float Altitude = 0f; public float Azimuth = 0f; public float Distance = 1f; public float Size = 1f; private T GetComponentInParents() where T : Component { Transform val = ((Component)this).transform; T component = ((Component)val).GetComponent(); while ((Object)(object)component == (Object)null && (Object)(object)val.parent != (Object)null) { val = val.parent; component = ((Component)val).GetComponent(); } return component; } protected void OnValidate() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_009d: 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_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_00b0: Unknown result type (might be due to invalid IL or missing references) TOD_Sky componentInParents = GetComponentInParents(); if (!((Object)(object)componentInParents == (Object)null)) { float theta = (90f - Altitude) * ((float)Math.PI / 180f); float phi = Azimuth * ((float)Math.PI / 180f); Vector3 val = componentInParents.OrbitalToUnity(Distance, theta, phi); if (((Component)this).transform.localPosition != val) { ((Component)this).transform.localPosition = val; } float num = 2f * Mathf.Tan((float)Math.PI / 90f * Size); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num, num, num); if (((Component)this).transform.localScale != val2) { ((Component)this).transform.localScale = val2; } ((Component)this).transform.LookAt(((Component)componentInParents).transform.position, Vector3.up); } } } [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu("Time of Day/Camera Main Script")] public class TOD_Camera : MonoBehaviour { public TOD_Sky sky; public bool DomePosToCamera = true; public Vector3 DomePosOffset = Vector3.zero; public bool DomeScaleToFarClip = true; public float DomeScaleFactor = 0.95f; private Camera cameraComponent = null; private Transform cameraTransform = null; public bool HDR => Object.op_Implicit((Object)(object)cameraComponent) && cameraComponent.allowHDR; public float NearClipPlane => (!Object.op_Implicit((Object)(object)cameraComponent)) ? 0.1f : cameraComponent.nearClipPlane; public float FarClipPlane => (!Object.op_Implicit((Object)(object)cameraComponent)) ? 1000f : cameraComponent.farClipPlane; public Color BackgroundColor => (!Object.op_Implicit((Object)(object)cameraComponent)) ? Color.black : cameraComponent.backgroundColor; protected void OnValidate() { DomeScaleFactor = Mathf.Clamp(DomeScaleFactor, 0.01f, 1f); } protected void OnEnable() { cameraComponent = ((Component)this).GetComponent(); cameraTransform = ((Component)this).GetComponent(); if (!Object.op_Implicit((Object)(object)sky)) { sky = FindSky(fallback: true); } } protected void Update() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0079: 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_0094: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)sky)) { sky = FindSky(); } if (Object.op_Implicit((Object)(object)sky) && sky.Initialized) { sky.Components.Camera = this; if ((int)cameraComponent.clearFlags != 2) { cameraComponent.clearFlags = (CameraClearFlags)2; } if (cameraComponent.backgroundColor != Color.clear) { cameraComponent.backgroundColor = Color.clear; } if ((Object)(object)RenderSettings.skybox != (Object)(object)sky.Resources.Skybox) { RenderSettings.skybox = sky.Resources.Skybox; DynamicGI.UpdateEnvironment(); } } } protected void OnPreCull() { if (!Object.op_Implicit((Object)(object)sky)) { sky = FindSky(); } if (Object.op_Implicit((Object)(object)sky) && sky.Initialized) { if (DomeScaleToFarClip) { DoDomeScaleToFarClip(); } if (DomePosToCamera) { DoDomePosToCamera(); } } } private TOD_Sky FindSky(bool fallback = false) { if (Object.op_Implicit((Object)(object)TOD_Sky.Instance)) { return TOD_Sky.Instance; } if (fallback) { return Object.FindObjectOfType(typeof(TOD_Sky)) as TOD_Sky; } return null; } public void DoDomeScaleToFarClip() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) float num = DomeScaleFactor * cameraComponent.farClipPlane; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num, num); if (sky.Components.DomeTransform.localScale != val) { sky.Components.DomeTransform.localScale = val; } } public void DoDomePosToCamera() { //IL_0007: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cameraTransform.position + cameraTransform.rotation * DomePosOffset; if (sky.Components.DomeTransform.position != val) { sky.Components.DomeTransform.position = val; } } } [ExecuteInEditMode] public class TOD_Components : MonoBehaviour { public GameObject Space = null; public GameObject Stars = null; public GameObject Sun = null; public GameObject Moon = null; public GameObject Atmosphere = null; public GameObject Clear = null; public GameObject Clouds = null; public GameObject Billboards = null; public GameObject Light = null; public Transform DomeTransform { get; set; } public Transform SpaceTransform { get; set; } public Transform StarTransform { get; set; } public Transform SunTransform { get; set; } public Transform MoonTransform { get; set; } public Transform AtmosphereTransform { get; set; } public Transform ClearTransform { get; set; } public Transform CloudTransform { get; set; } public Transform BillboardTransform { get; set; } public Transform LightTransform { get; set; } public Renderer SpaceRenderer { get; set; } public Renderer StarRenderer { get; set; } public Renderer SunRenderer { get; set; } public Renderer MoonRenderer { get; set; } public Renderer AtmosphereRenderer { get; set; } public Renderer ClearRenderer { get; set; } public Renderer CloudRenderer { get; set; } public Renderer[] BillboardRenderers { get; set; } public MeshFilter SpaceMeshFilter { get; set; } public MeshFilter StarMeshFilter { get; set; } public MeshFilter SunMeshFilter { get; set; } public MeshFilter MoonMeshFilter { get; set; } public MeshFilter AtmosphereMeshFilter { get; set; } public MeshFilter ClearMeshFilter { get; set; } public MeshFilter CloudMeshFilter { get; set; } public MeshFilter[] BillboardMeshFilters { get; set; } public Material SpaceMaterial { get; set; } public Material StarMaterial { get; set; } public Material SunMaterial { get; set; } public Material MoonMaterial { get; set; } public Material AtmosphereMaterial { get; set; } public Material ClearMaterial { get; set; } public Material CloudMaterial { get; set; } public Material[] BillboardMaterials { get; set; } public Light LightSource { get; set; } public TOD_Sky Sky { get; set; } public TOD_Animation Animation { get; set; } public TOD_Time Time { get; set; } public TOD_Camera Camera { get; set; } public TOD_Rays Rays { get; set; } public TOD_Scattering Scattering { get; set; } public TOD_Shadows Shadows { get; set; } public void Initialize() { DomeTransform = ((Component)this).GetComponent(); Sky = ((Component)this).GetComponent(); Animation = ((Component)this).GetComponent(); Time = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)Space)) { SpaceTransform = Space.GetComponent(); SpaceRenderer = Space.GetComponent(); SpaceMeshFilter = Space.GetComponent(); SpaceMaterial = SpaceRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Stars)) { StarTransform = Stars.GetComponent(); StarRenderer = Stars.GetComponent(); StarMeshFilter = Stars.GetComponent(); StarMaterial = StarRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Sun)) { SunTransform = Sun.GetComponent(); SunRenderer = Sun.GetComponent(); SunMeshFilter = Sun.GetComponent(); SunMaterial = SunRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Moon)) { MoonTransform = Moon.GetComponent(); MoonRenderer = Moon.GetComponent(); MoonMeshFilter = Moon.GetComponent(); MoonMaterial = MoonRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Atmosphere)) { AtmosphereTransform = Atmosphere.GetComponent(); AtmosphereRenderer = Atmosphere.GetComponent(); AtmosphereMeshFilter = Atmosphere.GetComponent(); AtmosphereMaterial = AtmosphereRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Clear)) { ClearTransform = Clear.GetComponent(); ClearRenderer = Clear.GetComponent(); ClearMeshFilter = Clear.GetComponent(); ClearMaterial = ClearRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Clouds)) { CloudTransform = Clouds.GetComponent(); CloudRenderer = Clouds.GetComponent(); CloudMeshFilter = Clouds.GetComponent(); CloudMaterial = CloudRenderer.sharedMaterial; } if (Object.op_Implicit((Object)(object)Billboards)) { BillboardTransform = Billboards.GetComponent(); BillboardRenderers = Billboards.GetComponentsInChildren(); BillboardMeshFilters = Billboards.GetComponentsInChildren(); BillboardMaterials = (Material[])(object)new Material[BillboardRenderers.Length]; for (int i = 0; i < BillboardRenderers.Length; i++) { BillboardMaterials[i] = BillboardRenderers[i].sharedMaterial; } } if (Object.op_Implicit((Object)(object)Light)) { LightTransform = Light.GetComponent(); LightSource = Light.GetComponent(); } } } public enum TOD_MoonPositionType { OppositeToSun, Realistic } public enum TOD_StarsPositionType { Static, Rotating } public enum TOD_FogType { None, Atmosphere, Directional, Gradient } public enum TOD_AmbientType { None, Color, Gradient, Spherical } public enum TOD_ReflectionType { None, Cubemap } public enum TOD_ColorSpaceType { Auto, Linear, Gamma } public enum TOD_ColorRangeType { Auto, HDR, LDR } public enum TOD_ColorOutputType { Raw, Dithered } public enum TOD_CloudQualityType { Low, Medium, High } public enum TOD_MeshQualityType { Low, Medium, High } public enum TOD_StarQualityType { Low, Medium, High } public enum TOD_SkyQualityType { PerVertex, PerPixel } [ExecuteInEditMode] [RequireComponent(typeof(Camera))] public abstract class TOD_ImageEffect : MonoBehaviour { public enum ResolutionType { Low, Normal, High } public TOD_Sky sky = null; protected Camera cam = null; private static Vector3[] frustumCornersArray = (Vector3[])(object)new Vector3[4]; protected Material CreateMaterial(Shader shader) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)shader)) { Debug.Log((object)("Missing shader in " + ((object)this).ToString())); ((Behaviour)this).enabled = false; return null; } if (!shader.isSupported) { Debug.LogError((object)("The shader " + ((object)shader).ToString() + " on effect " + ((object)this).ToString() + " is not supported on this platform!")); ((Behaviour)this).enabled = false; return null; } Material val = new Material(shader); ((Object)val).hideFlags = (HideFlags)52; return val; } private TOD_Sky FindSky(bool fallback = false) { if (Object.op_Implicit((Object)(object)TOD_Sky.Instance)) { return TOD_Sky.Instance; } if (fallback) { return Object.FindObjectOfType(typeof(TOD_Sky)) as TOD_Sky; } return null; } protected void Awake() { if (!Object.op_Implicit((Object)(object)cam)) { cam = ((Component)this).GetComponent(); } if (!Object.op_Implicit((Object)(object)sky)) { sky = FindSky(fallback: true); } } protected bool CheckSupport(bool needDepth = false, bool needHdr = false) { //IL_012d: 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) if (!Object.op_Implicit((Object)(object)cam)) { cam = ((Component)this).GetComponent(); } if (!Object.op_Implicit((Object)(object)cam)) { return false; } if (!Object.op_Implicit((Object)(object)sky)) { sky = FindSky(); } if (!Object.op_Implicit((Object)(object)sky) || !sky.Initialized) { return false; } if (!SystemInfo.supportsImageEffects) { Debug.LogWarning((object)("The image effect " + ((object)this).ToString() + " has been disabled as it's not supported on the current platform.")); ((Behaviour)this).enabled = false; return false; } if (needDepth && !SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)1)) { Debug.LogWarning((object)("The image effect " + ((object)this).ToString() + " has been disabled as it requires a depth texture.")); ((Behaviour)this).enabled = false; return false; } if (needHdr && !SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)2)) { Debug.LogWarning((object)("The image effect " + ((object)this).ToString() + " has been disabled as it requires HDR.")); ((Behaviour)this).enabled = false; return false; } if (needDepth) { Camera obj = cam; obj.depthTextureMode = (DepthTextureMode)(obj.depthTextureMode | 1); } if (needHdr) { cam.allowHDR = true; } return true; } protected void DrawBorder(RenderTexture dest, Material material) { RenderTexture.active = dest; bool flag = true; GL.PushMatrix(); GL.LoadOrtho(); for (int i = 0; i < material.passCount; i++) { material.SetPass(i); float num; float num2; if (flag) { num = 1f; num2 = 0f; } else { num = 0f; num2 = 1f; } float num3 = 0f; float num4 = 1f / ((float)((Texture)dest).width * 1f); float num5 = 0f; float num6 = 1f; GL.Begin(7); GL.TexCoord2(0f, num); GL.Vertex3(num3, num5, 0.1f); GL.TexCoord2(1f, num); GL.Vertex3(num4, num5, 0.1f); GL.TexCoord2(1f, num2); GL.Vertex3(num4, num6, 0.1f); GL.TexCoord2(0f, num2); GL.Vertex3(num3, num6, 0.1f); num3 = 1f - 1f / ((float)((Texture)dest).width * 1f); num4 = 1f; num5 = 0f; num6 = 1f; GL.TexCoord2(0f, num); GL.Vertex3(num3, num5, 0.1f); GL.TexCoord2(1f, num); GL.Vertex3(num4, num5, 0.1f); GL.TexCoord2(1f, num2); GL.Vertex3(num4, num6, 0.1f); GL.TexCoord2(0f, num2); GL.Vertex3(num3, num6, 0.1f); num3 = 0f; num4 = 1f; num5 = 0f; num6 = 1f / ((float)((Texture)dest).height * 1f); GL.TexCoord2(0f, num); GL.Vertex3(num3, num5, 0.1f); GL.TexCoord2(1f, num); GL.Vertex3(num4, num5, 0.1f); GL.TexCoord2(1f, num2); GL.Vertex3(num4, num6, 0.1f); GL.TexCoord2(0f, num2); GL.Vertex3(num3, num6, 0.1f); num3 = 0f; num4 = 1f; num5 = 1f - 1f / ((float)((Texture)dest).height * 1f); num6 = 1f; GL.TexCoord2(0f, num); GL.Vertex3(num3, num5, 0.1f); GL.TexCoord2(1f, num); GL.Vertex3(num4, num5, 0.1f); GL.TexCoord2(1f, num2); GL.Vertex3(num4, num6, 0.1f); GL.TexCoord2(0f, num2); GL.Vertex3(num3, num6, 0.1f); GL.End(); } GL.PopMatrix(); } protected Matrix4x4 FrustumCorners() { //IL_001b: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00ce: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) cam.CalculateFrustumCorners(new Rect(0f, 0f, 1f, 1f), cam.farClipPlane, cam.stereoActiveEye, frustumCornersArray); Vector3 val = ((Component)cam).transform.TransformVector(frustumCornersArray[0]); Vector3 val2 = ((Component)cam).transform.TransformVector(frustumCornersArray[1]); Vector3 val3 = ((Component)cam).transform.TransformVector(frustumCornersArray[2]); Vector3 val4 = ((Component)cam).transform.TransformVector(frustumCornersArray[3]); Matrix4x4 identity = Matrix4x4.identity; ((Matrix4x4)(ref identity)).SetRow(0, Vector4.op_Implicit(val)); ((Matrix4x4)(ref identity)).SetRow(1, Vector4.op_Implicit(val4)); ((Matrix4x4)(ref identity)).SetRow(2, Vector4.op_Implicit(val2)); ((Matrix4x4)(ref identity)).SetRow(3, Vector4.op_Implicit(val3)); return identity; } protected RenderTexture GetSkyMask(RenderTexture source, Material skyMaskMaterial, Material screenClearMaterial, ResolutionType resolution, Vector3 lightPos, int blurIterations, float blurRadius, float maxRadius) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Invalid comparison between Unknown and I4 //IL_011e: 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) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) int num; int num2; int num3; switch (resolution) { case ResolutionType.High: num = ((Texture)source).width; num2 = ((Texture)source).height; num3 = 0; break; case ResolutionType.Normal: num = ((Texture)source).width / 2; num2 = ((Texture)source).height / 2; num3 = 0; break; default: num = ((Texture)source).width / 4; num2 = ((Texture)source).height / 4; num3 = 0; break; } RenderTexture temporary = RenderTexture.GetTemporary(num, num2, num3); RenderTexture val = null; skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(1f, 1f, 0f, 0f) * blurRadius); skyMaskMaterial.SetVector("_LightPosition", new Vector4(lightPos.x, lightPos.y, lightPos.z, maxRadius)); if ((cam.depthTextureMode & 1) != 0) { Graphics.Blit((Texture)(object)source, temporary, skyMaskMaterial, 1); } else { Graphics.Blit((Texture)(object)source, temporary, skyMaskMaterial, 2); } if ((int)cam.stereoActiveEye == 2) { DrawBorder(temporary, screenClearMaterial); } float num4 = blurRadius * 0.0013020834f; skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num4, num4, 0f, 0f)); skyMaskMaterial.SetVector("_LightPosition", new Vector4(lightPos.x, lightPos.y, lightPos.z, maxRadius)); for (int i = 0; i < blurIterations; i++) { val = RenderTexture.GetTemporary(num, num2, num3); Graphics.Blit((Texture)(object)temporary, val, skyMaskMaterial, 0); RenderTexture.ReleaseTemporary(temporary); num4 = blurRadius * (((float)i * 2f + 1f) * 6f) / 768f; skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num4, num4, 0f, 0f)); temporary = RenderTexture.GetTemporary(num, num2, num3); Graphics.Blit((Texture)(object)val, temporary, skyMaskMaterial, 0); RenderTexture.ReleaseTemporary(val); num4 = blurRadius * (((float)i * 2f + 2f) * 6f) / 768f; skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num4, num4, 0f, 0f)); } return temporary; } } [Serializable] public class TOD_Parameters { public TOD_CycleParameters Cycle; public TOD_WorldParameters World; public TOD_AtmosphereParameters Atmosphere; public TOD_DayParameters Day; public TOD_NightParameters Night; public TOD_SunParameters Sun; public TOD_MoonParameters Moon; public TOD_LightParameters Light; public TOD_StarParameters Stars; public TOD_CloudParameters Clouds; public TOD_FogParameters Fog; public TOD_AmbientParameters Ambient; public TOD_ReflectionParameters Reflection; public TOD_Parameters() { } public TOD_Parameters(TOD_Sky sky) { Cycle = sky.Cycle; World = sky.World; Atmosphere = sky.Atmosphere; Day = sky.Day; Night = sky.Night; Sun = sky.Sun; Moon = sky.Moon; Light = sky.Light; Stars = sky.Stars; Clouds = sky.Clouds; Fog = sky.Fog; Ambient = sky.Ambient; Reflection = sky.Reflection; } public void ToSky(TOD_Sky sky) { sky.Cycle = Cycle; sky.World = World; sky.Atmosphere = Atmosphere; sky.Day = Day; sky.Night = Night; sky.Sun = Sun; sky.Moon = Moon; sky.Light = Light; sky.Stars = Stars; sky.Clouds = Clouds; sky.Fog = Fog; sky.Ambient = Ambient; sky.Reflection = Reflection; } } [Serializable] public class TOD_CycleParameters { [Tooltip("Current hour of the day.")] public float Hour = 12f; [Tooltip("Current day of the month.")] public int Day = 15; [Tooltip("Current month of the year.")] public int Month = 6; [Tooltip("Current year.")] [TOD_Range(1f, 9999f)] public int Year = 2000; public DateTime DateTime { get { DateTime result = new DateTime(0L, DateTimeKind.Utc); if (Year > 0) { result = result.AddYears(Year - 1); } if (Month > 0) { result = result.AddMonths(Month - 1); } if (Day > 0) { result = result.AddDays(Day - 1); } if (Hour > 0f) { result = result.AddHours(Hour); } return result; } set { Year = value.Year; Month = value.Month; Day = value.Day; Hour = (float)value.Hour + (float)value.Minute / 60f + (float)value.Second / 3600f + (float)value.Millisecond / 3600000f; } } public long Ticks { get { return DateTime.Ticks; } set { DateTime = new DateTime(value, DateTimeKind.Utc); } } } [Serializable] public class TOD_WorldParameters { [Tooltip("Latitude of the current location in degrees.")] [Range(-90f, 90f)] public float Latitude = 0f; [Tooltip("Longitude of the current location in degrees.")] [Range(-180f, 180f)] public float Longitude = 0f; [Tooltip("UTC/GMT time zone of the current location in hours.")] [Range(-14f, 14f)] public float UTC = 0f; } [Serializable] public class TOD_AtmosphereParameters { [Tooltip("Intensity of the atmospheric Rayleigh scattering.")] [TOD_Min(0f)] public float RayleighMultiplier = 1f; [Tooltip("Intensity of the atmospheric Mie scattering.")] [TOD_Min(0f)] public float MieMultiplier = 1f; [Tooltip("Overall brightness of the atmosphere.")] [TOD_Min(0f)] public float Brightness = 1.5f; [Tooltip("Overall contrast of the atmosphere.")] [TOD_Min(0f)] public float Contrast = 1.5f; [Tooltip("Directionality factor that determines the size of the glow around the sun.")] [TOD_Range(0f, 1f)] public float Directionality = 0.7f; [Tooltip("Density of the fog covering the sky.")] [TOD_Range(0f, 1f)] public float Fogginess = 0f; } [Serializable] public class TOD_DayParameters { [Tooltip("Color of the sun spot.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient SunColor = null; [Tooltip("Color of the light that hits the ground.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient LightColor = null; [Tooltip("Color of the god rays.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient RayColor = null; [Tooltip("Color of the light that hits the atmosphere.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient SkyColor = null; [Tooltip("Color of the clouds.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient CloudColor = null; [Tooltip("Color of the atmosphere fog.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient FogColor = null; [Tooltip("Color of the ambient light.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")] public Gradient AmbientColor = null; [Tooltip("Intensity of the light source.")] [Range(0f, 8f)] public float LightIntensity = 1f; [Tooltip("Opacity of the shadows dropped by the light source.")] [Range(0f, 1f)] public float ShadowStrength = 1f; [Tooltip("Brightness multiplier of the ambient light.")] [Range(0f, 8f)] public float AmbientMultiplier = 1f; [Tooltip("Brightness multiplier of the reflection probe.")] [Range(0f, 1f)] public float ReflectionMultiplier = 1f; } [Serializable] public class TOD_NightParameters { [Tooltip("Color of the moon mesh.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient MoonColor = null; [Tooltip("Color of the light that hits the ground.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient LightColor = null; [Tooltip("Color of the god rays.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient RayColor = null; [Tooltip("Color of the light that hits the atmosphere.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient SkyColor = null; [Tooltip("Color of the clouds.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient CloudColor = null; [Tooltip("Color of the atmosphere fog.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient FogColor = null; [Tooltip("Color of the ambient light.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")] public Gradient AmbientColor = null; [Tooltip("Intensity of the light source.")] [Range(0f, 8f)] public float LightIntensity = 0.1f; [Tooltip("Opacity of the shadows dropped by the light source.")] [Range(0f, 1f)] public float ShadowStrength = 1f; [Tooltip("Brightness multiplier of the ambient light.")] [Range(0f, 8f)] public float AmbientMultiplier = 1f; [Tooltip("Brightness multiplier of the reflection probe.")] [Range(0f, 1f)] public float ReflectionMultiplier = 1f; } [Serializable] public class TOD_SunParameters { [Tooltip("Diameter of the sun in degrees.\nThe diameter as seen from earth is 0.5 degrees.")] [TOD_Min(0f)] public float MeshSize = 1f; [Tooltip("Brightness of the sun.")] [TOD_Min(0f)] public float MeshBrightness = 2f; [Tooltip("Contrast of the sun.")] [TOD_Min(0f)] public float MeshContrast = 1f; } [Serializable] public class TOD_MoonParameters { [Tooltip("Diameter of the moon in degrees.\nThe diameter as seen from earth is 0.5 degrees.")] [TOD_Min(0f)] public float MeshSize = 1f; [Tooltip("Brightness of the moon.")] [TOD_Min(0f)] public float MeshBrightness = 2f; [Tooltip("Contrast of the moon.")] [TOD_Min(0f)] public float MeshContrast = 1f; [Tooltip("Size of the moon halo.")] [TOD_Min(0f)] public float HaloSize = 0.1f; [Tooltip("Brightness of the moon halo.")] [TOD_Min(0f)] public float HaloBrightness = 1f; [Tooltip("Type of the moon position calculation.")] public TOD_MoonPositionType Position = TOD_MoonPositionType.Realistic; } [Serializable] public class TOD_StarParameters { [Tooltip("Size of the stars.")] [TOD_Min(0f)] public float Size = 1f; [Tooltip("Brightness of the stars.")] [TOD_Min(0f)] public float Brightness = 1f; [Tooltip("Type of the stars position calculation.")] public TOD_StarsPositionType Position = TOD_StarsPositionType.Rotating; } [Serializable] public class TOD_CloudParameters { [Tooltip("Size of the clouds.")] [TOD_Min(1f)] public float Size = 2f; [Tooltip("Opacity of the clouds.")] [TOD_Range(0f, 1f)] public float Opacity = 1f; [Tooltip("How much sky is covered by clouds.")] [TOD_Range(0f, 1f)] public float Coverage = 0.5f; [Tooltip("Sharpness of the cloud to sky transition.")] [TOD_Range(0f, 1f)] public float Sharpness = 0.5f; [Tooltip("Coloring of the clouds.")] [TOD_Range(0f, 1f)] public float Coloring = 0.5f; [Tooltip("Amount of skylight that is blocked.")] [TOD_Range(0f, 1f)] public float Attenuation = 0.5f; [Tooltip("Amount of sunlight that is blocked.\nOnly affects the highest cloud quality setting.")] [TOD_Range(0f, 1f)] public float Saturation = 0.5f; [Tooltip("Intensity of the cloud translucency glow.\nOnly affects the highest cloud quality setting.")] [TOD_Min(0f)] public float Scattering = 1f; [Tooltip("Brightness of the clouds.")] [TOD_Min(0f)] public float Brightness = 1.5f; } [Serializable] public class TOD_LightParameters { [Tooltip("Refresh interval of the light source position in seconds.")] [TOD_Min(0f)] public float UpdateInterval = 0f; [Tooltip("Controls how low the light source is allowed to go.\n = -1 light source can go as low as it wants.\n = 0 light source will never go below the horizon.\n = +1 light source will never leave zenith.")] [TOD_Range(-1f, 1f)] public float MinimumHeight = 0f; } [Serializable] public class TOD_FogParameters { [Tooltip("Fog color mode.")] public TOD_FogType Mode = TOD_FogType.Atmosphere; [Tooltip("Fog color sampling height.\n = 0 fog is atmosphere color at horizon.\n = 1 fog is atmosphere color at zenith.")] [TOD_Range(0f, 1f)] public float HeightBias = 0f; } [Serializable] public class TOD_AmbientParameters { [Tooltip("Ambient light mode.")] public TOD_AmbientType Mode = TOD_AmbientType.Color; [Tooltip("Saturation of the ambient light.")] [TOD_Min(0f)] public float Saturation = 1f; [Tooltip("Refresh interval of the ambient light probe in seconds.")] [TOD_Min(0f)] public float UpdateInterval = 1f; } [Serializable] public class TOD_ReflectionParameters { [Tooltip("Reflection probe mode.")] public TOD_ReflectionType Mode = TOD_ReflectionType.None; [Tooltip("Clear flags to use for the reflection.")] public ReflectionProbeClearFlags ClearFlags = (ReflectionProbeClearFlags)1; [Tooltip("Layers to include in the reflection.")] public LayerMask CullingMask = LayerMask.op_Implicit(0); [Tooltip("Time slicing behaviour to spread out rendering cost over multiple frames.")] public ReflectionProbeTimeSlicingMode TimeSlicing = (ReflectionProbeTimeSlicingMode)0; [Tooltip("Resolution of the reflection bake.")] [TOD_Range(16f, 2048f)] public int Resolution = 128; [Tooltip("Refresh interval of the reflection cubemap in seconds.")] [TOD_Min(0f)] public float UpdateInterval = 1f; } [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu("Time of Day/Camera God Rays")] public class TOD_Rays : TOD_ImageEffect { public enum BlendModeType { Screen, Add } public Shader GodRayShader = null; public Shader ScreenClearShader = null; public Shader SkyMaskShader = null; [Tooltip("Whether or not to use the depth buffer.")] public bool UseDepthTexture = true; [Header("Rays")] [Tooltip("The god ray rendering blend mode.")] public BlendModeType BlendMode = BlendModeType.Screen; [Tooltip("The intensity of the god rays.")] [TOD_Min(0f)] public float Intensity = 1f; [Header("Blur")] [Tooltip("The god ray rendering resolution.")] public ResolutionType Resolution = ResolutionType.Normal; [Tooltip("The number of blur iterations to be performed.")] [TOD_Range(0f, 4f)] public int BlurIterations = 2; [Tooltip("The radius to blur filter applied to the god rays.")] [TOD_Min(0f)] public float BlurRadius = 2f; [Tooltip("The maximum radius of the god rays.")] [TOD_Min(0f)] public float MaxRadius = 0.5f; private Material godRayMaterial = null; private Material screenClearMaterial = null; private Material skyMaskMaterial = null; private const int PASS_SCREEN = 0; private const int PASS_ADD = 1; protected void OnEnable() { if (!Object.op_Implicit((Object)(object)GodRayShader)) { GodRayShader = Shader.Find("Hidden/Time of Day/God Rays"); } if (!Object.op_Implicit((Object)(object)ScreenClearShader)) { ScreenClearShader = Shader.Find("Hidden/Time of Day/Screen Clear"); } if (!Object.op_Implicit((Object)(object)SkyMaskShader)) { SkyMaskShader = Shader.Find("Hidden/Time of Day/Sky Mask"); } godRayMaterial = CreateMaterial(GodRayShader); screenClearMaterial = CreateMaterial(ScreenClearShader); skyMaskMaterial = CreateMaterial(SkyMaskShader); } protected void OnDisable() { if (Object.op_Implicit((Object)(object)godRayMaterial)) { Object.DestroyImmediate((Object)(object)godRayMaterial); } if (Object.op_Implicit((Object)(object)screenClearMaterial)) { Object.DestroyImmediate((Object)(object)screenClearMaterial); } if (Object.op_Implicit((Object)(object)skyMaskMaterial)) { Object.DestroyImmediate((Object)(object)skyMaskMaterial); } } protected void OnRenderImage(RenderTexture source, RenderTexture destination) { //IL_0047: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //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_0108: 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_00f5: 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_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_00d0: Unknown result type (might be due to invalid IL or missing references) if (!CheckSupport(UseDepthTexture)) { Graphics.Blit((Texture)(object)source, destination); return; } sky.Components.Rays = this; Vector3 lightPos = cam.WorldToViewportPoint(sky.Components.LightTransform.position); RenderTexture skyMask = GetSkyMask(source, skyMaskMaterial, screenClearMaterial, Resolution, lightPos, BlurIterations, BlurRadius, MaxRadius); Color val = Color.black; if ((double)lightPos.z >= 0.0) { val = ((!sky.IsDay) ? (Intensity * sky.MoonVisibility * sky.MoonRayColor) : (Intensity * sky.SunVisibility * sky.SunRayColor)); } godRayMaterial.SetColor("_LightColor", val); godRayMaterial.SetTexture("_SkyMask", (Texture)(object)skyMask); if (BlendMode == BlendModeType.Screen) { Graphics.Blit((Texture)(object)source, destination, godRayMaterial, 0); } else { Graphics.Blit((Texture)(object)source, destination, godRayMaterial, 1); } RenderTexture.ReleaseTemporary(skyMask); } } public class TOD_Resources : MonoBehaviour { public Material Skybox; public Mesh MoonLOD0; public Mesh MoonLOD1; public Mesh MoonLOD2; public Mesh SkyLOD0; public Mesh SkyLOD1; public Mesh SkyLOD2; public Mesh CloudsLOD0; public Mesh CloudsLOD1; public Mesh CloudsLOD2; public Mesh StarsLOD0; public Mesh StarsLOD1; public Mesh StarsLOD2; public int ID_SunLightColor { get; private set; } public int ID_MoonLightColor { get; private set; } public int ID_SunSkyColor { get; private set; } public int ID_MoonSkyColor { get; private set; } public int ID_SunMeshColor { get; private set; } public int ID_MoonMeshColor { get; private set; } public int ID_SunCloudColor { get; private set; } public int ID_MoonCloudColor { get; private set; } public int ID_FogColor { get; private set; } public int ID_GroundColor { get; private set; } public int ID_AmbientColor { get; private set; } public int ID_SunDirection { get; private set; } public int ID_MoonDirection { get; private set; } public int ID_LightDirection { get; private set; } public int ID_LocalSunDirection { get; private set; } public int ID_LocalMoonDirection { get; private set; } public int ID_LocalLightDirection { get; private set; } public int ID_Contrast { get; private set; } public int ID_Brightness { get; private set; } public int ID_Fogginess { get; private set; } public int ID_Directionality { get; private set; } public int ID_MoonHaloPower { get; private set; } public int ID_MoonHaloColor { get; private set; } public int ID_CloudSize { get; private set; } public int ID_CloudOpacity { get; private set; } public int ID_CloudCoverage { get; private set; } public int ID_CloudSharpness { get; private set; } public int ID_CloudDensity { get; private set; } public int ID_CloudColoring { get; private set; } public int ID_CloudAttenuation { get; private set; } public int ID_CloudSaturation { get; private set; } public int ID_CloudScattering { get; private set; } public int ID_CloudBrightness { get; private set; } public int ID_CloudMultiplier { get; private set; } public int ID_CloudOffset { get; private set; } public int ID_CloudWind { get; private set; } public int ID_StarSize { get; private set; } public int ID_StarBrightness { get; private set; } public int ID_StarVisibility { get; private set; } public int ID_SunMeshContrast { get; private set; } public int ID_SunMeshBrightness { get; private set; } public int ID_MoonMeshContrast { get; private set; } public int ID_MoonMeshBrightness { get; private set; } public int ID_kBetaMie { get; private set; } public int ID_kSun { get; private set; } public int ID_k4PI { get; private set; } public int ID_kRadius { get; private set; } public int ID_kScale { get; private set; } public int ID_World2Sky { get; private set; } public int ID_Sky2World { get; private set; } public void Initialize() { ID_SunLightColor = Shader.PropertyToID("TOD_SunLightColor"); ID_MoonLightColor = Shader.PropertyToID("TOD_MoonLightColor"); ID_SunSkyColor = Shader.PropertyToID("TOD_SunSkyColor"); ID_MoonSkyColor = Shader.PropertyToID("TOD_MoonSkyColor"); ID_SunMeshColor = Shader.PropertyToID("TOD_SunMeshColor"); ID_MoonMeshColor = Shader.PropertyToID("TOD_MoonMeshColor"); ID_SunCloudColor = Shader.PropertyToID("TOD_SunCloudColor"); ID_MoonCloudColor = Shader.PropertyToID("TOD_MoonCloudColor"); ID_FogColor = Shader.PropertyToID("TOD_FogColor"); ID_GroundColor = Shader.PropertyToID("TOD_GroundColor"); ID_AmbientColor = Shader.PropertyToID("TOD_AmbientColor"); ID_SunDirection = Shader.PropertyToID("TOD_SunDirection"); ID_MoonDirection = Shader.PropertyToID("TOD_MoonDirection"); ID_LightDirection = Shader.PropertyToID("TOD_LightDirection"); ID_LocalSunDirection = Shader.PropertyToID("TOD_LocalSunDirection"); ID_LocalMoonDirection = Shader.PropertyToID("TOD_LocalMoonDirection"); ID_LocalLightDirection = Shader.PropertyToID("TOD_LocalLightDirection"); ID_Contrast = Shader.PropertyToID("TOD_Contrast"); ID_Brightness = Shader.PropertyToID("TOD_Brightness"); ID_Fogginess = Shader.PropertyToID("TOD_Fogginess"); ID_Directionality = Shader.PropertyToID("TOD_Directionality"); ID_MoonHaloPower = Shader.PropertyToID("TOD_MoonHaloPower"); ID_MoonHaloColor = Shader.PropertyToID("TOD_MoonHaloColor"); ID_CloudSize = Shader.PropertyToID("TOD_CloudSize"); ID_CloudOpacity = Shader.PropertyToID("TOD_CloudOpacity"); ID_CloudCoverage = Shader.PropertyToID("TOD_CloudCoverage"); ID_CloudSharpness = Shader.PropertyToID("TOD_CloudSharpness"); ID_CloudDensity = Shader.PropertyToID("TOD_CloudDensity"); ID_CloudColoring = Shader.PropertyToID("TOD_CloudColoring"); ID_CloudAttenuation = Shader.PropertyToID("TOD_CloudAttenuation"); ID_CloudSaturation = Shader.PropertyToID("TOD_CloudSaturation"); ID_CloudScattering = Shader.PropertyToID("TOD_CloudScattering"); ID_CloudBrightness = Shader.PropertyToID("TOD_CloudBrightness"); ID_CloudOffset = Shader.PropertyToID("TOD_CloudOffset"); ID_CloudWind = Shader.PropertyToID("TOD_CloudWind"); ID_StarSize = Shader.PropertyToID("TOD_StarSize"); ID_StarBrightness = Shader.PropertyToID("TOD_StarBrightness"); ID_StarVisibility = Shader.PropertyToID("TOD_StarVisibility"); ID_SunMeshContrast = Shader.PropertyToID("TOD_SunMeshContrast"); ID_SunMeshBrightness = Shader.PropertyToID("TOD_SunMeshBrightness"); ID_MoonMeshContrast = Shader.PropertyToID("TOD_MoonMeshContrast"); ID_MoonMeshBrightness = Shader.PropertyToID("TOD_MoonMeshBrightness"); ID_kBetaMie = Shader.PropertyToID("TOD_kBetaMie"); ID_kSun = Shader.PropertyToID("TOD_kSun"); ID_k4PI = Shader.PropertyToID("TOD_k4PI"); ID_kRadius = Shader.PropertyToID("TOD_kRadius"); ID_kScale = Shader.PropertyToID("TOD_kScale"); ID_World2Sky = Shader.PropertyToID("TOD_World2Sky"); ID_Sky2World = Shader.PropertyToID("TOD_Sky2World"); } } [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu("Time of Day/Camera Atmospheric Scattering")] public class TOD_Scattering : TOD_ImageEffect { public Shader ScatteringShader = null; public Shader ScreenClearShader = null; public Shader SkyMaskShader = null; public Texture2D DitheringTexture = null; [Tooltip("Whether to render atmosphere and fog in a single pass or two separate passes. Disable when using anti-aliasing in forward rendering or when your manual reflection scripts need the sky dome to be present before the image effects are rendered.")] public bool SinglePass = true; [Header("Fog")] [Tooltip("How quickly the fog thickens with increasing distance.")] [Range(0f, 1f)] public float GlobalDensity = 0.01f; [Tooltip("How quickly the fog falls off with increasing altitude.")] [Range(0f, 1f)] public float HeightFalloff = 0.01f; [Tooltip("The distance the fog starts at.")] public float StartDistance = 0f; [Tooltip("The height where the fog reaches its maximum density.")] public float ZeroLevel = 0f; [Header("Blur")] [Tooltip("The scattering resolution.")] public ResolutionType Resolution = ResolutionType.Normal; [Tooltip("The number of blur iterations to be performed.")] [TOD_Range(0f, 4f)] public int BlurIterations = 2; [Tooltip("The radius to blur filter applied to the directional scattering.")] [TOD_Min(0f)] public float BlurRadius = 2f; [Tooltip("The maximum radius of the directional scattering.")] [TOD_Min(0f)] public float MaxRadius = 1f; private Material scatteringMaterial = null; private Material screenClearMaterial = null; private Material skyMaskMaterial = null; protected void OnEnable() { if (!Object.op_Implicit((Object)(object)ScatteringShader)) { ScatteringShader = Shader.Find("Hidden/Time of Day/Scattering"); } if (!Object.op_Implicit((Object)(object)ScreenClearShader)) { ScreenClearShader = Shader.Find("Hidden/Time of Day/Screen Clear"); } if (!Object.op_Implicit((Object)(object)SkyMaskShader)) { SkyMaskShader = Shader.Find("Hidden/Time of Day/Sky Mask"); } scatteringMaterial = CreateMaterial(ScatteringShader); screenClearMaterial = CreateMaterial(ScreenClearShader); skyMaskMaterial = CreateMaterial(SkyMaskShader); } protected void OnDisable() { if (Object.op_Implicit((Object)(object)scatteringMaterial)) { Object.DestroyImmediate((Object)(object)scatteringMaterial); } if (Object.op_Implicit((Object)(object)screenClearMaterial)) { Object.DestroyImmediate((Object)(object)screenClearMaterial); } if (Object.op_Implicit((Object)(object)skyMaskMaterial)) { Object.DestroyImmediate((Object)(object)skyMaskMaterial); } } protected void OnPreCull() { if (SinglePass && Object.op_Implicit((Object)(object)sky) && sky.Initialized) { sky.Components.AtmosphereRenderer.enabled = false; } } protected void OnPostRender() { if (SinglePass && Object.op_Implicit((Object)(object)sky) && sky.Initialized) { sky.Components.AtmosphereRenderer.enabled = true; } } [ImageEffectOpaque] protected void OnRenderImage(RenderTexture source, RenderTexture destination) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) if (!CheckSupport(needDepth: true)) { Graphics.Blit((Texture)(object)source, destination); return; } sky.Components.Scattering = this; Vector3 lightPos = cam.WorldToViewportPoint(sky.Components.SunTransform.position); RenderTexture skyMask = GetSkyMask(source, skyMaskMaterial, screenClearMaterial, Resolution, lightPos, BlurIterations, BlurRadius, MaxRadius); scatteringMaterial.SetMatrix("_FrustumCornersWS", FrustumCorners()); scatteringMaterial.SetTexture("_SkyMask", (Texture)(object)skyMask); if (SinglePass) { scatteringMaterial.EnableKeyword("TOD_SCATTERING_SINGLE_PASS"); } else { scatteringMaterial.DisableKeyword("TOD_SCATTERING_SINGLE_PASS"); } Shader.SetGlobalTexture("TOD_BayerTexture", (Texture)(object)DitheringTexture); Shader.SetGlobalVector("TOD_ScatterDensity", new Vector4(HeightFalloff, ZeroLevel, GlobalDensity, StartDistance)); Graphics.Blit((Texture)(object)source, destination, scatteringMaterial); RenderTexture.ReleaseTemporary(skyMask); } } [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu("Time of Day/Camera Cloud Shadows")] public class TOD_Shadows : TOD_ImageEffect { public Shader ShadowShader = null; public Texture2D CloudTexture = null; [Header("Shadows")] [Range(0f, 1f)] public float Cutoff = 0f; [Range(0f, 1f)] public float Fade = 0f; [Range(0f, 1f)] public float Intensity = 0.5f; private Material shadowMaterial = null; protected void OnEnable() { if (!Object.op_Implicit((Object)(object)ShadowShader)) { ShadowShader = Shader.Find("Hidden/Time of Day/Cloud Shadows"); } shadowMaterial = CreateMaterial(ShadowShader); } protected void OnDisable() { if (Object.op_Implicit((Object)(object)shadowMaterial)) { Object.DestroyImmediate((Object)(object)shadowMaterial); } } [ImageEffectOpaque] protected void OnRenderImage(RenderTexture source, RenderTexture destination) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!CheckSupport(needDepth: true)) { Graphics.Blit((Texture)(object)source, destination); return; } sky.Components.Shadows = this; shadowMaterial.SetMatrix("_FrustumCornersWS", FrustumCorners()); Shader.SetGlobalTexture("TOD_CloudTexture", (Texture)(object)CloudTexture); Shader.SetGlobalFloat("TOD_CloudShadowCutoff", Cutoff); Shader.SetGlobalFloat("TOD_CloudShadowFade", Fade); Shader.SetGlobalFloat("TOD_CloudShadowIntensity", Intensity * Mathf.Clamp01(1f - sky.SunZenith / 90f)); Graphics.Blit((Texture)(object)source, destination, shadowMaterial); } } [ExecuteInEditMode] [RequireComponent(typeof(TOD_Resources))] [RequireComponent(typeof(TOD_Components))] public class TOD_Sky : MonoBehaviour { private static List instances = new List(); private int probeRenderID = -1; [Tooltip("Auto: Use the player settings.\nLinear: Force linear color space.\nGamma: Force gamma color space.")] public TOD_ColorSpaceType ColorSpace = TOD_ColorSpaceType.Auto; [Tooltip("Auto: Use the camera settings.\nHDR: Force high dynamic range.\nLDR: Force low dynamic range.")] public TOD_ColorRangeType ColorRange = TOD_ColorRangeType.Auto; [Tooltip("Raw: Write color without modifications.\nDithered: Add dithering to reduce banding.")] public TOD_ColorOutputType ColorOutput = TOD_ColorOutputType.Dithered; [Tooltip("Per Vertex: Calculate sky color per vertex.\nPer Pixel: Calculate sky color per pixel.")] public TOD_SkyQualityType SkyQuality = TOD_SkyQualityType.PerVertex; [Tooltip("Low: Only recommended for very old mobile devices.\nMedium: Simplified cloud shading.\nHigh: Physically based cloud shading.")] public TOD_CloudQualityType CloudQuality = TOD_CloudQualityType.High; [Tooltip("Low: Only recommended for very old mobile devices.\nMedium: Simplified mesh geometry.\nHigh: Detailed mesh geometry.")] public TOD_MeshQualityType MeshQuality = TOD_MeshQualityType.High; [Tooltip("Low: Recommended for most mobile devices.\nMedium: Includes most visible stars.\nHigh: Includes all visible stars.")] public TOD_StarQualityType StarQuality = TOD_StarQualityType.High; public TOD_CycleParameters Cycle; public TOD_WorldParameters World; public TOD_AtmosphereParameters Atmosphere; public TOD_DayParameters Day; public TOD_NightParameters Night; public TOD_SunParameters Sun; public TOD_MoonParameters Moon; public TOD_StarParameters Stars; public TOD_CloudParameters Clouds; public TOD_LightParameters Light; public TOD_FogParameters Fog; public TOD_AmbientParameters Ambient; public TOD_ReflectionParameters Reflection; private float timeSinceLightUpdate = float.MaxValue; private float timeSinceAmbientUpdate = float.MaxValue; private float timeSinceReflectionUpdate = float.MaxValue; private const int TOD_SAMPLES = 2; private Vector3 kBetaMie; private Vector4 kSun; private Vector4 k4PI; private Vector4 kRadius; private Vector4 kScale; private const float pi = (float)Math.PI; private const float tau = (float)Math.PI * 2f; public static List Instances => instances; public static TOD_Sky Instance => (instances.Count != 0) ? instances[instances.Count - 1] : null; public bool Initialized { get; private set; } public bool Headless => false; public TOD_Components Components { get; private set; } public TOD_Resources Resources { get; private set; } public bool IsDay { get; private set; } public bool IsNight { get; private set; } public float Radius => Components.DomeTransform.lossyScale.y; public float Diameter => Components.DomeTransform.lossyScale.y * 2f; public float LerpValue { get; private set; } public float SunZenith { get; private set; } public float SunAltitude { get; private set; } public float SunAzimuth { get; private set; } public float MoonZenith { get; private set; } public float MoonAltitude { get; private set; } public float MoonAzimuth { get; private set; } public float SunsetTime { get; private set; } public float SunriseTime { get; private set; } public float LocalSiderealTime { get; private set; } public float LightZenith => Mathf.Min(SunZenith, MoonZenith); public float LightIntensity => Components.LightSource.intensity; public float SunVisibility { get; private set; } public float MoonVisibility { get; private set; } public Vector3 SunDirection { get; private set; } public Vector3 MoonDirection { get; private set; } public Vector3 LightDirection { get; private set; } public Vector3 LocalSunDirection { get; private set; } public Vector3 LocalMoonDirection { get; private set; } public Vector3 LocalLightDirection { get; private set; } public Color SunLightColor { get; private set; } public Color MoonLightColor { get; private set; } public Color LightColor => Components.LightSource.color; public Color SunRayColor { get; private set; } public Color MoonRayColor { get; private set; } public Color SunSkyColor { get; private set; } public Color MoonSkyColor { get; private set; } public Color SunMeshColor { get; private set; } public Color MoonMeshColor { get; private set; } public Color SunCloudColor { get; private set; } public Color MoonCloudColor { get; private set; } public Color FogColor { get; private set; } public Color GroundColor { get; private set; } public Color AmbientColor { get; private set; } public Color MoonHaloColor { get; private set; } public ReflectionProbe Probe { get; private set; } public Vector3 OrbitalToUnity(float radius, float theta, float phi) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sin(theta); float num2 = Mathf.Cos(theta); float num3 = Mathf.Sin(phi); float num4 = Mathf.Cos(phi); Vector3 result = default(Vector3); result.z = radius * num * num4; result.y = radius * num2; result.x = radius * num * num3; return result; } public Vector3 OrbitalToLocal(float theta, float phi) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sin(theta); float y = Mathf.Cos(theta); float num2 = Mathf.Sin(phi); float num3 = Mathf.Cos(phi); Vector3 result = default(Vector3); result.z = num * num3; result.y = y; result.x = num * num2; return result; } public Color SampleAtmosphere(Vector3 direction, bool directLight = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0026: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Vector3 dir = Components.DomeTransform.InverseTransformDirection(direction); Color color = ShaderScatteringColor(dir, directLight); color = TOD_HDR2LDR(color); return TOD_LINEAR2GAMMA(color); } public SphericalHarmonicsL2 RenderToSphericalHarmonics() { //IL_0032: 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_003d: Unknown result type (might be due to invalid IL or missing references) float saturation = Ambient.Saturation; float intensity = Mathf.Lerp(Night.AmbientMultiplier, Day.AmbientMultiplier, LerpValue); return RenderToSphericalHarmonics(intensity, saturation); } public SphericalHarmonicsL2 RenderToSphericalHarmonics(float intensity, float saturation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001b: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0057: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_012b: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_018b: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0309: 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) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_034f: 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_035c: 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) SphericalHarmonicsL2 result = default(SphericalHarmonicsL2); bool directLight = false; Color ambientColor = AmbientColor; Color val = TOD_Util.AdjustRGB(((Color)(ref ambientColor)).linear, intensity, saturation); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0.61237246f, 0.5f, 0.61237246f); Vector3 up = Vector3.up; Color val3 = SampleAtmosphere(up, directLight); Color linear = ((Color)(ref val3)).linear; Color val4 = TOD_Util.AdjustRGB(linear, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(up, val4, 0.42857143f); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0f - val2.x, val2.y, 0f - val2.z); Color val6 = SampleAtmosphere(val5, directLight); Color linear2 = ((Color)(ref val6)).linear; Color val7 = TOD_Util.AdjustRGB(linear2, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val5, val7, 0.2857143f); Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(val2.x, val2.y, 0f - val2.z); Color val9 = SampleAtmosphere(val8, directLight); Color linear3 = ((Color)(ref val9)).linear; Color val10 = TOD_Util.AdjustRGB(linear3, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val8, val10, 0.2857143f); Vector3 val11 = default(Vector3); ((Vector3)(ref val11))..ctor(0f - val2.x, val2.y, val2.z); Color val12 = SampleAtmosphere(val11, directLight); Color linear4 = ((Color)(ref val12)).linear; Color val13 = TOD_Util.AdjustRGB(linear4, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val11, val13, 0.2857143f); Vector3 val14 = default(Vector3); ((Vector3)(ref val14))..ctor(val2.x, val2.y, val2.z); Color val15 = SampleAtmosphere(val14, directLight); Color linear5 = ((Color)(ref val15)).linear; Color val16 = TOD_Util.AdjustRGB(linear5, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val14, val16, 0.2857143f); Vector3 left = Vector3.left; Color val17 = SampleAtmosphere(left, directLight); Color linear6 = ((Color)(ref val17)).linear; Color val18 = TOD_Util.AdjustRGB(linear6, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(left, val18, 1f / 7f); Vector3 right = Vector3.right; Color val19 = SampleAtmosphere(right, directLight); Color linear7 = ((Color)(ref val19)).linear; Color val20 = TOD_Util.AdjustRGB(linear7, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(right, val20, 1f / 7f); Vector3 back = Vector3.back; Color val21 = SampleAtmosphere(back, directLight); Color linear8 = ((Color)(ref val21)).linear; Color val22 = TOD_Util.AdjustRGB(linear8, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(back, val22, 1f / 7f); Vector3 forward = Vector3.forward; Color val23 = SampleAtmosphere(forward, directLight); Color linear9 = ((Color)(ref val23)).linear; Color val24 = TOD_Util.AdjustRGB(linear9, intensity, saturation); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(forward, val24, 1f / 7f); Vector3 val25 = default(Vector3); ((Vector3)(ref val25))..ctor(0f - val2.x, 0f - val2.y, 0f - val2.z); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val25, val, 0.2857143f); Vector3 val26 = default(Vector3); ((Vector3)(ref val26))..ctor(val2.x, 0f - val2.y, 0f - val2.z); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val26, val, 0.2857143f); Vector3 val27 = default(Vector3); ((Vector3)(ref val27))..ctor(0f - val2.x, 0f - val2.y, val2.z); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val27, val, 0.2857143f); Vector3 val28 = default(Vector3); ((Vector3)(ref val28))..ctor(val2.x, 0f - val2.y, val2.z); ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val28, val, 0.2857143f); Vector3 down = Vector3.down; ((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(down, val, 0.42857143f); return result; } public void RenderToCubemap(RenderTexture targetTexture = null) { //IL_0013: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Probe)) { Probe = new GameObject().AddComponent(); ((Object)Probe).name = ((Object)((Component)this).gameObject).name + " Reflection Probe"; Probe.mode = (ReflectionProbeMode)1; } if (probeRenderID < 0 || Probe.IsFinishedRendering(probeRenderID)) { float num = float.MaxValue; ((Component)Probe).transform.position = Components.DomeTransform.position; Probe.size = new Vector3(num, num, num); Probe.intensity = RenderSettings.reflectionIntensity; Probe.clearFlags = Reflection.ClearFlags; Probe.cullingMask = LayerMask.op_Implicit(Reflection.CullingMask); Probe.refreshMode = (ReflectionProbeRefreshMode)2; Probe.timeSlicingMode = Reflection.TimeSlicing; Probe.resolution = Mathf.ClosestPowerOfTwo(Reflection.Resolution); if ((Object)(object)Components.Camera != (Object)null) { Probe.backgroundColor = Components.Camera.BackgroundColor; Probe.nearClipPlane = Components.Camera.NearClipPlane; Probe.farClipPlane = Components.Camera.FarClipPlane; } probeRenderID = Probe.RenderProbe(targetTexture); } } public Color SampleFogColor(bool directLight = true) { //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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) //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_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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0052: 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_00a7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.forward; if ((Object)(object)Components.Camera != (Object)null) { Quaternion rotation = ((Component)Components.Camera).transform.rotation; val = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f) * val; } Vector3 val2 = Vector3.Lerp(val, Vector3.up, Fog.HeightBias); Color val3 = SampleAtmosphere(((Vector3)(ref val2)).normalized, directLight); return new Color(val3.r, val3.g, val3.b, 1f); } public Color SampleSkyColor() { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_004f: Unknown result type (might be due to invalid IL or missing references) Vector3 sunDirection = SunDirection; sunDirection.y = Mathf.Abs(sunDirection.y); Color val = SampleAtmosphere(((Vector3)(ref sunDirection)).normalized, directLight: false); return new Color(val.r, val.g, val.b, 1f); } public Color SampleEquatorColor() { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) Vector3 sunDirection = SunDirection; sunDirection.y = 0f; Color val = SampleAtmosphere(((Vector3)(ref sunDirection)).normalized, directLight: false); return new Color(val.r, val.g, val.b, 1f); } public void UpdateFog() { //IL_002f: 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_0035: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_006b: 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) switch (Fog.Mode) { case TOD_FogType.None: break; case TOD_FogType.Atmosphere: { Color val = SampleFogColor(directLight: false); if (RenderSettings.fogColor != val) { RenderSettings.fogColor = val; } break; } case TOD_FogType.Directional: { Color val2 = SampleFogColor(); if (RenderSettings.fogColor != val2) { RenderSettings.fogColor = val2; } break; } case TOD_FogType.Gradient: if (RenderSettings.fogColor != FogColor) { RenderSettings.fogColor = FogColor; } break; } } public void UpdateAmbient() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b6: 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_00c2: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00d9: Invalid comparison between Unknown and I4 //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) float saturation = Ambient.Saturation; float num = Mathf.Lerp(Night.AmbientMultiplier, Day.AmbientMultiplier, LerpValue); switch (Ambient.Mode) { case TOD_AmbientType.Color: { Color val2 = TOD_Util.AdjustRGB(AmbientColor, num, saturation); if ((int)RenderSettings.ambientMode != 3) { RenderSettings.ambientMode = (AmbientMode)3; } if (RenderSettings.ambientLight != val2) { RenderSettings.ambientLight = val2; } if (RenderSettings.ambientIntensity != num) { RenderSettings.ambientIntensity = num; } break; } case TOD_AmbientType.Gradient: { Color val3 = TOD_Util.AdjustRGB(AmbientColor, num, saturation); Color val4 = TOD_Util.AdjustRGB(SampleEquatorColor(), num, saturation); Color val5 = TOD_Util.AdjustRGB(SampleSkyColor(), num, saturation); if ((int)RenderSettings.ambientMode != 1) { RenderSettings.ambientMode = (AmbientMode)1; } if (RenderSettings.ambientSkyColor != val5) { RenderSettings.ambientSkyColor = val5; } if (RenderSettings.ambientEquatorColor != val4) { RenderSettings.ambientEquatorColor = val4; } if (RenderSettings.ambientGroundColor != val3) { RenderSettings.ambientGroundColor = val3; } if (RenderSettings.ambientIntensity != num) { RenderSettings.ambientIntensity = num; } break; } case TOD_AmbientType.Spherical: { Color val = TOD_Util.AdjustRGB(AmbientColor, num, saturation); if ((int)RenderSettings.ambientMode != 0) { RenderSettings.ambientMode = (AmbientMode)0; } if (RenderSettings.ambientLight != val) { RenderSettings.ambientLight = val; } if (RenderSettings.ambientIntensity != num) { RenderSettings.ambientIntensity = num; } RenderSettings.ambientProbe = RenderToSphericalHarmonics(num, saturation); break; } } } public void UpdateReflection() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) TOD_ReflectionType mode = Reflection.Mode; if (mode == TOD_ReflectionType.Cubemap) { float num = Mathf.Lerp(Night.ReflectionMultiplier, Day.ReflectionMultiplier, LerpValue); if ((int)RenderSettings.defaultReflectionMode != 0) { RenderSettings.defaultReflectionMode = (DefaultReflectionMode)0; } if (RenderSettings.reflectionIntensity != num) { RenderSettings.reflectionIntensity = num; } if (Application.isPlaying) { RenderToCubemap(); } } } public void LoadParameters(string xml) { using StringReader input = new StringReader(xml); using XmlTextReader xmlReader = new XmlTextReader(input); XmlSerializer xmlSerializer = new XmlSerializer(typeof(TOD_Parameters)); TOD_Parameters tOD_Parameters = xmlSerializer.Deserialize(xmlReader) as TOD_Parameters; tOD_Parameters.ToSky(this); } public string SaveParameters() { StringBuilder stringBuilder = new StringBuilder(); using (StringWriter w = new StringWriter(stringBuilder)) { using XmlTextWriter xmlTextWriter = new XmlTextWriter(w); xmlTextWriter.Formatting = Formatting.Indented; XmlSerializer xmlSerializer = new XmlSerializer(typeof(TOD_Parameters)); TOD_Parameters o = new TOD_Parameters(this); xmlSerializer.Serialize(xmlTextWriter, o); } return stringBuilder.ToString(); } private void UpdateQualitySettings() { if (!Headless) { Mesh val = null; Mesh val2 = null; Mesh val3 = null; Mesh val4 = null; Mesh val5 = null; Mesh val6 = null; switch (MeshQuality) { case TOD_MeshQualityType.Low: val = Resources.SkyLOD2; val2 = Resources.SkyLOD2; val3 = Resources.SkyLOD2; val4 = Resources.CloudsLOD2; val5 = Resources.MoonLOD2; break; case TOD_MeshQualityType.Medium: val = Resources.SkyLOD1; val2 = Resources.SkyLOD1; val3 = Resources.SkyLOD2; val4 = Resources.CloudsLOD1; val5 = Resources.MoonLOD1; break; case TOD_MeshQualityType.High: val = Resources.SkyLOD0; val2 = Resources.SkyLOD0; val3 = Resources.SkyLOD2; val4 = Resources.CloudsLOD0; val5 = Resources.MoonLOD0; break; } switch (StarQuality) { case TOD_StarQualityType.Low: val6 = Resources.StarsLOD2; break; case TOD_StarQualityType.Medium: val6 = Resources.StarsLOD1; break; case TOD_StarQualityType.High: val6 = Resources.StarsLOD0; break; } if (Object.op_Implicit((Object)(object)Components.SpaceMeshFilter) && (Object)(object)Components.SpaceMeshFilter.sharedMesh != (Object)(object)val) { Components.SpaceMeshFilter.mesh = val; } if (Object.op_Implicit((Object)(object)Components.MoonMeshFilter) && (Object)(object)Components.MoonMeshFilter.sharedMesh != (Object)(object)val5) { Components.MoonMeshFilter.mesh = val5; } if (Object.op_Implicit((Object)(object)Components.AtmosphereMeshFilter) && (Object)(object)Components.AtmosphereMeshFilter.sharedMesh != (Object)(object)val2) { Components.AtmosphereMeshFilter.mesh = val2; } if (Object.op_Implicit((Object)(object)Components.ClearMeshFilter) && (Object)(object)Components.ClearMeshFilter.sharedMesh != (Object)(object)val3) { Components.ClearMeshFilter.mesh = val3; } if (Object.op_Implicit((Object)(object)Components.CloudMeshFilter) && (Object)(object)Components.CloudMeshFilter.sharedMesh != (Object)(object)val4) { Components.CloudMeshFilter.mesh = val4; } if (Object.op_Implicit((Object)(object)Components.StarMeshFilter) && (Object)(object)Components.StarMeshFilter.sharedMesh != (Object)(object)val6) { Components.StarMeshFilter.mesh = val6; } } } private void UpdateRenderSettings() { if (!Headless) { UpdateFog(); if (!Application.isPlaying || timeSinceAmbientUpdate >= Ambient.UpdateInterval) { timeSinceAmbientUpdate = 0f; UpdateAmbient(); } else { timeSinceAmbientUpdate += Time.deltaTime; } if (!Application.isPlaying || timeSinceReflectionUpdate >= Reflection.UpdateInterval) { timeSinceReflectionUpdate = 0f; UpdateReflection(); } else { timeSinceReflectionUpdate += Time.deltaTime; } } } private void UpdateShaderKeywords() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 if (Headless) { return; } switch (ColorSpace) { case TOD_ColorSpaceType.Auto: if ((int)QualitySettings.activeColorSpace == 1) { Shader.EnableKeyword("TOD_OUTPUT_LINEAR"); } else { Shader.DisableKeyword("TOD_OUTPUT_LINEAR"); } break; case TOD_ColorSpaceType.Linear: Shader.EnableKeyword("TOD_OUTPUT_LINEAR"); break; case TOD_ColorSpaceType.Gamma: Shader.DisableKeyword("TOD_OUTPUT_LINEAR"); break; } switch (ColorRange) { case TOD_ColorRangeType.Auto: if (Object.op_Implicit((Object)(object)Components.Camera) && Components.Camera.HDR) { Shader.EnableKeyword("TOD_OUTPUT_HDR"); } else { Shader.DisableKeyword("TOD_OUTPUT_HDR"); } break; case TOD_ColorRangeType.HDR: Shader.EnableKeyword("TOD_OUTPUT_HDR"); break; case TOD_ColorRangeType.LDR: Shader.DisableKeyword("TOD_OUTPUT_HDR"); break; } switch (ColorOutput) { case TOD_ColorOutputType.Raw: Shader.DisableKeyword("TOD_OUTPUT_DITHERING"); break; case TOD_ColorOutputType.Dithered: Shader.EnableKeyword("TOD_OUTPUT_DITHERING"); break; } switch (SkyQuality) { case TOD_SkyQualityType.PerVertex: Shader.DisableKeyword("TOD_SCATTERING_PER_PIXEL"); break; case TOD_SkyQualityType.PerPixel: Shader.EnableKeyword("TOD_SCATTERING_PER_PIXEL"); break; } switch (CloudQuality) { case TOD_CloudQualityType.Low: Shader.DisableKeyword("TOD_CLOUDS_DENSITY"); Shader.DisableKeyword("TOD_CLOUDS_BUMPED"); break; case TOD_CloudQualityType.Medium: Shader.EnableKeyword("TOD_CLOUDS_DENSITY"); Shader.DisableKeyword("TOD_CLOUDS_BUMPED"); break; case TOD_CloudQualityType.High: Shader.EnableKeyword("TOD_CLOUDS_DENSITY"); Shader.EnableKeyword("TOD_CLOUDS_BUMPED"); break; } } private void UpdateShaderProperties() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0114: 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_012f: 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) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) if (!Headless) { Shader.SetGlobalColor(Resources.ID_SunLightColor, SunLightColor); Shader.SetGlobalColor(Resources.ID_MoonLightColor, MoonLightColor); Shader.SetGlobalColor(Resources.ID_SunSkyColor, SunSkyColor); Shader.SetGlobalColor(Resources.ID_MoonSkyColor, MoonSkyColor); Shader.SetGlobalColor(Resources.ID_SunMeshColor, SunMeshColor); Shader.SetGlobalColor(Resources.ID_MoonMeshColor, MoonMeshColor); Shader.SetGlobalColor(Resources.ID_SunCloudColor, SunCloudColor); Shader.SetGlobalColor(Resources.ID_MoonCloudColor, MoonCloudColor); Shader.SetGlobalColor(Resources.ID_FogColor, FogColor); Shader.SetGlobalColor(Resources.ID_GroundColor, GroundColor); Shader.SetGlobalColor(Resources.ID_AmbientColor, AmbientColor); Shader.SetGlobalVector(Resources.ID_SunDirection, Vector4.op_Implicit(SunDirection)); Shader.SetGlobalVector(Resources.ID_MoonDirection, Vector4.op_Implicit(MoonDirection)); Shader.SetGlobalVector(Resources.ID_LightDirection, Vector4.op_Implicit(LightDirection)); Shader.SetGlobalVector(Resources.ID_LocalSunDirection, Vector4.op_Implicit(LocalSunDirection)); Shader.SetGlobalVector(Resources.ID_LocalMoonDirection, Vector4.op_Implicit(LocalMoonDirection)); Shader.SetGlobalVector(Resources.ID_LocalLightDirection, Vector4.op_Implicit(LocalLightDirection)); Shader.SetGlobalFloat(Resources.ID_Contrast, Atmosphere.Contrast); Shader.SetGlobalFloat(Resources.ID_Brightness, Atmosphere.Brightness); Shader.SetGlobalFloat(Resources.ID_Fogginess, Atmosphere.Fogginess); Shader.SetGlobalFloat(Resources.ID_Directionality, Atmosphere.Directionality); Shader.SetGlobalFloat(Resources.ID_MoonHaloPower, 1f / Moon.HaloSize); Shader.SetGlobalColor(Resources.ID_MoonHaloColor, MoonHaloColor); float num = Mathf.Lerp(0.8f, 0f, Clouds.Coverage); float num2 = Mathf.Lerp(3f, 9f, Clouds.Sharpness); float num3 = Mathf.Lerp(0f, 1f, Clouds.Attenuation); float num4 = Mathf.Lerp(0f, 2f, Clouds.Saturation); Shader.SetGlobalFloat(Resources.ID_CloudOpacity, Clouds.Opacity); Shader.SetGlobalFloat(Resources.ID_CloudCoverage, num); Shader.SetGlobalFloat(Resources.ID_CloudSharpness, 1f / num2); Shader.SetGlobalFloat(Resources.ID_CloudDensity, num2); Shader.SetGlobalFloat(Resources.ID_CloudColoring, Clouds.Coloring); Shader.SetGlobalFloat(Resources.ID_CloudAttenuation, num3); Shader.SetGlobalFloat(Resources.ID_CloudSaturation, num4); Shader.SetGlobalFloat(Resources.ID_CloudScattering, Clouds.Scattering); Shader.SetGlobalFloat(Resources.ID_CloudBrightness, Clouds.Brightness); Shader.SetGlobalVector(Resources.ID_CloudOffset, Vector4.op_Implicit(Components.Animation.OffsetUV)); Shader.SetGlobalVector(Resources.ID_CloudWind, Vector4.op_Implicit(Components.Animation.CloudUV)); Shader.SetGlobalVector(Resources.ID_CloudSize, Vector4.op_Implicit(new Vector3(Clouds.Size * 4f, Clouds.Size, Clouds.Size * 4f))); Shader.SetGlobalFloat(Resources.ID_StarSize, Stars.Size); Shader.SetGlobalFloat(Resources.ID_StarBrightness, Stars.Brightness); Shader.SetGlobalFloat(Resources.ID_StarVisibility, (1f - Atmosphere.Fogginess) * (1f - LerpValue)); Shader.SetGlobalFloat(Resources.ID_SunMeshContrast, 1f / Mathf.Max(0.001f, Sun.MeshContrast)); Shader.SetGlobalFloat(Resources.ID_SunMeshBrightness, Sun.MeshBrightness * (1f - Atmosphere.Fogginess)); Shader.SetGlobalFloat(Resources.ID_MoonMeshContrast, 1f / Mathf.Max(0.001f, Moon.MeshContrast)); Shader.SetGlobalFloat(Resources.ID_MoonMeshBrightness, Moon.MeshBrightness * (1f - Atmosphere.Fogginess)); Shader.SetGlobalVector(Resources.ID_kBetaMie, Vector4.op_Implicit(kBetaMie)); Shader.SetGlobalVector(Resources.ID_kSun, kSun); Shader.SetGlobalVector(Resources.ID_k4PI, k4PI); Shader.SetGlobalVector(Resources.ID_kRadius, kRadius); Shader.SetGlobalVector(Resources.ID_kScale, kScale); Shader.SetGlobalMatrix(Resources.ID_World2Sky, Components.DomeTransform.worldToLocalMatrix); Shader.SetGlobalMatrix(Resources.ID_Sky2World, Components.DomeTransform.localToWorldMatrix); } } private float ShaderScale(float inCos) { float num = 1f - inCos; return 0.25f * Mathf.Exp(-0.00287f + num * (0.459f + num * (3.83f + num * (-6.8f + num * 5.25f)))); } private float ShaderMiePhase(float eyeCos, float eyeCos2) { return kBetaMie.x * (1f + eyeCos2) / Mathf.Pow(kBetaMie.y + kBetaMie.z * eyeCos, 1.5f); } private float ShaderRayleighPhase(float eyeCos2) { return 0.75f + 0.75f * eyeCos2; } private Color ShaderNightSkyColor(Vector3 dir) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) dir.y = Mathf.Max(0f, dir.y); return MoonSkyColor * (1f - 0.75f * dir.y); } private Color ShaderMoonHaloColor(Vector3 dir) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) return MoonHaloColor * Mathf.Pow(Mathf.Max(0f, Vector3.Dot(dir, LocalMoonDirection)), 1f / Moon.MeshSize); } private Color TOD_HDR2LDR(Color color) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) return new Color(1f - Mathf.Pow(2f, (0f - Atmosphere.Brightness) * color.r), 1f - Mathf.Pow(2f, (0f - Atmosphere.Brightness) * color.g), 1f - Mathf.Pow(2f, (0f - Atmosphere.Brightness) * color.b), color.a); } private Color TOD_GAMMA2LINEAR(Color color) { //IL_0035: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r * color.r, color.g * color.g, color.b * color.b, color.a); } private Color TOD_LINEAR2GAMMA(Color color) { //IL_002c: 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) //IL_0037: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Sqrt(color.r), Mathf.Sqrt(color.g), Mathf.Sqrt(color.b), color.a); } private Color ShaderScatteringColor(Vector3 dir, bool directLight = true) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: 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_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: 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_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) dir.y = Mathf.Max(0f, dir.y); float x = kRadius.x; float y = kRadius.y; float w = kRadius.w; float x2 = kScale.x; float z = kScale.z; float w2 = kScale.w; float x3 = k4PI.x; float y2 = k4PI.y; float z2 = k4PI.z; float w3 = k4PI.w; float x4 = kSun.x; float y3 = kSun.y; float z3 = kSun.z; float w4 = kSun.w; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, x + w2, 0f); float num = Mathf.Sqrt(w + y * dir.y * dir.y - y) - x * dir.y; float num2 = Mathf.Exp(z * (0f - w2)); float inCos = Vector3.Dot(dir, val) / (x + w2); float num3 = num2 * ShaderScale(inCos); float num4 = num / 2f; float num5 = num4 * x2; Vector3 val2 = dir * num4; Vector3 val3 = val + val2 * 0.5f; float num6 = 0f; float num7 = 0f; float num8 = 0f; for (int i = 0; i < 2; i++) { float magnitude = ((Vector3)(ref val3)).magnitude; float num9 = 1f / magnitude; float num10 = Mathf.Exp(z * (x - magnitude)); float num11 = num10 * num5; float inCos2 = Vector3.Dot(dir, val3) * num9; float inCos3 = Vector3.Dot(LocalSunDirection, val3) * num9; float num12 = num3 + num10 * (ShaderScale(inCos3) - ShaderScale(inCos2)); float num13 = Mathf.Exp((0f - num12) * (x3 + w3)); float num14 = Mathf.Exp((0f - num12) * (y2 + w3)); float num15 = Mathf.Exp((0f - num12) * (z2 + w3)); num6 += num13 * num11; num7 += num14 * num11; num8 += num15 * num11; val3 += val2; } float num16 = SunSkyColor.r * num6 * x4; float num17 = SunSkyColor.g * num7 * y3; float num18 = SunSkyColor.b * num8 * z3; float num19 = SunSkyColor.r * num6 * w4; float num20 = SunSkyColor.g * num7 * w4; float num21 = SunSkyColor.b * num8 * w4; float num22 = 0f; float num23 = 0f; float num24 = 0f; float num25 = Vector3.Dot(LocalSunDirection, dir); float eyeCos = num25 * num25; float num26 = ShaderRayleighPhase(eyeCos); num22 += num26 * num16; num23 += num26 * num17; num24 += num26 * num18; if (directLight) { float num27 = ShaderMiePhase(num25, eyeCos); num22 += num27 * num19; num23 += num27 * num20; num24 += num27 * num21; } Color val4 = ShaderNightSkyColor(dir); num22 += val4.r; num23 += val4.g; num24 += val4.b; if (directLight) { Color val5 = ShaderMoonHaloColor(dir); num22 += val5.r; num23 += val5.g; num24 += val5.b; } num22 = Mathf.Lerp(num22, FogColor.r, Atmosphere.Fogginess); num23 = Mathf.Lerp(num23, FogColor.g, Atmosphere.Fogginess); num24 = Mathf.Lerp(num24, FogColor.b, Atmosphere.Fogginess); num22 = Mathf.Pow(num22 * Atmosphere.Brightness, Atmosphere.Contrast); num23 = Mathf.Pow(num23 * Atmosphere.Brightness, Atmosphere.Contrast); num24 = Mathf.Pow(num24 * Atmosphere.Brightness, Atmosphere.Contrast); return new Color(num22, num23, num24, 1f); } private void Initialize() { Components = ((Component)this).GetComponent(); Components.Initialize(); Resources = ((Component)this).GetComponent(); Resources.Initialize(); instances.Add(this); Initialized = true; } private void Cleanup() { if (Object.op_Implicit((Object)(object)Probe)) { Object.Destroy((Object)(object)((Component)Probe).gameObject); } instances.Remove(this); Initialized = false; } protected void OnEnable() { LateUpdate(); } protected void OnDisable() { Cleanup(); } protected void LateUpdate() { if (!Initialized) { Initialize(); } Profiler.BeginSample("UpdateScattering"); UpdateScattering(); Profiler.EndSample(); Profiler.BeginSample("UpdateCelestials"); UpdateCelestials(); Profiler.EndSample(); Profiler.BeginSample("UpdateQualitySettings"); UpdateQualitySettings(); Profiler.EndSample(); Profiler.BeginSample("UpdateRenderSettings"); UpdateRenderSettings(); Profiler.EndSample(); Profiler.BeginSample("UpdateShaderKeywords"); UpdateShaderKeywords(); Profiler.EndSample(); Profiler.BeginSample("UpdateShaderProperties"); UpdateShaderProperties(); Profiler.EndSample(); } protected void OnValidate() { Cycle.DateTime = Cycle.DateTime; } [ContextMenu("Import Parameters")] private void EditorImportParameters() { string @string = EditorPrefs.GetString("Time of Day Folder", Application.dataPath); string text = EditorUtility.OpenFilePanel("Import", @string, "xml"); if (!string.IsNullOrEmpty(text)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(TOD_Parameters)); using (FileStream input = new FileStream(text, FileMode.Open)) { XmlTextReader xmlReader = new XmlTextReader(input); TOD_Parameters tOD_Parameters = xmlSerializer.Deserialize(xmlReader) as TOD_Parameters; tOD_Parameters.ToSky(this); EditorUtility.SetDirty((Object)(object)this); } EditorPrefs.SetString("Time of Day Folder", Path.GetDirectoryName(text)); EditorPrefs.SetString("Time of Day File", Path.GetFileName(text)); } } [ContextMenu("Export Parameters")] private void EditorExportParameters() { string @string = EditorPrefs.GetString("Time of Day Folder", Application.dataPath); string string2 = EditorPrefs.GetString("Time of Day File", "Time of Day.xml"); string text = EditorUtility.SaveFilePanel("Export", @string, string2, "xml"); if (!string.IsNullOrEmpty(text)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(TOD_Parameters)); using (FileStream w = new FileStream(text, FileMode.Create)) { TOD_Parameters o = new TOD_Parameters(this); XmlTextWriter xmlTextWriter = new XmlTextWriter(w, Encoding.UTF8); xmlTextWriter.Formatting = Formatting.Indented; xmlSerializer.Serialize(xmlTextWriter, o); AssetDatabase.Refresh(); } EditorPrefs.SetString("Time of Day Folder", Path.GetDirectoryName(text)); EditorPrefs.SetString("Time of Day File", Path.GetFileName(text)); } } private void UpdateScattering() { float num = 0f - Atmosphere.Directionality; float num2 = num * num; kBetaMie.x = 1.5f * ((1f - num2) / (2f + num2)); kBetaMie.y = 1f + num2; kBetaMie.z = 2f * num; float num3 = 0.002f * Atmosphere.MieMultiplier; float num4 = 0.002f * Atmosphere.RayleighMultiplier; float x = num4 * 40f * 5.2701645f; float y = num4 * 40f * 9.473285f; float z = num4 * 40f * 19.643803f; float w = num3 * 40f; kSun.x = x; kSun.y = y; kSun.z = z; kSun.w = w; float x2 = num4 * 4f * (float)Math.PI * 5.2701645f; float y2 = num4 * 4f * (float)Math.PI * 9.473285f; float z2 = num4 * 4f * (float)Math.PI * 19.643803f; float w2 = num3 * 4f * (float)Math.PI; k4PI.x = x2; k4PI.y = y2; k4PI.z = z2; k4PI.w = w2; kRadius.x = 1f; kRadius.y = 1f; kRadius.z = 1.025f; kRadius.w = 1.050625f; kScale.x = 40.00004f; kScale.y = 0.25f; kScale.z = 160.00015f; kScale.w = 0.0001f; } private void UpdateCelestials() { //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_080c: Unknown result type (might be due to invalid IL or missing references) //IL_0811: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Unknown result type (might be due to invalid IL or missing references) //IL_08cc: Unknown result type (might be due to invalid IL or missing references) //IL_08d1: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_084b: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_08ec: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) //IL_090d: Unknown result type (might be due to invalid IL or missing references) //IL_0912: Unknown result type (might be due to invalid IL or missing references) //IL_0967: Unknown result type (might be due to invalid IL or missing references) //IL_096c: Unknown result type (might be due to invalid IL or missing references) //IL_0979: Unknown result type (might be due to invalid IL or missing references) //IL_097e: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_0947: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0992: Unknown result type (might be due to invalid IL or missing references) //IL_0997: Unknown result type (might be due to invalid IL or missing references) //IL_099c: Unknown result type (might be due to invalid IL or missing references) //IL_09a9: Unknown result type (might be due to invalid IL or missing references) //IL_09c6: Unknown result type (might be due to invalid IL or missing references) //IL_09cb: Unknown result type (might be due to invalid IL or missing references) //IL_0a64: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a26: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0b11: Unknown result type (might be due to invalid IL or missing references) //IL_0b16: Unknown result type (might be due to invalid IL or missing references) //IL_0b5c: Unknown result type (might be due to invalid IL or missing references) //IL_0b61: Unknown result type (might be due to invalid IL or missing references) //IL_0d2a: Unknown result type (might be due to invalid IL or missing references) //IL_0d2f: Unknown result type (might be due to invalid IL or missing references) //IL_0d47: Unknown result type (might be due to invalid IL or missing references) //IL_0d4c: Unknown result type (might be due to invalid IL or missing references) //IL_0d64: Unknown result type (might be due to invalid IL or missing references) //IL_0d69: Unknown result type (might be due to invalid IL or missing references) //IL_0d81: Unknown result type (might be due to invalid IL or missing references) //IL_0d86: Unknown result type (might be due to invalid IL or missing references) //IL_0d9e: Unknown result type (might be due to invalid IL or missing references) //IL_0da3: Unknown result type (might be due to invalid IL or missing references) //IL_0dbb: Unknown result type (might be due to invalid IL or missing references) //IL_0dc0: Unknown result type (might be due to invalid IL or missing references) //IL_0dd8: Unknown result type (might be due to invalid IL or missing references) //IL_0ddd: Unknown result type (might be due to invalid IL or missing references) //IL_0df5: Unknown result type (might be due to invalid IL or missing references) //IL_0dfa: Unknown result type (might be due to invalid IL or missing references) //IL_0e12: Unknown result type (might be due to invalid IL or missing references) //IL_0e17: Unknown result type (might be due to invalid IL or missing references) //IL_0e2f: Unknown result type (might be due to invalid IL or missing references) //IL_0e34: Unknown result type (might be due to invalid IL or missing references) //IL_0e4b: Unknown result type (might be due to invalid IL or missing references) //IL_0e50: Unknown result type (might be due to invalid IL or missing references) //IL_0e55: Unknown result type (might be due to invalid IL or missing references) //IL_0e64: Unknown result type (might be due to invalid IL or missing references) //IL_0e69: Unknown result type (might be due to invalid IL or missing references) //IL_0e6e: Unknown result type (might be due to invalid IL or missing references) //IL_0e71: Unknown result type (might be due to invalid IL or missing references) //IL_0e73: Unknown result type (might be due to invalid IL or missing references) //IL_0e7b: Unknown result type (might be due to invalid IL or missing references) //IL_0e92: Unknown result type (might be due to invalid IL or missing references) //IL_0e97: Unknown result type (might be due to invalid IL or missing references) //IL_0e9c: Unknown result type (might be due to invalid IL or missing references) //IL_0eab: Unknown result type (might be due to invalid IL or missing references) //IL_0eb0: Unknown result type (might be due to invalid IL or missing references) //IL_0eb5: Unknown result type (might be due to invalid IL or missing references) //IL_0eb8: Unknown result type (might be due to invalid IL or missing references) //IL_0eba: Unknown result type (might be due to invalid IL or missing references) //IL_0ec2: Unknown result type (might be due to invalid IL or missing references) //IL_0ecc: Unknown result type (might be due to invalid IL or missing references) //IL_0ece: Unknown result type (might be due to invalid IL or missing references) //IL_0ed0: Unknown result type (might be due to invalid IL or missing references) //IL_0ed2: Unknown result type (might be due to invalid IL or missing references) //IL_0ed5: Unknown result type (might be due to invalid IL or missing references) //IL_0ed7: Unknown result type (might be due to invalid IL or missing references) //IL_0edf: Unknown result type (might be due to invalid IL or missing references) //IL_0eeb: Unknown result type (might be due to invalid IL or missing references) //IL_0efe: Unknown result type (might be due to invalid IL or missing references) //IL_0f99: Unknown result type (might be due to invalid IL or missing references) //IL_0f9e: Unknown result type (might be due to invalid IL or missing references) //IL_0f52: Unknown result type (might be due to invalid IL or missing references) //IL_0f57: Unknown result type (might be due to invalid IL or missing references) //IL_0fac: Unknown result type (might be due to invalid IL or missing references) //IL_0fb1: Unknown result type (might be due to invalid IL or missing references) //IL_0fc9: Unknown result type (might be due to invalid IL or missing references) //IL_10b5: Unknown result type (might be due to invalid IL or missing references) //IL_1086: Unknown result type (might be due to invalid IL or missing references) //IL_10ba: Unknown result type (might be due to invalid IL or missing references) //IL_10c7: Unknown result type (might be due to invalid IL or missing references) //IL_10cc: Unknown result type (might be due to invalid IL or missing references) //IL_1133: Unknown result type (might be due to invalid IL or missing references) //IL_1138: Unknown result type (might be due to invalid IL or missing references) //IL_114f: Unknown result type (might be due to invalid IL or missing references) //IL_1154: Unknown result type (might be due to invalid IL or missing references) //IL_116a: Unknown result type (might be due to invalid IL or missing references) //IL_116f: Unknown result type (might be due to invalid IL or missing references) //IL_1186: Unknown result type (might be due to invalid IL or missing references) //IL_118b: Unknown result type (might be due to invalid IL or missing references) //IL_11a1: Unknown result type (might be due to invalid IL or missing references) //IL_11a6: Unknown result type (might be due to invalid IL or missing references) //IL_11bd: Unknown result type (might be due to invalid IL or missing references) //IL_11c2: Unknown result type (might be due to invalid IL or missing references) //IL_10e4: Unknown result type (might be due to invalid IL or missing references) //IL_1101: Unknown result type (might be due to invalid IL or missing references) float num = (float)Math.PI / 180f * World.Latitude; float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); float longitude = World.Longitude; float num4 = (float)Math.PI / 2f; int year = Cycle.Year; int month = Cycle.Month; int day = Cycle.Day; float num5 = Cycle.Hour - World.UTC; float num6 = (float)(367 * year - 7 * (year + (month + 9) / 12) / 4 + 275 * month / 9 + day - 730530) + num5 / 24f; float num7 = (float)(367 * year - 7 * (year + (month + 9) / 12) / 4 + 275 * month / 9 + day - 730530) + 0.5f; float num8 = 23.4393f - 3.563E-07f * num6; float num9 = (float)Math.PI / 180f * num8; float num10 = Mathf.Sin(num9); float num11 = Mathf.Cos(num9); float num12 = 282.9404f + 4.70935E-05f * num7; float num13 = 0.016709f - 1.151E-09f * num7; float num14 = 356.047f + 0.98560023f * num7; float num15 = (float)Math.PI / 180f * num14; float num16 = Mathf.Sin(num15); float num17 = Mathf.Cos(num15); float num18 = num15 + num13 * num16 * (1f + num13 * num17); float num19 = Mathf.Sin(num18); float num20 = Mathf.Cos(num18); float num21 = num20 - num13; float num22 = Mathf.Sqrt(1f - num13 * num13) * num19; float num23 = 57.29578f * Mathf.Atan2(num22, num21); float num24 = Mathf.Sqrt(num21 * num21 + num22 * num22); float num25 = num23 + num12; float num26 = (float)Math.PI / 180f * num25; float num27 = Mathf.Sin(num26); float num28 = Mathf.Cos(num26); float num29 = num24 * num28; float num30 = num24 * num27; float num31 = num29; float num32 = num30 * num11; float num33 = num30 * num10; float num34 = Mathf.Atan2(num32, num31); float num35 = 57.29578f * num34; float num36 = Mathf.Atan2(num33, Mathf.Sqrt(num31 * num31 + num32 * num32)); float num37 = Mathf.Sin(num36); float num38 = Mathf.Cos(num36); float num39 = num23 + num12; float num40 = num39 + 180f; float num41 = num35 - num40 - longitude; float num42 = -6f; float num43 = (float)Math.PI / 180f * num42; float num44 = Mathf.Sin(num43); float num45 = (num44 - num2 * num37) / (num3 * num38); float num46 = Mathf.Acos(num45); float num47 = 57.29578f * num46; SunsetTime = (24f + ((num41 + num47) / 15f + World.UTC) % 24f) % 24f; SunriseTime = (24f + ((num41 - num47) / 15f + World.UTC) % 24f) % 24f; float num48 = 282.9404f + 4.70935E-05f * num6; float num49 = 0.016709f - 1.151E-09f * num6; float num50 = 356.047f + 0.98560023f * num6; float num51 = (float)Math.PI / 180f * num50; float num52 = Mathf.Sin(num51); float num53 = Mathf.Cos(num51); float num54 = num51 + num49 * num52 * (1f + num49 * num53); float num55 = Mathf.Sin(num54); float num56 = Mathf.Cos(num54); float num57 = num56 - num49; float num58 = Mathf.Sqrt(1f - num49 * num49) * num55; float num59 = 57.29578f * Mathf.Atan2(num58, num57); float num60 = Mathf.Sqrt(num57 * num57 + num58 * num58); float num61 = num59 + num48; float num62 = (float)Math.PI / 180f * num61; float num63 = Mathf.Sin(num62); float num64 = Mathf.Cos(num62); float num65 = num60 * num64; float num66 = num60 * num63; float num67 = num65; float num68 = num66 * num11; float num69 = num66 * num10; float num70 = Mathf.Atan2(num68, num67); float num71 = Mathf.Atan2(num69, Mathf.Sqrt(num67 * num67 + num68 * num68)); float num72 = Mathf.Sin(num71); float num73 = Mathf.Cos(num71); float num74 = num59 + num48; float num75 = num74 + 180f; float num76 = num75 + 15f * num5; float num77 = (float)Math.PI / 180f * (num76 + longitude); LocalSiderealTime = (num76 + longitude) / 15f; float num78 = num77 - num70; float num79 = Mathf.Sin(num78); float num80 = Mathf.Cos(num78); float num81 = num80 * num73; float num82 = num79 * num73; float num83 = num72; float num84 = num81 * num2 - num83 * num3; float num85 = num82; float num86 = num81 * num3 + num83 * num2; float num87 = Mathf.Atan2(num85, num84) + (float)Math.PI; float num88 = Mathf.Atan2(num86, Mathf.Sqrt(num84 * num84 + num85 * num85)); float num89 = num4 - num88; float num90 = num88; float num91 = num87; SunZenith = 57.29578f * num89; SunAltitude = 57.29578f * num90; SunAzimuth = 57.29578f * num91; float num142; float num143; float num144; if (Moon.Position == TOD_MoonPositionType.Realistic) { float num92 = 125.1228f - 0.05295381f * num6; float num93 = 5.1454f; float num94 = 318.0634f + 0.16435732f * num6; float num95 = 60.2666f; float num96 = 0.0549f; float num97 = 115.3654f + 13.064993f * num6; float num98 = (float)Math.PI / 180f * num92; float num99 = Mathf.Sin(num98); float num100 = Mathf.Cos(num98); float num101 = (float)Math.PI / 180f * num93; float num102 = Mathf.Sin(num101); float num103 = Mathf.Cos(num101); float num104 = (float)Math.PI / 180f * num97; float num105 = Mathf.Sin(num104); float num106 = Mathf.Cos(num104); float num107 = num104 + num96 * num105 * (1f + num96 * num106); float num108 = Mathf.Sin(num107); float num109 = Mathf.Cos(num107); float num110 = num95 * (num109 - num96); float num111 = num95 * (Mathf.Sqrt(1f - num96 * num96) * num108); float num112 = 57.29578f * Mathf.Atan2(num111, num110); float num113 = Mathf.Sqrt(num110 * num110 + num111 * num111); float num114 = num112 + num94; float num115 = (float)Math.PI / 180f * num114; float num116 = Mathf.Sin(num115); float num117 = Mathf.Cos(num115); float num118 = num113 * (num100 * num117 - num99 * num116 * num103); float num119 = num113 * (num99 * num117 + num100 * num116 * num103); float num120 = num113 * (num116 * num102); float num121 = num118; float num122 = num119; float num123 = num120; float num124 = num121; float num125 = num122 * num11 - num123 * num10; float num126 = num122 * num10 + num123 * num11; float num127 = Mathf.Atan2(num125, num124); float num128 = Mathf.Atan2(num126, Mathf.Sqrt(num124 * num124 + num125 * num125)); float num129 = Mathf.Sin(num128); float num130 = Mathf.Cos(num128); float num131 = num77 - num127; float num132 = Mathf.Sin(num131); float num133 = Mathf.Cos(num131); float num134 = num133 * num130; float num135 = num132 * num130; float num136 = num129; float num137 = num134 * num2 - num136 * num3; float num138 = num135; float num139 = num134 * num3 + num136 * num2; float num140 = Mathf.Atan2(num138, num137) + (float)Math.PI; float num141 = Mathf.Atan2(num139, Mathf.Sqrt(num137 * num137 + num138 * num138)); num142 = num4 - num141; num143 = num141; num144 = num140; } else { num142 = num89 - (float)Math.PI; num143 = num90 - (float)Math.PI; num144 = num91; } MoonZenith = 57.29578f * num142; MoonAltitude = 57.29578f * num143; MoonAzimuth = 57.29578f * num144; Quaternion val = Quaternion.Euler(90f - World.Latitude, 0f, 0f) * Quaternion.Euler(0f, 180f + num77 * 57.29578f, 0f); if (Stars.Position == TOD_StarsPositionType.Rotating) { if (Components.SpaceTransform.localRotation * Vector3.one != val * Vector3.one) { Components.SpaceTransform.localRotation = val; } if (Components.StarTransform.localRotation * Vector3.one != val * Vector3.one) { Components.StarTransform.localRotation = val; } } else { if (Components.SpaceTransform.localRotation != Quaternion.identity) { Components.SpaceTransform.localRotation = Quaternion.identity; } if (Components.StarTransform.localRotation != Quaternion.identity) { Components.StarTransform.localRotation = Quaternion.identity; } } Vector3 val2 = OrbitalToLocal(num89, num91); if (Components.SunTransform.localPosition != val2) { Components.SunTransform.localPosition = val2; Components.SunTransform.LookAt(Components.DomeTransform.position, Components.SunTransform.up); } Vector3 val3 = OrbitalToLocal(num142, num144); if (Components.MoonTransform.localPosition != val3) { Vector3 val4 = val * -Vector3.right; Components.MoonTransform.localPosition = val3; Components.MoonTransform.LookAt(Components.DomeTransform.position, val4); } float num145 = 8f * Mathf.Tan((float)Math.PI / 360f * Sun.MeshSize); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(num145, num145, num145); if (Components.SunTransform.localScale != val5) { Components.SunTransform.localScale = val5; } float num146 = 4f * Mathf.Tan((float)Math.PI / 360f * Moon.MeshSize); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(num146, num146, num146); if (Components.MoonTransform.localScale != val6) { Components.MoonTransform.localScale = val6; } bool flag = (1f - Atmosphere.Fogginess) * (1f - LerpValue) > 0f; if (Components.SpaceRenderer.enabled != flag) { Components.SpaceRenderer.enabled = flag; } if (Components.StarRenderer.enabled != flag) { Components.StarRenderer.enabled = flag; } bool flag2 = Components.SunTransform.localPosition.y > 0f - num145; if (Components.SunRenderer.enabled != flag2) { Components.SunRenderer.enabled = flag2; } bool flag3 = Components.MoonTransform.localPosition.y > 0f - num146; if (Components.MoonRenderer.enabled != flag3) { Components.MoonRenderer.enabled = flag3; } bool flag4 = true; if (Components.AtmosphereRenderer.enabled != flag4) { Components.AtmosphereRenderer.enabled = flag4; } bool flag5 = false; if (Components.ClearRenderer.enabled != flag5) { Components.ClearRenderer.enabled = flag5; } bool flag6 = Clouds.Coverage > 0f && Clouds.Opacity > 0f; if (Components.CloudRenderer.enabled != flag6) { Components.CloudRenderer.enabled = flag6; } LerpValue = Mathf.InverseLerp(105f, 90f, SunZenith); float num147 = Mathf.Clamp01(SunZenith / 90f); float num148 = Mathf.Clamp01((SunZenith - 90f) / 90f); float num149 = Mathf.Clamp01((LerpValue - 0.1f) / 0.9f); float num150 = Mathf.Clamp01((0.1f - LerpValue) / 0.1f); float num151 = Mathf.Clamp01((90f - num142 * 57.29578f) / 5f); SunVisibility = (1f - Atmosphere.Fogginess) * num149; MoonVisibility = (1f - Atmosphere.Fogginess) * num150 * num151; SunLightColor = TOD_Util.ApplyAlpha(Day.LightColor.Evaluate(num147)); MoonLightColor = TOD_Util.ApplyAlpha(Night.LightColor.Evaluate(num148)); SunRayColor = TOD_Util.ApplyAlpha(Day.RayColor.Evaluate(num147)); MoonRayColor = TOD_Util.ApplyAlpha(Night.RayColor.Evaluate(num148)); SunSkyColor = TOD_Util.ApplyAlpha(Day.SkyColor.Evaluate(num147)); MoonSkyColor = TOD_Util.ApplyAlpha(Night.SkyColor.Evaluate(num148)); SunMeshColor = TOD_Util.ApplyAlpha(Day.SunColor.Evaluate(num147)); MoonMeshColor = TOD_Util.ApplyAlpha(Night.MoonColor.Evaluate(num148)); SunCloudColor = TOD_Util.ApplyAlpha(Day.CloudColor.Evaluate(num147)); MoonCloudColor = TOD_Util.ApplyAlpha(Night.CloudColor.Evaluate(num148)); Color val7 = TOD_Util.ApplyAlpha(Day.FogColor.Evaluate(num147)); Color val8 = TOD_Util.ApplyAlpha(Night.FogColor.Evaluate(num148)); FogColor = Color.Lerp(val8, val7, LerpValue); Color val9 = TOD_Util.ApplyAlpha(Day.AmbientColor.Evaluate(num147)); Color val10 = TOD_Util.ApplyAlpha(Night.AmbientColor.Evaluate(num148)); AmbientColor = Color.Lerp(val10, val9, LerpValue); Color val11 = val9; Color val12 = val10; GroundColor = Color.Lerp(val12, val11, LerpValue); MoonHaloColor = TOD_Util.MulRGB(MoonSkyColor, Moon.HaloBrightness * num151); float shadowStrength; float num152; Color val13; if (LerpValue > 0.1f) { IsDay = true; IsNight = false; shadowStrength = Day.ShadowStrength; num152 = Mathf.Lerp(0f, Day.LightIntensity, SunVisibility); val13 = SunLightColor; } else { IsDay = false; IsNight = true; shadowStrength = Night.ShadowStrength; num152 = Mathf.Lerp(0f, Night.LightIntensity, MoonVisibility); val13 = MoonLightColor; } if (Components.LightSource.color != val13) { Components.LightSource.color = val13; } if (Components.LightSource.intensity != num152) { Components.LightSource.intensity = num152; } if (Components.LightSource.shadowStrength != shadowStrength) { Components.LightSource.shadowStrength = shadowStrength; } if (!Application.isPlaying || timeSinceLightUpdate >= Light.UpdateInterval) { timeSinceLightUpdate = 0f; Vector3 val14 = ((!IsNight) ? OrbitalToLocal(Mathf.Min(num89, (1f - Light.MinimumHeight) * (float)Math.PI / 2f), num91) : OrbitalToLocal(Mathf.Min(num142, (1f - Light.MinimumHeight) * (float)Math.PI / 2f), num144)); if (Components.LightTransform.localPosition != val14) { Components.LightTransform.localPosition = val14; Components.LightTransform.LookAt(Components.DomeTransform.position); } } else { timeSinceLightUpdate += Time.deltaTime; } SunDirection = -Components.SunTransform.forward; LocalSunDirection = Components.DomeTransform.InverseTransformDirection(SunDirection); MoonDirection = -Components.MoonTransform.forward; LocalMoonDirection = Components.DomeTransform.InverseTransformDirection(MoonDirection); LightDirection = -Components.LightTransform.forward; LocalLightDirection = Components.DomeTransform.InverseTransformDirection(LightDirection); } } public class TOD_Time : MonoBehaviour { [Tooltip("Length of one day in minutes.")] [TOD_Min(0f)] public float DayLengthInMinutes = 30f; [Tooltip("Progress time at runtime.")] public bool ProgressTime = true; [Tooltip("Set the date to the current device date on start.")] public bool UseDeviceDate = false; [Tooltip("Set the time to the current device time on start.")] public bool UseDeviceTime = false; [Tooltip("Apply the time curve when progressing time.")] public bool UseTimeCurve = false; [Tooltip("Time progression curve.")] public AnimationCurve TimeCurve = AnimationCurve.Linear(0f, 0f, 24f, 24f); private TOD_Sky sky; private AnimationCurve timeCurve; private AnimationCurve timeCurveInverse; public event Action OnSecond; public event Action OnMinute; public event Action OnHour; public event Action OnDay; public event Action OnMonth; public event Action OnYear; public event Action OnSunrise; public event Action OnSunset; public void RefreshTimeCurve() { TimeCurve.preWrapMode = (WrapMode)1; TimeCurve.postWrapMode = (WrapMode)1; ApproximateCurve(TimeCurve, out timeCurve, out timeCurveInverse); timeCurve.preWrapMode = (WrapMode)2; timeCurve.postWrapMode = (WrapMode)2; timeCurveInverse.preWrapMode = (WrapMode)2; timeCurveInverse.postWrapMode = (WrapMode)2; } public float ApplyTimeCurve(float deltaTime) { float num = timeCurveInverse.Evaluate(sky.Cycle.Hour) + deltaTime; deltaTime = timeCurve.Evaluate(num) - sky.Cycle.Hour; if (num >= 24f) { deltaTime += (float)((int)num / 24 * 24); } else if (num < 0f) { deltaTime += (float)(((int)num / 24 - 1) * 24); } return deltaTime; } public void AddHours(float hours, bool adjust = true) { if (UseTimeCurve && adjust) { hours = ApplyTimeCurve(hours); } DateTime dateTime = sky.Cycle.DateTime; DateTime dateTime2 = dateTime.AddHours(hours); sky.Cycle.DateTime = dateTime2; if (dateTime2.Year > dateTime.Year) { if (this.OnYear != null) { this.OnYear(); } if (this.OnMonth != null) { this.OnMonth(); } if (this.OnDay != null) { this.OnDay(); } if (this.OnHour != null) { this.OnHour(); } if (this.OnMinute != null) { this.OnMinute(); } if (this.OnSecond != null) { this.OnSecond(); } } else if (dateTime2.Month > dateTime.Month) { if (this.OnMonth != null) { this.OnMonth(); } if (this.OnDay != null) { this.OnDay(); } if (this.OnHour != null) { this.OnHour(); } if (this.OnMinute != null) { this.OnMinute(); } if (this.OnSecond != null) { this.OnSecond(); } } else if (dateTime2.Day > dateTime.Day) { if (this.OnDay != null) { this.OnDay(); } if (this.OnHour != null) { this.OnHour(); } if (this.OnMinute != null) { this.OnMinute(); } if (this.OnSecond != null) { this.OnSecond(); } } else if (dateTime2.Hour > dateTime.Hour) { if (this.OnHour != null) { this.OnHour(); } if (this.OnMinute != null) { this.OnMinute(); } if (this.OnSecond != null) { this.OnSecond(); } } else if (dateTime2.Minute > dateTime.Minute) { if (this.OnMinute != null) { this.OnMinute(); } if (this.OnSecond != null) { this.OnSecond(); } } else if (dateTime2.Second > dateTime.Second && this.OnSecond != null) { this.OnSecond(); } double totalHours = dateTime.TimeOfDay.TotalHours; double totalHours2 = dateTime2.TimeOfDay.TotalHours; if (totalHours < (double)sky.SunriseTime && totalHours2 >= (double)sky.SunriseTime && this.OnSunrise != null) { this.OnSunrise(); } if (totalHours < (double)sky.SunsetTime && totalHours2 >= (double)sky.SunsetTime && this.OnSunset != null) { this.OnSunset(); } } public void AddSeconds(float seconds, bool adjust = true) { AddHours(seconds / 3600f); } private void CalculateLinearTangents(Keyframe[] keys) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < keys.Length; i++) { Keyframe val = keys[i]; if (i > 0) { Keyframe val2 = keys[i - 1]; ((Keyframe)(ref val)).inTangent = (((Keyframe)(ref val)).value - ((Keyframe)(ref val2)).value) / (((Keyframe)(ref val)).time - ((Keyframe)(ref val2)).time); } if (i < keys.Length - 1) { Keyframe val3 = keys[i + 1]; ((Keyframe)(ref val)).outTangent = (((Keyframe)(ref val3)).value - ((Keyframe)(ref val)).value) / (((Keyframe)(ref val3)).time - ((Keyframe)(ref val)).time); } keys[i] = val; } } private void ApproximateCurve(AnimationCurve source, out AnimationCurve approxCurve, out AnimationCurve approxInverse) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown Keyframe[] array = (Keyframe[])(object)new Keyframe[25]; Keyframe[] array2 = (Keyframe[])(object)new Keyframe[25]; float num = -0.01f; for (int i = 0; i < 25; i++) { num = Mathf.Max(num + 0.01f, source.Evaluate((float)i)); ref Keyframe reference = ref array[i]; reference = new Keyframe((float)i, num); ref Keyframe reference2 = ref array2[i]; reference2 = new Keyframe(num, (float)i); } CalculateLinearTangents(array); CalculateLinearTangents(array2); approxCurve = new AnimationCurve(array); approxInverse = new AnimationCurve(array2); } protected void Awake() { sky = ((Component)this).GetComponent(); if (UseDeviceDate) { sky.Cycle.Year = DateTime.Now.Year; sky.Cycle.Month = DateTime.Now.Month; sky.Cycle.Day = DateTime.Now.Day; } if (UseDeviceTime) { sky.Cycle.Hour = (float)DateTime.Now.TimeOfDay.TotalHours; } RefreshTimeCurve(); } protected void FixedUpdate() { if (ProgressTime && DayLengthInMinutes > 0f) { float num = 1440f / DayLengthInMinutes; AddSeconds(Time.fixedDeltaTime * num); } } } public static class TOD_Util { public static Color MulRGB(Color color, float multiplier) { //IL_0035: 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) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (multiplier == 1f) { return color; } return new Color(color.r * multiplier, color.g * multiplier, color.b * multiplier, color.a); } public static Color MulRGBA(Color color, float multiplier) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (multiplier == 1f) { return color; } return new Color(color.r * multiplier, color.g * multiplier, color.b * multiplier, color.a * multiplier); } public static Color PowRGB(Color color, float power) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (power == 1f) { return color; } return new Color(Mathf.Pow(color.r, power), Mathf.Pow(color.g, power), Mathf.Pow(color.b, power), color.a); } public static Color PowRGBA(Color color, float power) { //IL_0047: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (power == 1f) { return color; } return new Color(Mathf.Pow(color.r, power), Mathf.Pow(color.g, power), Mathf.Pow(color.b, power), Mathf.Pow(color.a, power)); } public static Color SatRGB(Color color, float saturation) { //IL_0045: 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_004c: Unknown result type (might be due to invalid IL or missing references) float grayscale = ((Color)(ref color)).grayscale; color.r = grayscale + (color.r - grayscale) * saturation; color.g = grayscale + (color.g - grayscale) * saturation; color.b = grayscale + (color.b - grayscale) * saturation; return color; } public static Color SatRGBA(Color color, float saturation) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) float grayscale = ((Color)(ref color)).grayscale; color.r = grayscale + (color.r - grayscale) * saturation; color.g = grayscale + (color.g - grayscale) * saturation; color.b = grayscale + (color.b - grayscale) * saturation; color.a = grayscale + (color.a - grayscale) * saturation; return color; } public static Color AdjustRGB(Color color, float intensity, float saturation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return MulRGB(SatRGB(color, saturation), intensity); } public static Color AdjustRGBA(Color color, float intensity, float saturation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return MulRGBA(SatRGBA(color, saturation), intensity); } public static Color ApplyAlpha(Color color) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r * color.a, color.g * color.a, color.b * color.a, 1f); } } public abstract class TOD_Audio : MonoBehaviour { private AudioSource audioComponent; protected float GetVolume() { if (Object.op_Implicit((Object)(object)audioComponent)) { return audioComponent.volume; } return 0f; } protected void SetVolume(float value) { if (Object.op_Implicit((Object)(object)audioComponent)) { audioComponent.volume = value; ((Behaviour)audioComponent).enabled = value > 0f; } } protected void Awake() { audioComponent = ((Component)this).GetComponent(); } } public class TOD_AudioAtDay : TOD_Audio { public float fadeTime = 1f; private float lerpTime = 0f; private float maxVolume; protected void Start() { maxVolume = GetVolume(); SetVolume((!TOD_Sky.Instance.IsDay) ? 0f : maxVolume); } protected void Update() { int num = (TOD_Sky.Instance.IsDay ? 1 : (-1)); lerpTime = Mathf.Clamp01(lerpTime + (float)num * Time.deltaTime / fadeTime); SetVolume(Mathf.Lerp(0f, maxVolume, lerpTime)); } } public class TOD_AudioAtNight : TOD_Audio { public float fadeTime = 1f; private float lerpTime = 0f; private float maxVolume; protected void Start() { maxVolume = GetVolume(); SetVolume((!TOD_Sky.Instance.IsDay) ? 0f : maxVolume); } protected void Update() { int num = (TOD_Sky.Instance.IsDay ? 1 : (-1)); lerpTime = Mathf.Clamp01(lerpTime + (float)num * Time.deltaTime / fadeTime); SetVolume(Mathf.Lerp(0f, maxVolume, lerpTime)); } } public class TOD_AudioAtTime : TOD_Audio { public AnimationCurve Volume; public TOD_AudioAtTime() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_005a: Unknown result type (might be due to invalid IL or missing references) AnimationCurve val = new AnimationCurve(); val.keys = (Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0f), new Keyframe(12f, 1f), new Keyframe(24f, 0f) }; Volume = val; base..ctor(); } protected void Update() { SetVolume(Volume.Evaluate(TOD_Sky.Instance.Cycle.Hour)); } } public abstract class TOD_Light : MonoBehaviour { private Light lightComponent; protected float GetIntensity() { if (Object.op_Implicit((Object)(object)lightComponent)) { return lightComponent.intensity; } return 0f; } protected void SetIntensity(float value) { if (Object.op_Implicit((Object)(object)lightComponent)) { lightComponent.intensity = value; ((Behaviour)lightComponent).enabled = value > 0f; } } protected void Awake() { lightComponent = ((Component)this).GetComponent(); } } public class TOD_LightAtDay : TOD_Light { public float fadeTime = 1f; private float lerpTime = 0f; private float maxIntensity; protected void Start() { maxIntensity = GetIntensity(); SetIntensity((!TOD_Sky.Instance.IsDay) ? 0f : maxIntensity); } protected void Update() { int num = (TOD_Sky.Instance.IsDay ? 1 : (-1)); lerpTime = Mathf.Clamp01(lerpTime + (float)num * Time.deltaTime / fadeTime); SetIntensity(Mathf.Lerp(0f, maxIntensity, lerpTime)); } } public class TOD_LightAtNight : TOD_Light { public float fadeTime = 1f; private float lerpTime = 0f; private float maxIntensity; protected void Start() { maxIntensity = GetIntensity(); SetIntensity((!TOD_Sky.Instance.IsNight) ? 0f : maxIntensity); } protected void Update() { int num = (TOD_Sky.Instance.IsNight ? 1 : (-1)); lerpTime = Mathf.Clamp01(lerpTime + (float)num * Time.deltaTime / fadeTime); SetIntensity(Mathf.Lerp(0f, maxIntensity, lerpTime)); } } public class TOD_LightAtTime : TOD_Light { public AnimationCurve Intensity; public TOD_LightAtTime() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_005a: Unknown result type (might be due to invalid IL or missing references) AnimationCurve val = new AnimationCurve(); val.keys = (Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0f), new Keyframe(12f, 1f), new Keyframe(24f, 0f) }; Intensity = val; base..ctor(); } protected void Update() { SetIntensity(Intensity.Evaluate(TOD_Sky.Instance.Cycle.Hour)); } } public class TOD_LoadSkyFromFile : MonoBehaviour { public TOD_Sky sky; public TextAsset textAsset = null; protected void Start() { if (!Object.op_Implicit((Object)(object)sky)) { sky = TOD_Sky.Instance; } if (Object.op_Implicit((Object)(object)textAsset)) { sky.LoadParameters(textAsset.text); } } } public abstract class TOD_Particle : MonoBehaviour { private ParticleSystem particleComponent; protected float GetEmission() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)particleComponent)) { EmissionModule emission = particleComponent.emission; return ((EmissionModule)(ref emission)).rateOverTimeMultiplier; } return 0f; } protected void SetEmission(float value) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)particleComponent)) { EmissionModule emission = particleComponent.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = value; } } protected void Awake() { particleComponent = ((Component)this).GetComponent(); } } public class TOD_ParticleAtDay : TOD_Particle { public float fadeTime = 1f; private float lerpTime = 0f; private float maxEmission; protected void Start() { maxEmission = GetEmission(); SetEmission((!TOD_Sky.Instance.IsDay) ? 0f : maxEmission); } protected void Update() { int num = (TOD_Sky.Instance.IsDay ? 1 : (-1)); lerpTime = Mathf.Clamp01(lerpTime + (float)num * Time.deltaTime / fadeTime); SetEmission(Mathf.Lerp(0f, maxEmission, lerpTime)); } } public class TOD_ParticleAtNight : TOD_Particle { public float fadeTime = 1f; private float lerpTime = 0f; private float maxEmission; protected void Start() { maxEmission = GetEmission(); SetEmission((!TOD_Sky.Instance.IsNight) ? 0f : maxEmission); } protected void Update() { int num = (TOD_Sky.Instance.IsNight ? 1 : (-1)); lerpTime = Mathf.Clamp01(lerpTime + (float)num * Time.deltaTime / fadeTime); SetEmission(Mathf.Lerp(0f, maxEmission, lerpTime)); } } public class TOD_ParticleAtTime : TOD_Particle { public AnimationCurve Emission; public TOD_ParticleAtTime() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_005a: Unknown result type (might be due to invalid IL or missing references) AnimationCurve val = new AnimationCurve(); val.keys = (Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0f), new Keyframe(12f, 1f), new Keyframe(24f, 0f) }; Emission = val; base..ctor(); } protected void Update() { SetEmission(Emission.Evaluate(TOD_Sky.Instance.Cycle.Hour)); } } public abstract class TOD_Render : MonoBehaviour { private Renderer rendererComponent; protected void SetState(bool value) { if (Object.op_Implicit((Object)(object)rendererComponent)) { rendererComponent.enabled = value; } } protected void Awake() { rendererComponent = ((Component)this).GetComponent(); } } public class TOD_RenderAtDay : TOD_Render { protected void Start() { SetState(TOD_Sky.Instance.IsDay); } protected void Update() { SetState(TOD_Sky.Instance.IsDay); } } public class TOD_RenderAtNight : TOD_Render { protected void Start() { SetState(TOD_Sky.Instance.IsNight); } protected void Update() { SetState(TOD_Sky.Instance.IsNight); } } public class TOD_WeatherManager : MonoBehaviour { public enum RainType { None, Light, Heavy } public enum CloudType { None, Few, Scattered, Broken, Overcast } public enum AtmosphereType { Clear, Storm, Dust, Fog } public ParticleSystem RainParticleSystem = null; public float FadeTime = 10f; public RainType Rain = RainType.None; public CloudType Clouds = CloudType.None; public AtmosphereType Atmosphere = AtmosphereType.Clear; private float cloudOpacityMax; private float cloudBrightnessMax; private float atmosphereBrightnessMax; private float rainEmissionMax; private float cloudOpacity; private float cloudCoverage; private float cloudBrightness; private float atmosphereFog; private float atmosphereBrightness; private float rainEmission; private float GetRainEmission() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)RainParticleSystem)) { EmissionModule emission = RainParticleSystem.emission; return ((EmissionModule)(ref emission)).rateOverTimeMultiplier; } return 0f; } private void SetRainEmission(float value) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)RainParticleSystem)) { EmissionModule emission = RainParticleSystem.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = value; } } protected void Start() { TOD_Sky instance = TOD_Sky.Instance; cloudOpacity = instance.Clouds.Opacity; cloudCoverage = instance.Clouds.Coverage; cloudBrightness = instance.Clouds.Brightness; atmosphereFog = instance.Atmosphere.Fogginess; atmosphereBrightness = instance.Atmosphere.Brightness; rainEmission = GetRainEmission(); cloudOpacityMax = cloudOpacity; cloudBrightnessMax = cloudBrightness; atmosphereBrightnessMax = atmosphereBrightness; rainEmissionMax = rainEmission; } protected void Update() { TOD_Sky instance = TOD_Sky.Instance; switch (Rain) { case RainType.None: rainEmission = 0f; break; case RainType.Light: rainEmission = rainEmissionMax * 0.5f; break; case RainType.Heavy: rainEmission = rainEmissionMax; break; } switch (Clouds) { case CloudType.None: cloudOpacity = 0f; cloudCoverage = 0f; break; case CloudType.Few: cloudOpacity = cloudOpacityMax; cloudCoverage = 0.1f; break; case CloudType.Scattered: cloudOpacity = cloudOpacityMax; cloudCoverage = 0.3f; break; case CloudType.Broken: cloudOpacity = cloudOpacityMax; cloudCoverage = 0.6f; break; case CloudType.Overcast: cloudOpacity = cloudOpacityMax; cloudCoverage = 1f; break; } switch (Atmosphere) { case AtmosphereType.Clear: cloudBrightness = cloudBrightnessMax; atmosphereBrightness = atmosphereBrightnessMax; atmosphereFog = 0f; break; case AtmosphereType.Storm: cloudBrightness = cloudBrightnessMax * 0.3f; atmosphereBrightness = atmosphereBrightnessMax * 0.5f; atmosphereFog = 1f; break; case AtmosphereType.Dust: cloudBrightness = cloudBrightnessMax; atmosphereBrightness = atmosphereBrightnessMax; atmosphereFog = 0.5f; break; case AtmosphereType.Fog: cloudBrightness = cloudBrightnessMax; atmosphereBrightness = atmosphereBrightnessMax; atmosphereFog = 1f; break; } float num = ((!(FadeTime > 0f)) ? 1f : Mathf.Clamp01(Time.deltaTime / FadeTime)); instance.Clouds.Opacity = Mathf.Lerp(instance.Clouds.Opacity, cloudOpacity, num); instance.Clouds.Coverage = Mathf.Lerp(instance.Clouds.Coverage, cloudCoverage, num); instance.Clouds.Brightness = Mathf.Lerp(instance.Clouds.Brightness, cloudBrightness, num); instance.Atmosphere.Fogginess = Mathf.Lerp(instance.Atmosphere.Fogginess, atmosphereFog, num); instance.Atmosphere.Brightness = Mathf.Lerp(instance.Atmosphere.Brightness, atmosphereBrightness, num); SetRainEmission(Mathf.Lerp(GetRainEmission(), rainEmission, num)); } } public class TimeOfDayMenu : MonoBehaviour { public TOD_Time time; private TOD_Sky sky; [Range(0f, 2f)] private float nightLight = 0.1f; private bool progress = true; private float dayLength = 12f; private bool setTime = false; [Range(0f, 23f)] private int hour = 0; [Range(0f, 59f)] private int minute = 0; public Text timeText; public Text nightLightLevel; public Text dayLengthText; public GameObject progressTick; public bool affectReflection = true; private void Start() { if ((Object)(object)time == (Object)null) { time = ((Component)this).GetComponent(); } if ((Object)(object)time == (Object)null) { Debug.LogError((object)"TIME HAS NOT BEEN ASSIGNED ON THE TIME OF DAY MENU"); return; } sky = ((Component)time).GetComponent(); nightLight = sky.Night.LightIntensity; nightLightLevel.text = sky.Night.LightIntensity.ToString(); progress = time.ProgressTime; progressTick.SetActive(progress); dayLength = time.DayLengthInMinutes; dayLengthText.text = dayLength.ToString(); } private void Update() { if ((Object)(object)time == (Object)null || (Object)(object)timeText == (Object)null) { return; } if (affectReflection) { float num = 0f; if (sky.Cycle.Hour >= 0f && sky.Cycle.Hour < 5f) { num = 0f; } else if (sky.Cycle.Hour >= 5f && sky.Cycle.Hour < 6f) { num = Mathf.InverseLerp(5f, 6f, sky.Cycle.Hour); } else if (sky.Cycle.Hour >= 6f && sky.Cycle.Hour < 18f) { num = 1f; } else if (sky.Cycle.Hour >= 17f && sky.Cycle.Hour < 18f) { num = Mathf.InverseLerp(19f, 18f, sky.Cycle.Hour); } else if (sky.Cycle.Hour >= 18f && sky.Cycle.Hour < 24f) { num = 0f; } RenderSettings.reflectionIntensity = num; RenderSettings.ambientIntensity = num; } hour = Mathf.FloorToInt(sky.Cycle.Hour); minute = Mathf.FloorToInt(Mathf.Lerp(0f, 60f, sky.Cycle.Hour - (float)hour)); string text = ((minute >= 10) ? minute.ToString() : ("0" + minute)); string text2 = hour + ":" + text; timeText.text = text2; } public void AdjustHour(int amount) { hour += amount; if (hour < 0) { hour = 23; } else if (hour > 23) { hour = 0; } AdjustTime(Mathf.Clamp(hour, 0, 23), minute); } public void AdjustMinute(int amount) { minute += amount; if (minute < 0) { minute = 59; } else if (minute > 59) { minute = 0; } AdjustTime(hour, Mathf.Clamp(minute, 0, 59)); } private void AdjustTime(int hours, int minutes) { sky.Cycle.Hour = (float)hours + Mathf.InverseLerp(0f, 60f, (float)minutes); } public void AdjustNightIntensity(float amount) { sky.Night.LightIntensity = Mathf.Clamp(sky.Night.LightIntensity + amount, 0f, 4f); nightLightLevel.text = sky.Night.LightIntensity.ToString(); } public void AdjustDayLength(float amount) { dayLength = Mathf.Clamp(dayLength + amount, 1f, 1440f); dayLengthText.text = dayLength.ToString(); time.DayLengthInMinutes = dayLength; } public void ToggleProgress() { progress = !progress; progressTick.SetActive(progress); time.ProgressTime = progress; } }