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 UnityEditor; using UnityEngine; using UnityEngine.AI; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.SceneManagement; 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 Prometheuz.TGM_Atacama_Desert; [BepInPlugin("Prometheuz.TGM_Atacama_Desert", "TGM_Atacama_Desert", "1.0.0")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("nrgill28.Atlas", "1.0.1")] public class TGM_Atacama_DesertPlugin : 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(), "Prometheuz.TGM_Atacama_Desert"); AtlasPlugin.RegisterScene(Path.Combine(BasePath, "tgm_atacama_desert")); } } [RequireComponent(typeof(MeshFilter))] [RequireComponent(typeof(MeshRenderer))] public class MeshCombiner : MonoBehaviour { private const int Mesh16BitBufferVertexLimit = 65535; [SerializeField] private bool createMultiMaterialMesh = false; [SerializeField] private bool combineInactiveChildren = false; [SerializeField] private bool deactivateCombinedChildren = true; [SerializeField] private bool deactivateCombinedChildrenMeshRenderers = false; [SerializeField] private bool generateUVMap = false; [SerializeField] private bool destroyCombinedChildren = false; [SerializeField] private string folderPath = "Prefabs/CombinedMeshes"; [SerializeField] [Tooltip("MeshFilters with Meshes which we don't want to combine into one Mesh.")] private MeshFilter[] meshFiltersToSkip = (MeshFilter[])(object)new MeshFilter[0]; public bool CreateMultiMaterialMesh { get { return createMultiMaterialMesh; } set { createMultiMaterialMesh = value; } } public bool CombineInactiveChildren { get { return combineInactiveChildren; } set { combineInactiveChildren = value; } } public bool DeactivateCombinedChildren { get { return deactivateCombinedChildren; } set { deactivateCombinedChildren = value; CheckDeactivateCombinedChildren(); } } public bool DeactivateCombinedChildrenMeshRenderers { get { return deactivateCombinedChildrenMeshRenderers; } set { deactivateCombinedChildrenMeshRenderers = value; CheckDeactivateCombinedChildren(); } } public bool GenerateUVMap { get { return generateUVMap; } set { generateUVMap = value; } } public bool DestroyCombinedChildren { get { return destroyCombinedChildren; } set { destroyCombinedChildren = value; CheckDestroyCombinedChildren(); } } public string FolderPath { get { return folderPath; } set { folderPath = value; } } private void CheckDeactivateCombinedChildren() { if (deactivateCombinedChildren || deactivateCombinedChildrenMeshRenderers) { destroyCombinedChildren = false; } } private void CheckDestroyCombinedChildren() { if (destroyCombinedChildren) { deactivateCombinedChildren = false; deactivateCombinedChildrenMeshRenderers = false; } } public void CombineMeshes(bool showCreatedMeshInfo) { //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) //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_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_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_005d: 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_007d: 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_00bb: 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_00ed: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = ((Component)this).transform.localScale; int siblingIndex = ((Component)this).transform.GetSiblingIndex(); Transform parent = ((Component)this).transform.parent; ((Component)this).transform.parent = null; Quaternion rotation = ((Component)this).transform.rotation; Vector3 position = ((Component)this).transform.position; Vector3 localScale2 = ((Component)this).transform.localScale; ((Component)this).transform.rotation = Quaternion.identity; ((Component)this).transform.position = Vector3.zero; ((Component)this).transform.localScale = Vector3.one; if (!createMultiMaterialMesh) { CombineMeshesWithSingleMaterial(showCreatedMeshInfo); } else { CombineMeshesWithMutliMaterial(showCreatedMeshInfo); } ((Component)this).transform.rotation = rotation; ((Component)this).transform.position = position; ((Component)this).transform.localScale = localScale2; ((Component)this).transform.parent = parent; ((Component)this).transform.SetSiblingIndex(siblingIndex); ((Component)this).transform.localScale = localScale; } private MeshFilter[] GetMeshFiltersToCombine() { MeshFilter[] meshFilters = ((Component)this).GetComponentsInChildren(combineInactiveChildren); meshFiltersToSkip = meshFiltersToSkip.Where((MeshFilter meshFilter) => (Object)(object)meshFilter != (Object)(object)meshFilters[0]).ToArray(); meshFiltersToSkip = meshFiltersToSkip.Where((MeshFilter meshFilter) => (Object)(object)meshFilter != (Object)null).ToArray(); for (int i = 0; i < meshFiltersToSkip.Length; i++) { meshFilters = meshFilters.Where((MeshFilter meshFilter) => (Object)(object)meshFilter != (Object)(object)meshFiltersToSkip[i]).ToArray(); } return meshFilters; } private void CombineMeshesWithSingleMaterial(bool showCreatedMeshInfo) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown MeshFilter[] meshFiltersToCombine = GetMeshFiltersToCombine(); CombineInstance[] array = (CombineInstance[])(object)new CombineInstance[meshFiltersToCombine.Length - 1]; long num = 0L; for (int i = 0; i < meshFiltersToCombine.Length - 1; i++) { ((CombineInstance)(ref array[i])).subMeshIndex = 0; ((CombineInstance)(ref array[i])).mesh = meshFiltersToCombine[i + 1].sharedMesh; ((CombineInstance)(ref array[i])).transform = ((Component)meshFiltersToCombine[i + 1]).transform.localToWorldMatrix; num += ((CombineInstance)(ref array[i])).mesh.vertices.Length; } MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(combineInactiveChildren); if (componentsInChildren.Length >= 2) { ((Renderer)componentsInChildren[0]).sharedMaterials = (Material[])(object)new Material[1]; ((Renderer)componentsInChildren[0]).sharedMaterial = ((Renderer)componentsInChildren[1]).sharedMaterial; } else { ((Renderer)componentsInChildren[0]).sharedMaterials = (Material[])(object)new Material[0]; } Mesh val = new Mesh(); ((Object)val).name = ((Object)this).name; if (num <= 65535) { val.CombineMeshes(array); GenerateUV(val); meshFiltersToCombine[0].sharedMesh = val; DeactivateCombinedGameObjects(meshFiltersToCombine); if (showCreatedMeshInfo) { Debug.Log((object)("Mesh \"" + ((Object)this).name + "\" was created from " + array.Length + " children meshes and has " + num + " vertices.")); } } else if (showCreatedMeshInfo) { Debug.Log((object)("The mesh vertex limit is 65535! The created mesh had " + num + " vertices. Upgrade Unity version to 2017.3 or higher to avoid this limit (some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices).")); } } private void CombineMeshesWithMutliMaterial(bool showCreatedMeshInfo) { //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_0103: 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_013d: Unknown result type (might be due to invalid IL or missing references) MeshFilter[] meshFiltersToCombine = GetMeshFiltersToCombine(); MeshRenderer[] array = (MeshRenderer[])(object)new MeshRenderer[meshFiltersToCombine.Length]; array[0] = ((Component)this).GetComponent(); List list = new List(); for (int i = 0; i < meshFiltersToCombine.Length - 1; i++) { array[i + 1] = ((Component)meshFiltersToCombine[i + 1]).GetComponent(); if (!((Object)(object)array[i + 1] != (Object)null)) { continue; } Material[] sharedMaterials = ((Renderer)array[i + 1]).sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if (!list.Contains(sharedMaterials[j])) { list.Add(sharedMaterials[j]); } } } List list2 = new List(); long num = 0L; for (int k = 0; k < list.Count; k++) { List list3 = new List(); for (int l = 0; l < meshFiltersToCombine.Length - 1; l++) { if (!((Object)(object)array[l + 1] != (Object)null)) { continue; } Material[] sharedMaterials2 = ((Renderer)array[l + 1]).sharedMaterials; for (int m = 0; m < sharedMaterials2.Length; m++) { if ((Object)(object)list[k] == (Object)(object)sharedMaterials2[m]) { CombineInstance item = default(CombineInstance); ((CombineInstance)(ref item)).subMeshIndex = m; ((CombineInstance)(ref item)).mesh = meshFiltersToCombine[l + 1].sharedMesh; ((CombineInstance)(ref item)).transform = ((Component)meshFiltersToCombine[l + 1]).transform.localToWorldMatrix; list3.Add(item); num += ((CombineInstance)(ref item)).mesh.vertices.Length; } } } Mesh val = new Mesh(); if (num <= 65535) { val.CombineMeshes(list3.ToArray(), true); } CombineInstance item2 = default(CombineInstance); ((CombineInstance)(ref item2)).subMeshIndex = 0; ((CombineInstance)(ref item2)).mesh = val; ((CombineInstance)(ref item2)).transform = Matrix4x4.identity; list2.Add(item2); } ((Renderer)array[0]).sharedMaterials = list.ToArray(); Mesh val2 = new Mesh(); ((Object)val2).name = ((Object)this).name; if (num <= 65535) { val2.CombineMeshes(list2.ToArray(), false); GenerateUV(val2); meshFiltersToCombine[0].sharedMesh = val2; DeactivateCombinedGameObjects(meshFiltersToCombine); if (showCreatedMeshInfo) { Debug.Log((object)("Mesh \"" + ((Object)this).name + "\" was created from " + (meshFiltersToCombine.Length - 1) + " children meshes and has " + list2.Count + " submeshes, and " + num + " vertices.")); } } else if (showCreatedMeshInfo) { Debug.Log((object)("The mesh vertex limit is 65535! The created mesh had " + num + " vertices. Upgrade Unity version to 2017.3 or higher to avoid this limit (some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices).")); } } private void DeactivateCombinedGameObjects(MeshFilter[] meshFilters) { for (int i = 0; i < meshFilters.Length - 1; i++) { if (!destroyCombinedChildren) { if (deactivateCombinedChildren) { ((Component)meshFilters[i + 1]).gameObject.SetActive(false); } if (deactivateCombinedChildrenMeshRenderers) { MeshRenderer component = ((Component)meshFilters[i + 1]).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = false; } } } else { Object.DestroyImmediate((Object)(object)((Component)meshFilters[i + 1]).gameObject); } } } private void GenerateUV(Mesh combinedMesh) { //IL_000f: 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 (generateUVMap) { UnwrapParam val = default(UnwrapParam); UnwrapParam.SetDefaults(ref val); Unwrapping.GenerateSecondaryUVSet(combinedMesh, val); } } } public class NavMeshCleaner : MonoBehaviour { private class Tri { public int i1; public int i2; public int i3; public int min; public int max; public Tri(int i1, int i2, int i3) { this.i1 = i1; this.i2 = i2; this.i3 = i3; min = Mathf.Min(new int[3] { i1, i2, i3 }); max = Mathf.Max(new int[3] { i1, i2, i3 }); } } private class Edge { public int i1; public int i2; public Edge(int i1, int i2) { this.i1 = i1; this.i2 = i2; } } [CustomEditor(typeof(NavMeshCleaner))] public class NavMeshCleanerEditor : Editor { private static class Styles { private static Dictionary texture = new Dictionary(); public static GUIStyle Get(string id) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!texture.TryGetValue(id, out var value)) { value = new GUIStyle(GUIStyle.op_Implicit(id)); texture.Add(id, value); } return value; } } private NavMeshCleaner m_Target; private int m_OverPoint = -1; private static float kEpsilon = 1E-06f; private void OnEnable() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown m_Target = (NavMeshCleaner)(object)((Editor)this).target; Undo.undoRedoPerformed = (UndoRedoCallback)Delegate.Combine((Delegate?)(object)Undo.undoRedoPerformed, (Delegate?)new UndoRedoCallback(OnUndoOrRedo)); } private void OnDisable() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Undo.undoRedoPerformed = (UndoRedoCallback)Delegate.Remove((Delegate?)(object)Undo.undoRedoPerformed, (Delegate?)new UndoRedoCallback(OnUndoOrRedo)); } private void OnUndoOrRedo() { ((Editor)this).Repaint(); } public override void OnInspectorGUI() { //IL_007c: 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_00f2: 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_00d5: 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) EditorGUILayout.HelpBox((m_OverPoint == -1) ? "Press Control and click to add a walkable point." : "Press Control and click to remove the point.", (MessageType)((m_Target.m_WalkablePoint.Count != 0) ? 1 : 2)); ((Editor)this).OnInspectorGUI(); NavMeshCleaner navMeshCleaner = (NavMeshCleaner)(object)((Editor)this).target; if (navMeshCleaner.m_Child.Count > 0) { EditorGUI.BeginChangeCheck(); bool flag = EditorGUILayout.Toggle("Hide Temp Mesh Object In Hierarchy", ((((Object)navMeshCleaner.m_Child[0].gameObject).hideFlags & 1) != 0) ? true : false, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < navMeshCleaner.m_Child.Count; i++) { ((Object)navMeshCleaner.m_Child[i].gameObject).hideFlags = (HideFlags)((!flag) ? (((Object)navMeshCleaner.m_Child[i].gameObject).hideFlags & -2) : (((Object)navMeshCleaner.m_Child[i].gameObject).hideFlags | 1)); } try { EditorApplication.RepaintHierarchyWindow(); EditorApplication.DirtyHierarchyWindowSorting(); } catch { } } } if (GUILayout.Button((!navMeshCleaner.HasMesh()) ? "Calculate" : "Recalculate", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { navMeshCleaner.Build(); navMeshCleaner.SetMeshVisible(visible: true); SceneView.RepaintAll(); } if (navMeshCleaner.HasMesh() && GUILayout.Button((!navMeshCleaner.MeshVisible()) ? "Show Mesh" : "Hide Mesh", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { bool meshVisible = !navMeshCleaner.MeshVisible(); navMeshCleaner.SetMeshVisible(meshVisible); SceneView.RepaintAll(); } if (navMeshCleaner.HasMesh() && GUILayout.Button("Reset Mesh", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { navMeshCleaner.Reset(); SceneView.RepaintAll(); } if (navMeshCleaner.HasMesh() && GUILayout.Button("Reset WalkablePoints", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { Undo.RecordObject(((Editor)this).target, "reset"); m_Target.m_WalkablePoint.Clear(); SceneView.RepaintAll(); } } private void DrawDisc(Vector3 p, Vector3 n, float radius) { //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_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_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_0067: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[20]; Matrix4x4 val = Matrix4x4.TRS(p, Quaternion.LookRotation(n), Vector3.one * radius); for (int i = 0; i < 20; i++) { ref Vector3 reference = ref array[i]; reference = ((Matrix4x4)(ref val)).MultiplyPoint3x4(new Vector3(Mathf.Cos((float)Math.PI * 2f * (float)i / 19f), Mathf.Sin((float)Math.PI * 2f * (float)i / 19f), 0f)); } Handles.DrawAAPolyLine(array); } private void OnSceneGUI() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 //IL_0149: 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_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_004f: 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_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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Invalid comparison between Unknown and I4 //IL_008b: 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_0185: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Invalid comparison between Unknown and I4 //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Invalid comparison between Unknown and I4 //IL_0095: 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_00a8: 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_00aa: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Invalid comparison between Unknown and I4 SceneView currentDrawingSceneView = SceneView.currentDrawingSceneView; Event current = Event.current; if ((int)current.type == 7) { for (int i = 0; i < m_Target.m_WalkablePoint.Count; i++) { Vector3 val = ((Component)m_Target).transform.TransformPoint(m_Target.m_WalkablePoint[i]); float num = WorldSize(1f, currentDrawingSceneView.camera, val); Handles.color = Color.black; DrawDisc(val, Vector3.up, num * 15f); Handles.color = ((i != m_OverPoint) ? Color.green : Color.red); Handles.DrawSolidDisc(val, Vector3.up, num * 10f); Handles.DrawLine(val, val + Vector3.up * (num * 200f)); } } if ((int)current.type == 8 && current.control) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID((FocusType)2)); } if (current.control) { EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (MouseCursor)((m_OverPoint != -1) ? 12 : 11)); } if (((int)current.type == 0 || (int)current.type == 3 || (int)current.type == 2 || (int)current.type == 1) && current.button == 0) { MouseEvent(current.type, current.mousePosition, (int)current.modifiers == 2); } } private void MouseEvent(EventType type, Vector2 mouseposition, bool controldown) { //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_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_0010: Invalid comparison between Unknown and I4 //IL_00aa: 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_004e: 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_005e: 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_014d: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_0175: 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_0195: 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_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_0200: 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_021a: Unknown result type (might be due to invalid IL or missing references) SceneView currentDrawingSceneView = SceneView.currentDrawingSceneView; Ray val = HandleUtility.GUIPointToWorldRay(mouseposition); if ((int)type == 2) { int num = -1; for (int i = 0; i < m_Target.m_WalkablePoint.Count; i++) { Vector3 val2 = ((Component)m_Target).transform.TransformPoint(m_Target.m_WalkablePoint[i]); float num2 = WorldSize(10f, currentDrawingSceneView.camera, val2) * 1.5f; if (DistanceRayVsPoint(val, val2) < num2) { num = i; break; } } if (num != m_OverPoint) { m_OverPoint = num; HandleUtility.Repaint(); } } if ((int)type != 0 || !controldown) { return; } if (m_OverPoint != -1) { Undo.RecordObject((Object)(object)m_Target, "Remove Point"); m_Target.m_WalkablePoint.RemoveAt(m_OverPoint); m_OverPoint = -1; } else { float num3 = 1000f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val, ref val3, num3)) { Undo.RecordObject((Object)(object)m_Target, "Add Point"); m_Target.m_WalkablePoint.Add(((Component)m_Target).transform.InverseTransformPoint(((RaycastHit)(ref val3)).point)); } else { NavMeshTriangulation val4 = NavMesh.CalculateTriangulation(); Vector3[] vertices = val4.vertices; int[] indices = val4.indices; Vector3 outNormal = Vector3.up; for (int j = 0; j < indices.Length; j += 3) { num3 = IntersectTest(val, vertices[indices[j]], vertices[indices[j + 1]], vertices[indices[j + 2]], num3, ref outNormal); } if (num3 < 1000f) { Undo.RecordObject((Object)(object)m_Target, "Add Point"); Vector3 val5 = ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * num3; m_Target.m_WalkablePoint.Add(((Component)m_Target).transform.InverseTransformPoint(val5)); } } } HandleUtility.Repaint(); } private static float IntersectTest(Ray ray, Vector3 v0, Vector3 v1, Vector3 v2, float mint, ref Vector3 outNormal) { //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_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_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_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_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_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_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_0090: 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_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_00d0: 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_00f5: 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) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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) Vector3 val = v1 - v0; Vector3 val2 = v2 - v0; Vector3 val3 = Vector3.Cross(((Ray)(ref ray)).direction, val2); float num = Vector3.Dot(val, val3); if (num > 0f - kEpsilon && num < kEpsilon) { return mint; } float num2 = 1f / num; Vector3 val4 = ((Ray)(ref ray)).origin - v0; float num3 = num2 * Vector3.Dot(val4, val3); if (num3 < 0f || num3 > 1f) { return mint; } Vector3 val5 = Vector3.Cross(val4, val); float num4 = num2 * Vector3.Dot(((Ray)(ref ray)).direction, val5); if (num4 < 0f || num3 + num4 > 1f) { return mint; } float num5 = num2 * Vector3.Dot(val2, val5); if (num5 > kEpsilon && num5 < mint) { outNormal = Vector3.Normalize(Vector3.Cross(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized)); return num5; } return mint; } private static float WorldSize(float screensize, Camera camera, Vector3 p) { //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) if (!camera.orthographic) { Vector3 val = ((Component)camera).transform.InverseTransformPoint(p); float num = Mathf.Tan(camera.fieldOfView * ((float)Math.PI / 180f) * 0.5f) * val.z; return num * screensize / (float)camera.pixelHeight; } return camera.orthographicSize * screensize / (float)camera.pixelHeight; } private static float DistanceRayVsPoint(Ray mouseRay, Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_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_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_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) Vector3 val = pos - ((Ray)(ref mouseRay)).origin; return Mathf.Sqrt(Vector3.Dot(val, val) - Vector3.Dot(((Ray)(ref mouseRay)).direction, val) * Vector3.Dot(((Ray)(ref mouseRay)).direction, val)); } private static Vector3 IntersectPlane(Vector3 inNormal, Vector3 inPoint, Ray mouseRay) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_001b: 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_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_0036: 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_004b: 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) Plane val = default(Plane); ((Plane)(ref val))..ctor(inNormal, inPoint); float distanceToPoint = ((Plane)(ref val)).GetDistanceToPoint(((Ray)(ref mouseRay)).origin); return ((Ray)(ref mouseRay)).origin + ((Ray)(ref mouseRay)).direction * (distanceToPoint / Vector3.Dot(-((Plane)(ref val)).normal, ((Ray)(ref mouseRay)).direction)); } } public List m_WalkablePoint = new List(); public float m_Height = 1f; public float m_Offset = 0f; public int m_MidLayerCount = 3; private List m_Child = new List(); private void Awake() { SetMeshVisible(visible: false); } private void Reset() { Undo.RecordObject((Object)(object)this, "Reset"); for (int i = 0; i < m_Child.Count; i++) { Undo.DestroyObjectImmediate((Object)(object)m_Child[i]); } m_Child.Clear(); } private void SetMeshVisible(bool visible) { for (int i = 0; i < m_Child.Count; i++) { m_Child[i].SetActive(visible); } } public bool HasMesh() { return (m_Child.Count != 0) ? true : false; } public bool MeshVisible() { if (m_Child.Count > 0) { return m_Child[0].activeSelf; } return false; } private void Build() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0083: 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_00a3: 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_00ba: 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->IL011c: Incompatible stack types: O vs I4 //IL_0106->IL011c: Incompatible stack types: I4 vs O //IL_0106->IL011c: Incompatible stack types: O vs I4 Mesh[] array = CreateMesh(); Undo.RegisterCreatedObjectUndo((Object)(object)this, "build"); for (int i = 0; i < array.Length || i == 0; i++) { GameObject val; if (i >= m_Child.Count) { val = new GameObject(); ((Object)val).name = ((Object)((Component)this).gameObject).name + "_Mesh(DontSave)"; val.AddComponent(); MeshRenderer val2 = val.AddComponent(); ((Renderer)val2).sharedMaterial = AssetDatabase.GetBuiltinExtraResource("Default-Diffuse.mat"); val.transform.parent = ((Component)this).transform; val.transform.localScale = Vector3.one; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; GameObjectUtility.SetStaticEditorFlags(val, (StaticEditorFlags)(GameObjectUtility.GetStaticEditorFlags(((Component)this).gameObject) | 8)); GameObjectUtility.SetNavMeshArea(val, 1); m_Child.Add(val); Undo.RegisterCreatedObjectUndo((Object)(object)val, ""); } else { val = m_Child[i].gameObject; } object obj = val; int num; if (i == 0) { num = 53; obj = num; num = (int)obj; } else { obj = ((Object)m_Child[0].gameObject).hideFlags; num = (int)obj; } ((Object)num).hideFlags = (HideFlags)obj; MeshFilter component = m_Child[i].GetComponent(); Undo.RecordObject((Object)(object)component, "MeshUpdate"); component.sharedMesh = ((array.Length != 0) ? array[i] : null); } while (m_Child.Count > array.Length) { Undo.DestroyObjectImmediate((Object)(object)m_Child[m_Child.Count - 1]); m_Child.RemoveAt(m_Child.Count - 1); } } private static int Find(Vector3[] vtx, int left, int right, Vector3 v, float key) { //IL_0094: 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_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_0024: Unknown result type (might be due to invalid IL or missing references) int num = (left + right) / 2; if (num == left) { for (int i = left; i < vtx.Length && vtx[i].x <= key + 0.002f; i++) { if (Vector3.Magnitude(vtx[i] - v) <= 0.01f) { return i; } } return -1; } if (key <= vtx[num].x) { return Find(vtx, left, num, v, key); } return Find(vtx, num, right, v, key); } private static bool Find(Edge[] edge, int left, int right, int i1, int i2) { int num = (left + right) / 2; if (num == left) { for (int j = left; j < edge.Length && edge[j].i1 <= i1; j++) { if (edge[j].i1 == i1 && edge[j].i2 == i2) { return true; } } return false; } if (i1 <= edge[num].i1) { return Find(edge, left, num, i1, i2); } return Find(edge, num, right, i1, i2); } private Mesh[] CreateMesh() { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_0726: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0618: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0a2d: Unknown result type (might be due to invalid IL or missing references) //IL_0a32: Unknown result type (might be due to invalid IL or missing references) //IL_0a42: Unknown result type (might be due to invalid IL or missing references) //IL_0a47: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) //IL_0a5c: Unknown result type (might be due to invalid IL or missing references) //IL_0a5e: Unknown result type (might be due to invalid IL or missing references) //IL_0a63: Unknown result type (might be due to invalid IL or missing references) //IL_0a73: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a7a: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) NavMeshTriangulation val = NavMesh.CalculateTriangulation(); Vector3[] vertices = val.vertices; List list = new List(); list.AddRange(vertices); list.Sort((Vector3 v1, Vector3 v2) => (v1.x == v2.x) ? ((v1.z != v2.z) ? ((!(v1.z < v2.z)) ? 1 : (-1)) : 0) : ((!(v1.x < v2.x)) ? 1 : (-1))); Vector3[] vtx = list.ToArray(); int[] array = new int[val.vertices.Length]; for (int i = 0; i < array.Length; i++) { array[i] = Find(vtx, 0, list.Count, vertices[i], vertices[i].x - 0.001f); if (i % 100 == 0) { EditorUtility.DisplayProgressBar($"Export Nav-Mesh (Phase #1/3) {i}/{array.Length}", "Weld Vertex", Mathf.InverseLerp(0f, (float)array.Length, (float)i)); } } int[] indices = val.indices; List list2 = new List(); for (int j = 0; j < indices.Length; j += 3) { list2.Add(new Tri(array[indices[j]], array[indices[j + 1]], array[indices[j + 2]])); } list2.Sort((Tri t1, Tri t2) => (t1.min != t2.min) ? ((t1.min >= t2.min) ? 1 : (-1)) : 0); int[] array2 = new int[(list2.Count + 127) / 128]; int[] array3 = new int[array2.Length]; int num = 0; int num2 = 0; while (num < list2.Count) { int num3 = list2[num].min; int num4 = list2[num].max; for (int k = 1; k < 128 && num + k < list2.Count; k++) { num3 = Mathf.Min(list2[num + k].min, num3); num4 = Mathf.Max(list2[num + k].max, num4); } array2[num2] = num3; array3[num2] = num4; num += 128; num2++; } int[] array4 = new int[indices.Length]; for (int l = 0; l < array4.Length; l += 3) { array4[l] = list2[l / 3].i1; array4[l + 1] = list2[l / 3].i2; array4[l + 2] = list2[l / 3].i3; } List list3 = new List(); List list4 = new List(); int[] array5 = new int[array4.Length / 3]; for (int m = 0; m < array4.Length; m += 3) { int num5 = -1; int num6 = Mathf.Max(new int[3] { array4[m], array4[m + 1], array4[m + 2] }); int num7 = Mathf.Min(new int[3] { array4[m], array4[m + 1], array4[m + 2] }); int num8 = 0; int num9 = 0; while (num8 < m) { if (array2[num9] <= num6 && array3[num9] >= num7) { for (int n = num8; n < m && n < num8 + 384 && list2[n / 3].min <= num6; n += 3) { if (list2[n / 3].max < num7 || list3[array5[n / 3]] == num5) { continue; } for (int num10 = 0; num10 < 3; num10++) { int num11 = array4[n + num10]; if (array4[m] != num11 && array4[m + 1] != num11 && array4[m + 2] != num11) { continue; } if (num5 == -1) { num5 = list3[array5[n / 3]]; array5[m / 3] = num5; break; } int num12 = list3[array5[n / 3]]; for (int num13 = 0; num13 < list3.Count; num13++) { if (list3[num13] == num12) { list3[num13] = num5; } } break; } } } num8 += 384; num9++; } if (num5 == -1) { num5 = list3.Count; array5[m / 3] = num5; list3.Add(num5); list4.Add(0); } if (m / 3 % 100 == 0) { EditorUtility.DisplayProgressBar("Collect (Phase #2/3)", "Classification Group", Mathf.InverseLerp(0f, (float)array4.Length, (float)m)); } } for (int num14 = 0; num14 < array4.Length; num14 += 3) { array5[num14 / 3] = list3[array5[num14 / 3]]; list4[array5[num14 / 3]]++; } List list5 = new List(); List list6 = new List(); List list7 = new List(); int[] array6 = new int[list.Count]; for (int num15 = 0; num15 < array6.Length; num15++) { array6[num15] = -1; } Vector3[] points = m_WalkablePoint.ToArray(); for (int num16 = 0; num16 < list4.Count; num16++) { if (list4[num16] == 0) { continue; } List list8 = new List(); List list9 = new List(); for (int num17 = 0; num17 < array4.Length; num17 += 3) { if (array5[num17 / 3] != num16) { continue; } for (int num18 = 0; num18 < 3; num18++) { int num19 = array4[num17 + num18]; if (array6[num19] == -1) { array6[num19] = list8.Count; list8.Add(((Component)this).transform.InverseTransformPoint(list[num19] + Vector3.up * m_Offset)); } } list9.Add(array6[array4[num17]]); list9.Add(array6[array4[num17 + 1]]); list9.Add(array6[array4[num17 + 2]]); } if (Contains(list8.ToArray(), list9.ToArray(), points)) { continue; } int num20 = 32768; if (list6.Count > num20 || list6.Count + list8.Count * (2 + m_MidLayerCount) >= 65536) { list5.Add(CreateMesh(list6.ToArray(), list7.ToArray())); list6.Clear(); list7.Clear(); } Vector3 val2 = ((Component)this).transform.InverseTransformVector(Vector3.up * m_Height); int count = list6.Count; int num21 = 2 + m_MidLayerCount; for (int num22 = 0; num22 < list8.Count; num22++) { for (int num23 = 0; num23 < num21; num23++) { list6.Add(list8[num22] + val2 * ((float)num23 / (float)(num21 - 1))); } } for (int num24 = 0; num24 < list9.Count; num24 += 3) { for (int num25 = 0; num25 < num21; num25++) { if (num25 == 0) { list7.AddRange(new int[3] { count + list9[num24] * num21 + num25, count + list9[num24 + 2] * num21 + num25, count + list9[num24 + 1] * num21 + num25 }); } else { list7.AddRange(new int[3] { count + list9[num24] * num21 + num25, count + list9[num24 + 1] * num21 + num25, count + list9[num24 + 2] * num21 + num25 }); } } } if (m_Height > 0f) { List list10 = new List(); for (int num26 = 0; num26 < list9.Count; num26 += 3) { list10.Add(new Edge(list9[num26], list9[num26 + 1])); list10.Add(new Edge(list9[num26 + 1], list9[num26 + 2])); list10.Add(new Edge(list9[num26 + 2], list9[num26])); } list10.Sort((Edge e1, Edge e2) => (e1.i1 != e2.i1) ? ((e1.i1 >= e2.i1) ? 1 : (-1)) : 0); Edge[] edge = list10.ToArray(); for (int num27 = 0; num27 < list9.Count; num27 += 3) { int num28 = 2; int num29 = 0; while (num29 < 3) { int num30 = list9[num27 + num28]; int num31 = list9[num27 + num29]; if (!Find(edge, 0, list10.Count, num31, num30)) { if (list6.Count + 4 >= 65536) { list5.Add(CreateMesh(list6.ToArray(), list7.ToArray())); list6.Clear(); list7.Clear(); } list7.AddRange(new int[6] { list6.Count, list6.Count + 1, list6.Count + 3, list6.Count, list6.Count + 3, list6.Count + 2 }); list6.AddRange((IEnumerable)(object)new Vector3[4] { list8[num30], list8[num31], list8[num30] + val2, list8[num31] + val2 }); } num28 = num29++; } if (num27 % 600 == 0) { EditorUtility.DisplayProgressBar("Collect (Phase #3/3)", "Create Mesh", Mathf.InverseLerp(0f, (float)(list4.Count * 100), (float)(num16 * 100 + num27 * 100 / (num27 - list9.Count)))); } } } EditorUtility.DisplayProgressBar("Collect (Phase #3/3)", "Create Mesh", Mathf.InverseLerp(0f, (float)list4.Count, (float)num16)); } if (list6.Count > 0) { list5.Add(CreateMesh(list6.ToArray(), list7.ToArray())); } EditorUtility.ClearProgressBar(); return list5.ToArray(); } private static Mesh CreateMesh(Vector3[] vtx, int[] indices) { //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(); ((Object)val).hideFlags = (HideFlags)52; val.vertices = vtx; val.SetIndices(indices, (MeshTopology)0, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static bool Contains(Vector3[] vtx, int[] indices, Vector3[] points) { //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_0055: 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_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) foreach (Vector3 p in points) { for (int j = 0; j < indices.Length; j += 3) { if (indices[j] != indices[j + 1] && indices[j] != indices[j + 2] && indices[j + 1] != indices[j + 2] && PointInTriangle(vtx[indices[j]], vtx[indices[j + 2]], vtx[indices[j + 1]], p)) { return true; } } } return false; } private static bool PointInTriangle(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 p) { //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_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_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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0028: 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_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_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_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_005b: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(v3 - v1, v2 - v1); if (Vector3.Dot(Vector3.Cross(p - v1, v2 - v1), val) > 0f && Vector3.Dot(Vector3.Cross(p - v2, v3 - v2), val) > 0f && Vector3.Dot(Vector3.Cross(p - v3, v1 - v3), val) > 0f) { return true; } return false; } } public class OBJExporter : ScriptableWizard { public bool onlySelectedObjects = false; public bool applyPosition = true; public bool applyRotation = true; public bool applyScale = true; public bool generateMaterials = true; public bool exportTextures = true; public bool splitObjects = true; public bool autoMarkTexReadable = false; public bool objNameAddIdNum = false; private string versionString = "v2.0"; private string lastExportFolder; private bool StaticBatchingEnabled() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown PlayerSettings[] array = Resources.FindObjectsOfTypeAll(); if (array == null) { return false; } SerializedObject val = new SerializedObject((Object[])(object)array); SerializedProperty val2 = val.FindProperty("m_BuildTargetBatching"); for (int i = 0; i < val2.arraySize; i++) { SerializedProperty arrayElementAtIndex = val2.GetArrayElementAtIndex(i); if (arrayElementAtIndex == null) { continue; } IEnumerator enumerator = arrayElementAtIndex.GetEnumerator(); if (enumerator == null) { continue; } while (enumerator.MoveNext()) { SerializedProperty val3 = (SerializedProperty)enumerator.Current; if (val3 != null && val3.name == "m_StaticBatching") { return val3.boolValue; } } } return false; } private void OnWizardUpdate() { ((ScriptableWizard)this).helpString = "Aaro4130's OBJ Exporter " + versionString; } private Vector3 RotateAroundPoint(Vector3 point, Vector3 pivot, Quaternion angle) { //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_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_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_001a: Unknown result type (might be due to invalid IL or missing references) return angle * (point - pivot) + pivot; } private Vector3 MultiplyVec3s(Vector3 v1, Vector3 v2) { //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_0039: Unknown result type (might be due to invalid IL or missing references) return new Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); } private void OnWizardCreate() { if (StaticBatchingEnabled() && Application.isPlaying) { EditorUtility.DisplayDialog("Error", "Static batching is enabled. This will cause the export file to look like a mess, as well as be a large filesize. Disable this option, and restart the player, before continuing.", "OK"); return; } if (autoMarkTexReadable) { int num = EditorUtility.DisplayDialogComplex("Warning", "This will convert all textures to Advanced type with the read/write option set. This is not reversible and will permanently affect your project. Continue?", "Yes", "No", "Cancel"); if (num > 0) { return; } } string @string = EditorPrefs.GetString("a4_OBJExport_lastPath", ""); string string2 = EditorPrefs.GetString("a4_OBJExport_lastFile", "unityexport.obj"); string text = EditorUtility.SaveFilePanel("Export OBJ", @string, string2, "obj"); if (text.Length > 0) { FileInfo fileInfo = new FileInfo(text); EditorPrefs.SetString("a4_OBJExport_lastFile", fileInfo.Name); EditorPrefs.SetString("a4_OBJExport_lastPath", fileInfo.Directory.FullName); Export(text); } } private void Export(string exportPath) { //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //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_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034b: 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_035c: 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_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0384: 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_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: 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_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046b: 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_03b0: 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_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04af: 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_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); FileInfo fileInfo = new FileInfo(exportPath); lastExportFolder = fileInfo.Directory.FullName; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(exportPath); EditorUtility.DisplayProgressBar("Exporting OBJ", "Please wait.. Starting export.", 0f); MeshFilter[] array; if (onlySelectedObjects) { List list = new List(); GameObject[] gameObjects = Selection.gameObjects; foreach (GameObject val in gameObjects) { MeshFilter component = val.GetComponent(); if ((Object)(object)component != (Object)null) { list.Add(component); } } array = list.ToArray(); } else { array = Object.FindObjectsOfType(typeof(MeshFilter)) as MeshFilter[]; } if (Application.isPlaying) { MeshFilter[] array2 = array; foreach (MeshFilter val2 in array2) { MeshRenderer component2 = ((Component)val2).gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null && ((Renderer)component2).isPartOfStaticBatch) { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("Error", "Static batched object detected. Static batching is not compatible with this exporter. Please disable it before starting the player.", "OK"); return; } } } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder.AppendLine("# Export of " + Application.loadedLevelName); stringBuilder.AppendLine("# from Aaro4130 OBJ Exporter " + versionString); if (generateMaterials) { stringBuilder.AppendLine("mtllib " + fileNameWithoutExtension + ".mtl"); } float num = array.Length + 1; int num2 = 0; for (int k = 0; k < array.Length; k++) { string name = ((Object)((Component)array[k]).gameObject).name; float num3 = (float)(k + 1) / num; EditorUtility.DisplayProgressBar("Exporting objects... (" + Mathf.Round(num3 * 100f) + "%)", "Exporting object " + name, num3); MeshFilter val3 = array[k]; MeshRenderer component3 = ((Component)array[k]).gameObject.GetComponent(); if (splitObjects) { string text = name; if (objNameAddIdNum) { text = text + "_" + k; } stringBuilder.AppendLine("g " + text); } if ((Object)(object)component3 != (Object)null && generateMaterials) { Material[] sharedMaterials = ((Renderer)component3).sharedMaterials; foreach (Material val4 in sharedMaterials) { if (!dictionary.ContainsKey(((Object)val4).name)) { dictionary[((Object)val4).name] = true; stringBuilder2.Append(MaterialToString(val4)); stringBuilder2.AppendLine(); } } } Mesh sharedMesh = val3.sharedMesh; int num4 = (int)Mathf.Clamp(((Component)val3).gameObject.transform.lossyScale.x * ((Component)val3).gameObject.transform.lossyScale.z, -1f, 1f); Vector3[] vertices = sharedMesh.vertices; foreach (Vector3 val5 in vertices) { Vector3 val6 = val5; if (applyScale) { val6 = MultiplyVec3s(val6, ((Component)val3).gameObject.transform.lossyScale); } if (applyRotation) { val6 = RotateAroundPoint(val6, Vector3.zero, ((Component)val3).gameObject.transform.rotation); } if (applyPosition) { val6 += ((Component)val3).gameObject.transform.position; } val6.x *= -1f; stringBuilder.AppendLine("v " + val6.x + " " + val6.y + " " + val6.z); } Vector3[] normals = sharedMesh.normals; foreach (Vector3 val7 in normals) { Vector3 val8 = val7; if (applyScale) { Vector3 v = val8; Vector3 lossyScale = ((Component)val3).gameObject.transform.lossyScale; val8 = MultiplyVec3s(v, ((Vector3)(ref lossyScale)).normalized); } if (applyRotation) { val8 = RotateAroundPoint(val8, Vector3.zero, ((Component)val3).gameObject.transform.rotation); } val8.x *= -1f; stringBuilder.AppendLine("vn " + val8.x + " " + val8.y + " " + val8.z); } Vector2[] uv = sharedMesh.uv; for (int num5 = 0; num5 < uv.Length; num5++) { Vector2 val9 = uv[num5]; stringBuilder.AppendLine("vt " + val9.x + " " + val9.y); } for (int num6 = 0; num6 < sharedMesh.subMeshCount; num6++) { if ((Object)(object)component3 != (Object)null && num6 < ((Renderer)component3).sharedMaterials.Length) { string name2 = ((Object)((Renderer)component3).sharedMaterials[num6]).name; stringBuilder.AppendLine("usemtl " + name2); } else { stringBuilder.AppendLine("usemtl " + name + "_sm" + num6); } int[] triangles = sharedMesh.GetTriangles(num6); for (int num7 = 0; num7 < triangles.Length; num7 += 3) { int index = triangles[num7] + 1 + num2; int index2 = triangles[num7 + 1] + 1 + num2; int index3 = triangles[num7 + 2] + 1 + num2; if (num4 < 0) { stringBuilder.AppendLine("f " + ConstructOBJString(index) + " " + ConstructOBJString(index2) + " " + ConstructOBJString(index3)); } else { stringBuilder.AppendLine("f " + ConstructOBJString(index3) + " " + ConstructOBJString(index2) + " " + ConstructOBJString(index)); } } } num2 += sharedMesh.vertices.Length; } File.WriteAllText(exportPath, stringBuilder.ToString()); if (generateMaterials) { File.WriteAllText(fileInfo.Directory.FullName + "\\" + fileNameWithoutExtension + ".mtl", stringBuilder2.ToString()); } EditorUtility.ClearProgressBar(); } private string TryExportTexture(string propertyName, Material m) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (m.HasProperty(propertyName)) { Texture texture = m.GetTexture(propertyName); if ((Object)(object)texture != (Object)null) { return ExportTexture((Texture2D)texture); } } return "false"; } private string ExportTexture(Texture2D t) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown try { if (autoMarkTexReadable) { string assetPath = AssetDatabase.GetAssetPath((Object)(object)t); AssetImporter atPath = AssetImporter.GetAtPath(assetPath); TextureImporter val = (TextureImporter)(object)((atPath is TextureImporter) ? atPath : null); if ((Object)(object)val != (Object)null) { val.textureType = (TextureImporterType)0; if (!val.isReadable) { val.isReadable = true; AssetDatabase.ImportAsset(assetPath); AssetDatabase.Refresh(); } } } string text = lastExportFolder + "\\" + ((Object)t).name + ".png"; Texture2D val2 = new Texture2D(((Texture)t).width, ((Texture)t).height, (TextureFormat)5, false); val2.SetPixels(t.GetPixels()); File.WriteAllBytes(text, val2.EncodeToPNG()); return text; } catch (Exception) { Debug.Log((object)("Could not export texture : " + ((Object)t).name + ". is it readable?")); return "null"; } } private string ConstructOBJString(int index) { string text = index.ToString(); return text + "/" + text + "/" + text; } private string MaterialToString(Material m) { //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_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_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_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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0108: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("newmtl " + ((Object)m).name); if (m.HasProperty("_Color")) { stringBuilder.AppendLine("Kd " + m.color.r + " " + m.color.g + " " + m.color.b); if (m.color.a < 1f) { stringBuilder.AppendLine("Tr " + (1f - m.color.a)); stringBuilder.AppendLine("d " + m.color.a); } } if (m.HasProperty("_SpecColor")) { Color color = m.GetColor("_SpecColor"); stringBuilder.AppendLine("Ks " + color.r + " " + color.g + " " + color.b); } if (exportTextures) { string text = TryExportTexture("_MainTex", m); if (text != "false") { stringBuilder.AppendLine("map_Kd " + text); } text = TryExportTexture("_SpecMap", m); if (text != "false") { stringBuilder.AppendLine("map_Ks " + text); } text = TryExportTexture("_BumpMap", m); if (text != "false") { stringBuilder.AppendLine("map_Bump " + text); } } stringBuilder.AppendLine("illum 2"); return stringBuilder.ToString(); } [MenuItem("File/Export/Wavefront OBJ")] private static void CreateWizard() { ScriptableWizard.DisplayWizard("Export OBJ", typeof(OBJExporter), "Export"); } } public class CameraRange : MonoBehaviour { public float minDistance = 0.02f; public float maxDistance = 3500f; private Camera[] cameras; private GameObject[] dndObjects; private void Start() { ((MonoBehaviour)this).Invoke("DelayedStart", 5f); } private void DelayedStart() { dndObjects = GetDontDestroyOnLoadObjects(); cameras = Object.FindObjectsOfType(); for (int i = 0; i < cameras.Length; i++) { cameras[i].nearClipPlane = minDistance; cameras[i].farClipPlane = maxDistance; } if (dndObjects == null) { return; } for (int j = 0; j < dndObjects.Length; j++) { Camera component = dndObjects[j].GetComponent(); if ((Object)(object)component != (Object)null) { component.nearClipPlane = minDistance; component.farClipPlane = maxDistance; } } } public static GameObject[] GetDontDestroyOnLoadObjects() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //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) GameObject val = null; try { val = new GameObject(); Object.DontDestroyOnLoad((Object)(object)val); Scene scene = val.scene; Object.DestroyImmediate((Object)(object)val); val = null; return ((Scene)(ref scene)).GetRootGameObjects(); } finally { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } } } public class FollowTargetDebug : MonoBehaviour { private bool check; private void OnLevelWasLoaded() { Debug.Log((object)("OnLevelWasLoaded, player head exists: " + GM.CurrentPlayerBody != null)); } private void Awake() { Debug.Log((object)("OnAwake, player head exists: " + GM.CurrentPlayerBody != null)); } private void Start() { Debug.Log((object)("Start, player head exists: " + GM.CurrentPlayerBody != null)); } private void Update() { if (!check) { Debug.Log((object)("Update, player head exists: " + GM.CurrentPlayerBody != null)); } check = true; } } public class RealtimeReflection : MonoBehaviour { public ReflectionProbe probe; public float frameRate = 24f; protected float nextUpdate = 0f; private void Start() { probe.mode = (ReflectionProbeMode)1; probe.refreshMode = (ReflectionProbeRefreshMode)2; } private void Update() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (nextUpdate <= Time.time) { ((Component)probe).transform.position = GM.CurrentPlayerBody.Head.position; nextUpdate = Time.time + 1f / frameRate; probe.RenderProbe(); } } } 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; } } 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; } }