using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Il2CppInterop.Runtime.InteropTypes.Arrays; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using WeatherGB; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(WeatherMod), "WeatherGB", "1.0.0", "Zooks", null)] [assembly: MelonGame("Boneloaf", "Gang Beasts")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Zooks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WeatherGB")] [assembly: AssemblyTitle("WeatherGB")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace WeatherGB { public class WeatherMod : MelonMod { private static WeatherController _controller; public override void OnInitializeMelon() { ((MelonBase)this).LoggerInstance.Msg("Loaded WeatherGB"); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (_controller != null) { _controller.Destroy(); _controller = null; } string text = sceneName.ToLower(); WeatherType weatherType = WeatherType.None; if (text.Contains("buoy") || text.Contains("trawler")) { weatherType = WeatherType.Snow; } else if (text.Contains("roof") || text.Contains("blimp") || text.Contains("menu") || text.Contains("customization") || text.Contains("lighthouse") || text.Contains("truck") || text.Contains("meat") || text.Contains("containers") || text.Contains("tower") || text.Contains("girders")) { weatherType = WeatherType.Rain; } else if (text.Contains("incinerator")) { weatherType = WeatherType.Ash; } else if (text.Contains("alley") || text.Contains("wheel") || text.Contains("gondola") || text.Contains("billboard") || text.Contains("elevator") || text.Contains("train")) { weatherType = ((Random.value <= 0.5f) ? WeatherType.Rain : WeatherType.Snow); } switch (weatherType) { case WeatherType.Rain: if (!text.Contains("blimp") && !text.Contains("truck") && !text.Contains("meat") && !text.Contains("menu") && !text.Contains("alley") && !text.Contains("wheel") && !text.Contains("gondola") && !text.Contains("billboard") && !text.Contains("elevator") && !text.Contains("train") && Random.value <= 0.2f) { weatherType = WeatherType.Snow; } break; case WeatherType.None: return; } bool flag = Random.value <= 0.4f; if (text.Contains("blimp") || text.Contains("truck") || text.Contains("meat") || text.Contains("alley") || text.Contains("menu") || text.Contains("billboard") || text.Contains("elevator") || text.Contains("train")) { flag = true; } if (text.Contains("menu") || text.Contains("customization")) { weatherType = WeatherType.Rain; flag = true; } _controller = new WeatherController(weatherType, flag); ((MelonBase)this).LoggerInstance.Msg($"[WeatherGB] Spawned {weatherType} weather {(flag ? "(Night)" : "(Day)")} for {sceneName}"); } public override void OnUpdate() { if (_controller != null) { _controller.Update(Time.deltaTime); } } } public enum WeatherType { None, Rain, Snow, Ash } public class WeatherController { private readonly WeatherType _type; private readonly List _particles = new List(); private readonly List _fogBillows = new List(); private readonly List _splashes = new List(); private Camera _mainCamera; private Texture2D _softCircleTex; private readonly List _directionalLights = new List(); private readonly Dictionary _originalIntensities = new Dictionary(); private float _originalLightIntensity = 1f; private Color _originalAmbientColor; private bool _lightsCached; private int _thunderState; private float _flashTimer; private readonly bool _isNight; private AudioSource _weatherAudioSource; private AudioSource _thunderAudioSource; private AudioClip _weatherClip; private AudioClip _thunderClip; private float _slowUpdateTimer; private float _nextThunderTime; private float _rainSpeed; private float _rainThickness; private float _rainLongness; public WeatherController(WeatherType type, bool isNight) { //IL_00c7: 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) _type = type; _isNight = isNight; _nextThunderTime = Time.time + Random.Range(15f, 30f); _mainCamera = Camera.main; _softCircleTex = CreateSoftCircleTexture(); _rainSpeed = 48f; _rainThickness = 0.08f; _rainLongness = 1.5f; FindDirectionalLights(); ApplyGlossiness(); ApplyAtmosphericSettings(); SetupAudio(); int num = 1800; Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLower(); if (_type == WeatherType.Snow) { num = (int)((float)num * 1.65f); } else if (_type == WeatherType.Rain) { num = (int)((float)num * 1.25f); } if (text.Contains("buoy")) { num = Math.Max(num, 1100); } for (int i = 0; i < num; i++) { GameObject val = CreateParticle(); if ((Object)(object)val != (Object)null) { _particles.Add(val); } } int num2 = ((_type == WeatherType.Snow) ? 14 : 9); for (int j = 0; j < num2; j++) { GameObject val2 = CreateFogBillow(); if ((Object)(object)val2 != (Object)null) { _fogBillows.Add(val2); } } SpawnHeadlights(); } private Texture2D CreateSoftCircleTexture() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0024: 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_006b: Unknown result type (might be due to invalid IL or missing references) int num = 64; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); float num2 = (float)num / 2f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)); float num4 = Mathf.Clamp01(1f - num3 / num2); num4 = Mathf.Pow(num4, 2.5f); val.SetPixel(j, i, new Color(1f, 1f, 1f, num4)); } } val.Apply(); return val; } private void FindDirectionalLights() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //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) foreach (Light item in Object.FindObjectsOfType()) { if ((Object)(object)item != (Object)null && (int)item.type == 1) { if (!_directionalLights.Contains(item)) { _directionalLights.Add(item); } if (!_originalIntensities.ContainsKey(item)) { _originalIntensities[item] = item.intensity; _originalLightIntensity = item.intensity; } } } if (!_lightsCached) { _originalAmbientColor = RenderSettings.ambientLight; _lightsCached = true; } } private void ApplyEveningLighting() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) foreach (Light directionalLight in _directionalLights) { if (!((Object)(object)directionalLight == (Object)null)) { directionalLight.intensity = 0.55f; directionalLight.color = new Color(0.95f, 0.48f, 0.28f); } } RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.35f, 0.18f, 0.25f); RenderSettings.ambientIntensity = 0.65f; RenderSettings.reflectionIntensity = 0.55f; } private void ApplyNightLighting() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_012c: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLower(); bool flag = text.Contains("blimp"); bool flag2 = text.Contains("menu") || text.Contains("customization"); bool flag3 = text.Contains("alley"); foreach (Light directionalLight in _directionalLights) { if (!((Object)(object)directionalLight == (Object)null)) { if (flag || flag2 || flag3) { directionalLight.intensity = 0.85f; directionalLight.color = new Color(0.25f, 0.35f, 0.68f); } else { directionalLight.intensity = 0.38f; directionalLight.color = new Color(0.18f, 0.25f, 0.5f); } } } RenderSettings.ambientMode = (AmbientMode)3; if (flag || flag2 || flag3) { RenderSettings.ambientLight = new Color(0.18f, 0.22f, 0.38f); RenderSettings.ambientIntensity = 0.75f; RenderSettings.reflectionIntensity = 0.65f; if (flag) { RenderSettings.fog = true; RenderSettings.fogColor = new Color(0.05f, 0.12f, 0.28f); RenderSettings.fogDensity = 0.04f; RenderSettings.fogMode = (FogMode)2; } } else { RenderSettings.ambientLight = new Color(0.12f, 0.14f, 0.28f); RenderSettings.ambientIntensity = 0.45f; RenderSettings.reflectionIntensity = 0.4f; } } private void ApplyGlossiness() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLower(); bool flag = text.Contains("roof"); bool flag2 = text.Contains("trawler"); bool flag3 = text.Contains("lighthouse"); if (!flag && !flag2 && !flag3) { return; } foreach (MeshRenderer item in Object.FindObjectsOfType()) { if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).gameObject == (Object)null) { continue; } bool flag4 = false; Transform val = ((Component)item).transform; while ((Object)(object)val != (Object)null) { string text2 = ((Object)((Component)val).gameObject).name.ToLower(); if (text2.Contains("actor") || text2.Contains("ragdoll") || text2.Contains("player") || text2.Contains("costume")) { flag4 = true; break; } val = val.parent; } if (flag4) { continue; } Il2CppReferenceArray materials = ((Renderer)item).materials; if (materials == null) { continue; } foreach (Material item2 in (Il2CppArrayBase)(object)materials) { if (!((Object)(object)item2 == (Object)null)) { float num = 0.96f; if (_type == WeatherType.Snow) { num = 0.05f; } else if (_type == WeatherType.Ash) { num = 0.2f; } if (item2.HasProperty("_Glossiness")) { item2.SetFloat("_Glossiness", num); } if (item2.HasProperty("_Smoothness")) { item2.SetFloat("_Smoothness", num); } if (item2.HasProperty("_GlossMapScale")) { item2.SetFloat("_GlossMapScale", num); } if (item2.HasProperty("_Metallic")) { item2.SetFloat("_Metallic", (_type == WeatherType.Rain) ? 0.2f : 0f); } if (item2.HasProperty("_Roughness")) { item2.SetFloat("_Roughness", 1f - num); } item2.EnableKeyword("_GLOSSYREFLECTIONS_ON"); item2.EnableKeyword("_SPECULARHIGHLIGHTS_ON"); } } } } private void ApplyAtmosphericSettings() { RenderSettings.ambientMode = (AmbientMode)3; try { foreach (Component item in Object.FindObjectsOfType()) { if ((Object)(object)item == (Object)null) { continue; } string fullName = ((object)item).GetType().FullName; if (!fullName.Contains("UnityEngine.Rendering.Volume") && !fullName.Contains("PostProcessVolume")) { continue; } PropertyInfo propertyInfo = ((object)item).GetType().GetProperty("profile") ?? ((object)item).GetType().GetProperty("sharedProfile"); if (propertyInfo == null) { continue; } object value = propertyInfo.GetValue(item); if (value == null) { continue; } FieldInfo fieldInfo = value.GetType().GetField("components", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? value.GetType().GetField("settings", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo == null || !(fieldInfo.GetValue(value) is IList list)) { continue; } foreach (object item2 in list) { if (item2 == null) { continue; } string name = item2.GetType().Name; if (name.Contains("Vignette")) { FieldInfo field = item2.GetType().GetField("intensity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value2 = field.GetValue(item2); PropertyInfo property = value2.GetType().GetProperty("value"); PropertyInfo property2 = value2.GetType().GetProperty("overrideState"); if (property != null) { property.SetValue(value2, 0.45f); } if (property2 != null) { property2.SetValue(value2, true); } } } else { if (!name.Contains("ChromaticAberration")) { continue; } FieldInfo field2 = item2.GetType().GetField("intensity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { object value3 = field2.GetValue(item2); PropertyInfo property3 = value3.GetType().GetProperty("value"); PropertyInfo property4 = value3.GetType().GetProperty("overrideState"); if (property3 != null) { property3.SetValue(value3, 0.6f); } if (property4 != null) { property4.SetValue(value3, true); } } } } } } catch (Exception ex) { MelonLogger.Warning("[WeatherGB] Post-processing adjustment skipped: " + ex.Message); } } private void SpawnHeadlights() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_00cd: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLower(); if (!text.Contains("truck") && !text.Contains("meat")) { return; } foreach (GameObject item in Object.FindObjectsOfType()) { if (!((Object)(object)item == (Object)null)) { string text2 = ((Object)item).name.ToLower(); if ((text2 == "cab" || text2 == "truck") && (Object)(object)item.transform.Find("WeatherHeadlightL") == (Object)null) { CreateHeadlight(item.transform, new Vector3(-1.1f, 0.8f, 2.8f), "WeatherHeadlightL"); CreateHeadlight(item.transform, new Vector3(1.1f, 0.8f, 2.8f), "WeatherHeadlightR"); } } } } private void CreateHeadlight(Transform parent, Vector3 localPos, string name) { //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_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_001e: 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_004a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.parent = parent; val.transform.localPosition = localPos; val.transform.localRotation = Quaternion.Euler(15f, 0f, 0f); Light obj = val.AddComponent(); obj.type = (LightType)0; obj.color = Color.white; obj.intensity = 18f; obj.range = 50f; obj.spotAngle = 50f; } private void SetupAudio() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("WeatherAudioHost"); _weatherAudioSource = val.AddComponent(); _thunderAudioSource = val.AddComponent(); _weatherAudioSource.spatialBlend = 0f; _thunderAudioSource.spatialBlend = 0f; string path = Path.Combine(Application.dataPath, "..", "Mods"); if (_type != WeatherType.Ash) { string path2 = ((_type == WeatherType.Snow) ? "snowloop.wav" : "rainloop.wav"); string filePath = Path.Combine(path, path2); _weatherClip = LoadWavFromFile(filePath); if ((Object)(object)_weatherClip != (Object)null) { _weatherAudioSource.clip = _weatherClip; _weatherAudioSource.loop = true; _weatherAudioSource.volume = 0.45f; _weatherAudioSource.Play(); } } string filePath2 = Path.Combine(path, "thunder.wav"); _thunderClip = LoadWavFromFile(filePath2); if ((Object)(object)_thunderClip == (Object)null) { MelonLogger.Warning("[WeatherGB] thunder.wav not found in Mods folder. Thunder sound disabled."); } } private AudioClip LoadWavFromFile(string filePath) { if (!File.Exists(filePath)) { return null; } try { byte[] array = File.ReadAllBytes(filePath); string text = Encoding.ASCII.GetString(array, 0, 4); string text2 = Encoding.ASCII.GetString(array, 8, 4); if (text != "RIFF" || text2 != "WAVE") { MelonLogger.Error("[WeatherGB] Invalid WAV header in " + Path.GetFileName(filePath)); return null; } int num = 12; int num2 = -1; int num3 = -1; uint num4 = 0u; while (num < array.Length - 8) { string text3 = Encoding.ASCII.GetString(array, num, 4); uint num5 = BitConverter.ToUInt32(array, num + 4); if (text3 == "fmt ") { num2 = num + 8; } else if (text3 == "data") { num3 = num + 8; num4 = num5; break; } num += (int)(8 + num5); if (num5 % 2 != 0) { num++; } } if (num2 == -1 || num3 == -1) { MelonLogger.Error("[WeatherGB] Failed to locate critical chunks in " + Path.GetFileName(filePath)); return null; } ushort num6 = BitConverter.ToUInt16(array, num2); ushort num7 = BitConverter.ToUInt16(array, num2 + 2); uint num8 = BitConverter.ToUInt32(array, num2 + 4); ushort num9 = BitConverter.ToUInt16(array, num2 + 14); int num10 = num9 / 8; int num11 = (int)(num4 / num10); float[] array2 = new float[num11]; int num12 = num3; for (int i = 0; i < num11; i++) { if (num12 + num10 > array.Length) { break; } float num13 = 0f; switch (num6) { case 1: switch (num9) { case 8: num13 = ((float)(int)array[num12] - 128f) / 128f; break; case 16: num13 = (float)BitConverter.ToInt16(array, num12) / 32768f; break; case 24: { int num14 = array[num12] | (array[num12 + 1] << 8) | (array[num12 + 2] << 16); if ((num14 & 0x800000) != 0) { num14 |= -16777216; } num13 = (float)num14 / 8388608f; break; } case 32: num13 = (float)BitConverter.ToInt32(array, num12) / 2.1474836E+09f; break; } break; case 3: if (num9 == 32) { num13 = BitConverter.ToSingle(array, num12); } break; } array2[i] = Mathf.Clamp(num13, -1f, 1f); num12 += num10; } AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(filePath), num11 / num7, (int)num7, (int)num8, false); obj.SetData(Il2CppStructArray.op_Implicit(array2), 0); return obj; } catch (Exception ex) { MelonLogger.Error("[WeatherGB] Failed parsing WAV " + Path.GetFileName(filePath) + ": " + ex.Message); return null; } } private GameObject CreateParticle() { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_0093: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); Collider component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Material material = ((Renderer)component2).material; material.shader = Shader.Find("Sprites/Default"); material.mainTexture = (Texture)(object)_softCircleTex; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; if (_type == WeatherType.Snow) { material.color = new Color(1f, 1f, 1f, 0.9f); val.transform.localScale = Vector3.one * Random.Range(0.25f, 0.5f); } else if (_type == WeatherType.Rain) { material.color = new Color(0.7f, 0.85f, 1f, 0.65f); val.transform.localScale = new Vector3(_rainThickness, Random.Range(1.8f, 3.2f) * _rainLongness, _rainThickness); } else { material.color = new Color(0.95f, 0.42f, 0.12f, 0.65f); val.transform.localScale = Vector3.one * Random.Range(0.08f, 0.18f); } } ResetParticle(val, Vector3.zero); Vector3 position = val.transform.position; position.y = Random.Range(GetCameraY() - 15f, GetCameraY() + 35f); val.transform.position = position; return val; } private GameObject CreateFogBillow() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00fe: 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) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = "FogBillow"; Collider component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Material material = ((Renderer)component2).material; material.shader = Shader.Find("Sprites/Default"); material.mainTexture = (Texture)(object)_softCircleTex; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; if (_type == WeatherType.Snow) { material.color = new Color(0.9f, 0.82f, 0.85f, 0.15f); } else if (_isNight) { material.color = new Color(0.02f, 0.03f, 0.08f, 0.22f); } else if (_type == WeatherType.Rain) { material.color = new Color(0.08f, 0.12f, 0.22f, 0.15f); } else { material.color = new Color(0.12f, 0.08f, 0.06f, 0.16f); } } val.transform.localScale = Vector3.one * Random.Range(22f, 42f); ResetFogPosition(val); return val; } private float GetCameraY() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_mainCamera == (Object)null) { _mainCamera = Camera.main; } if (!((Object)(object)_mainCamera != (Object)null)) { return 15f; } return ((Component)_mainCamera).transform.position.y; } private void GetCameraFocusAndSize(out Vector3 focusPoint, out float radiusX, out float radiusZ, out float minY, out float maxY) { //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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_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_00eb: 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) focusPoint = Vector3.zero; radiusX = 35f; radiusZ = 35f; minY = -15f; maxY = 35f; if ((Object)(object)_mainCamera == (Object)null) { _mainCamera = Camera.main; } if (!((Object)(object)_mainCamera == (Object)null)) { Vector3 position = ((Component)_mainCamera).transform.position; Ray val = _mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); Plane val2 = default(Plane); ((Plane)(ref val2))..ctor(Vector3.up, new Vector3(0f, position.y - 15f, 0f)); float num = default(float); if (((Plane)(ref val2)).Raycast(val, ref num)) { focusPoint = ((Ray)(ref val)).GetPoint(num); } else { focusPoint = position + ((Component)_mainCamera).transform.forward * 35f; } float num2 = Mathf.Clamp(Vector3.Distance(position, focusPoint), 10f, 150f); float num3 = _mainCamera.fieldOfView * ((float)Math.PI / 180f); float num4 = num2 * Mathf.Tan(num3 * 0.5f); float num5 = num4 * _mainCamera.aspect; radiusX = num5 * 1.8f; radiusZ = num4 * 2f; minY = (0f - num4) * 1.8f; maxY = num4 * 2.5f; } } private void ResetParticle(GameObject p, Vector3 camPos) { //IL_0034: 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) GetCameraFocusAndSize(out var focusPoint, out var radiusX, out var radiusZ, out var minY, out var maxY); float num = Random.Range(0f - radiusX, radiusX); float num2 = Random.Range(0f - radiusZ, radiusZ); float num3 = Random.Range(minY, maxY); p.transform.position = focusPoint + new Vector3(num, num3, num2); } private void DestroyGameObject(GameObject go) { if ((Object)(object)go == (Object)null) { return; } try { MeshRenderer component = go.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null) { Object.Destroy((Object)(object)((Renderer)component).material); } } catch (Exception) { } Object.Destroy((Object)(object)go); } private void TriggerSplash(Vector3 hitPoint) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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) Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLower(); if (_type == WeatherType.Snow && text.Contains("girders")) { return; } if (_splashes.Count >= 75) { Splash splash = _splashes[0]; if ((Object)(object)splash.GameObject != (Object)null) { DestroyGameObject(splash.GameObject); } _splashes.RemoveAt(0); } GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); val.transform.position = hitPoint + new Vector3(0f, 0.08f, 0f); val.transform.rotation = Quaternion.Euler(90f, Random.Range(0f, 360f), 0f); Object.Destroy((Object)(object)val.GetComponent()); MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Material material = ((Renderer)component).material; material.shader = Shader.Find("Sprites/Default"); material.mainTexture = (Texture)(object)_softCircleTex; material.color = ((_type == WeatherType.Snow) ? new Color(1f, 1f, 1f, 0.7f) : new Color(0.8f, 0.9f, 1f, 0.65f)); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; } val.transform.localScale = Vector3.one * 0.1f; float num = 1.6f; _splashes.Add(new Splash { GameObject = val, StartScale = Vector3.one * Random.Range(1.8f, 3.2f) * num, Life = 0.25f, MaxLife = 0.25f }); } private void ResetFogPosition(GameObject f) { //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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_mainCamera == (Object)null) { _mainCamera = Camera.main; } if (!((Object)(object)_mainCamera == (Object)null)) { Vector3 position = ((Component)_mainCamera).transform.position; float num = Random.Range(-40f, 40f); float num2 = Random.Range(-40f, 40f); float num3 = Random.Range(-5f, 15f); f.transform.position = position + new Vector3(num, num3, num2); f.transform.rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); } } public void Update(float dt) { //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_00a0: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0239: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0380: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_mainCamera == (Object)null) { _mainCamera = Camera.main; } if ((Object)(object)_mainCamera == (Object)null) { return; } Vector3 position = ((Component)_mainCamera).transform.position; _slowUpdateTimer += dt; if (_slowUpdateTimer >= 1f) { _slowUpdateTimer = 0f; FindDirectionalLights(); ApplyGlossiness(); SpawnHeadlights(); } if (_type == WeatherType.Snow) { ApplyEveningLighting(); } else if (_isNight) { ApplyNightLighting(); } GetCameraFocusAndSize(out var focusPoint, out var _, out var _, out var minY, out var _); float num = focusPoint.y - 120f; float num2 = focusPoint.y + minY + 5f; RaycastHit val3 = default(RaycastHit); foreach (GameObject particle in _particles) { if ((Object)(object)particle == (Object)null) { continue; } Vector3 position2 = particle.transform.position; Vector3 val = position2; if (_type == WeatherType.Snow) { float num3 = 2.4f; float num4 = 1.5f; float num5 = position2.y * 0.08f + position2.z * 0.05f; val.y -= 3.2f * dt; val.x += Mathf.Sin(Time.time * num3 + num5) * num4 * dt; } else if (_type == WeatherType.Rain) { val.y -= _rainSpeed * dt; val += ((Component)_mainCamera).transform.right * 7.5f * dt; } else { val.y -= 1.6f * dt; val.x += Mathf.Sin(Time.time * 0.4f) * 0.8f * dt; } particle.transform.LookAt(position); if (_type == WeatherType.Rain) { float num6 = Mathf.Atan2(7.5f, 0f - _rainSpeed) * 57.29578f; particle.transform.Rotate(Vector3.forward, 0f - num6); } bool flag = false; if (_type == WeatherType.Rain || _type == WeatherType.Snow) { Vector3 val2 = val - position2; if (Physics.Raycast(position2, ((Vector3)(ref val2)).normalized, ref val3, ((Vector3)(ref val2)).magnitude + 0.5f, -5, (QueryTriggerInteraction)1)) { TriggerSplash(((RaycastHit)(ref val3)).point); flag = true; } } if (flag || val.y < num || val.y < num2) { ResetParticle(particle, position); } else { particle.transform.position = val; } } for (int num7 = _splashes.Count - 1; num7 >= 0; num7--) { Splash splash = _splashes[num7]; if (splash != null) { splash.Life -= dt; if (splash.Life <= 0f || (Object)(object)splash.GameObject == (Object)null) { if ((Object)(object)splash.GameObject != (Object)null) { DestroyGameObject(splash.GameObject); } _splashes.RemoveAt(num7); } else { float num8 = 1f - splash.Life / splash.MaxLife; splash.GameObject.transform.localScale = Vector3.Lerp(Vector3.one * 0.1f, splash.StartScale, num8); MeshRenderer component = splash.GameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Color color = ((Renderer)component).material.color; color.a = Mathf.Lerp(0.45f, 0f, num8); ((Renderer)component).material.color = color; } } } } foreach (GameObject fogBillow in _fogBillows) { if (!((Object)(object)fogBillow == (Object)null)) { Vector3 position3 = fogBillow.transform.position; position3.x += 0.4f * dt; fogBillow.transform.position = position3; fogBillow.transform.LookAt(position); if (Vector3.Distance(position3, position) > 60f) { ResetFogPosition(fogBillow); } } } if (_type != WeatherType.Rain) { return; } if (_thunderState == 0) { if (Time.time >= _nextThunderTime) { if (_directionalLights.Count == 0) { FindDirectionalLights(); } _thunderState = 1; _flashTimer = 0.15f; SetLighting(5.5f, Color.white); if ((Object)(object)_thunderAudioSource != (Object)null && (Object)(object)_thunderClip != (Object)null) { _thunderAudioSource.pitch = Random.Range(0.85f, 1.1f); _thunderAudioSource.PlayOneShot(_thunderClip, 1f); } } } else if (_thunderState == 1) { _flashTimer -= dt; if (_flashTimer <= 0f) { _thunderState = 2; _flashTimer = 1.2f; } } else if (_thunderState == 2) { _flashTimer -= dt; float num9 = Mathf.Clamp01(_flashTimer / 1.2f); float num10 = (_isNight ? 0.85f : _originalLightIntensity); ? val4 = (_isNight ? new Color(0.18f, 0.22f, 0.38f) : _originalAmbientColor); float intensity = Mathf.Lerp(num10, 5.5f, num9); Color ambient = Color.Lerp((Color)val4, Color.white, num9); SetLighting(intensity, ambient); if (_flashTimer <= 0f) { _thunderState = 0; _nextThunderTime = Time.time + Random.Range(15f, 30f); } } } private void SetLighting(float intensity, Color ambient) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) foreach (Light directionalLight in _directionalLights) { if ((Object)(object)directionalLight != (Object)null) { directionalLight.intensity = intensity; } } RenderSettings.ambientLight = ambient; } public void Destroy() { //IL_015c: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject particle in _particles) { if ((Object)(object)particle != (Object)null) { DestroyGameObject(particle); } } _particles.Clear(); foreach (GameObject fogBillow in _fogBillows) { if ((Object)(object)fogBillow != (Object)null) { DestroyGameObject(fogBillow); } } _fogBillows.Clear(); foreach (Splash splash in _splashes) { if (splash != null && (Object)(object)splash.GameObject != (Object)null) { DestroyGameObject(splash.GameObject); } } _splashes.Clear(); if ((Object)(object)_softCircleTex != (Object)null) { Object.Destroy((Object)(object)_softCircleTex); } foreach (KeyValuePair originalIntensity in _originalIntensities) { if ((Object)(object)originalIntensity.Key != (Object)null) { originalIntensity.Key.intensity = originalIntensity.Value; } } RenderSettings.ambientLight = _originalAmbientColor; RenderSettings.fog = false; if ((Object)(object)_weatherAudioSource != (Object)null && (Object)(object)((Component)_weatherAudioSource).gameObject != (Object)null) { _weatherAudioSource.Stop(); Object.Destroy((Object)(object)((Component)_weatherAudioSource).gameObject); } if ((Object)(object)_thunderAudioSource != (Object)null && (Object)(object)((Component)_thunderAudioSource).gameObject != (Object)null) { _thunderAudioSource.Stop(); Object.Destroy((Object)(object)((Component)_thunderAudioSource).gameObject); } } } public class Splash { public GameObject GameObject; public Vector3 StartScale; public float Life; public float MaxLife; } }