Decompiled source of WeatherGB v1.3.7
Mods/WeatherGB.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
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 MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; 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.3.5", "Zooks", null)] [assembly: MelonGame("Boneloaf", "Gang Beasts")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("WeatherGB")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Weather mod for Gang Beasts")] [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] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WeatherGB { public enum TimeOfDay { Day, Evening, Night } public enum WeatherType { None, Rain, Snow, Ash } public class WeatherMod : MelonMod { private static WeatherController _controller; private static MelonPreferences_Category _prefCategory; private static MelonPreferences_Entry<string> _prefWeather; private static MelonPreferences_Entry<string> _prefTime; public override void OnInitializeMelon() { _prefCategory = MelonPreferences.CreateCategory("WeatherGB", "WeatherGB Settings"); _prefWeather = _prefCategory.CreateEntry<string>("WeatherOverride", "Random", "Weather (Random, Rain, Snow, Ash)", (string)null, false, false, (ValueValidator)null, (string)null); _prefTime = _prefCategory.CreateEntry<string>("TimeOverride", "Random", "Time of Day (Random, Day, Evening, Night)", (string)null, false, false, (ValueValidator)null, (string)null); ((MelonBase)this).LoggerInstance.Msg("Loaded WeatherGB v1.2.9"); try { QualitySettings.antiAliasing = Mathf.Max(QualitySettings.antiAliasing, 2); QualitySettings.anisotropicFiltering = (AnisotropicFiltering)2; QualitySettings.shadowResolution = (ShadowResolution)2; QualitySettings.shadowProjection = (ShadowProjection)1; } catch (Exception) { } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (_controller != null) { _controller.Destroy(); _controller = null; } string text = sceneName.ToLower(); if (text.Contains("incinerator") || text.Contains("chute") || text.Contains("grind") || text.Contains("meat") || text.Contains("vent") || text.Contains("fan") || text.Contains("ring") || text.Contains("subway") || text.Contains("aquarium")) { _controller = new WeatherController(WeatherType.None, TimeOfDay.Night); if (text.Contains("subway")) { ((MelonBase)this).LoggerInstance.Msg("[WeatherGB] Subway detected ('" + sceneName + "') - reflection probes off, normal maps 1.2x."); } else { ((MelonBase)this).LoggerInstance.Msg("[WeatherGB] Indoor map detected ('" + sceneName + "') - interior lighting & normal tweaks."); } return; } bool flag = text.Contains("lighthouse"); bool flag2 = text.Contains("crane"); bool flag3 = text.Contains("trawler"); WeatherType weatherType = WeatherType.None; string a = ((_prefWeather.Value != null) ? _prefWeather.Value.Trim() : "Random"); if (flag2) { weatherType = WeatherType.Rain; } else if (flag3) { weatherType = WeatherType.Rain; } else if (flag) { weatherType = WeatherType.Rain; } else if (string.Equals(a, "Rain", StringComparison.OrdinalIgnoreCase)) { weatherType = WeatherType.Rain; } else if (string.Equals(a, "Snow", StringComparison.OrdinalIgnoreCase)) { weatherType = WeatherType.Snow; } else if (string.Equals(a, "Ash", StringComparison.OrdinalIgnoreCase)) { weatherType = WeatherType.Ash; } else { if (text.Contains("buoy")) { weatherType = WeatherType.Snow; } else if (text.Contains("roof") || text.Contains("blimp") || text.Contains("menu") || text.Contains("customization") || text.Contains("truck") || text.Contains("containers") || text.Contains("tower") || text.Contains("girders")) { weatherType = WeatherType.Rain; } 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); } if (weatherType == WeatherType.Rain && !text.Contains("blimp") && !text.Contains("truck") && !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; } } string a2 = ((_prefTime.Value != null) ? _prefTime.Value.Trim() : "Random"); TimeOfDay timeOfDay = TimeOfDay.Day; if (string.Equals(a2, "Day", StringComparison.OrdinalIgnoreCase)) { timeOfDay = TimeOfDay.Day; } else if (string.Equals(a2, "Evening", StringComparison.OrdinalIgnoreCase)) { timeOfDay = TimeOfDay.Evening; } else if (string.Equals(a2, "Night", StringComparison.OrdinalIgnoreCase)) { timeOfDay = TimeOfDay.Night; } else { bool flag4 = text.Contains("roof") || text.Contains("wheel"); if (flag2) { timeOfDay = ((!(Random.value <= 0.5f)) ? TimeOfDay.Night : TimeOfDay.Day); } else if (flag4) { float value = Random.value; timeOfDay = ((value <= 0.62f) ? TimeOfDay.Evening : ((!(value <= 0.84f)) ? TimeOfDay.Night : TimeOfDay.Day)); } else { float value2 = Random.value; timeOfDay = ((!(value2 <= 0.33f)) ? ((value2 <= 0.66f) ? TimeOfDay.Evening : TimeOfDay.Night) : TimeOfDay.Day); } } if (flag2 && timeOfDay == TimeOfDay.Evening) { timeOfDay = TimeOfDay.Night; } if (weatherType != WeatherType.None) { _controller = new WeatherController(weatherType, timeOfDay); ((MelonBase)this).LoggerInstance.Msg($"[WeatherGB] Spawned {weatherType} weather ({timeOfDay}) for {sceneName}"); } } public override void OnUpdate() { if (_controller != null) { _controller.Update(Time.deltaTime); } } } public class WeatherController { private struct ParticleSimData { public Vector3 Position; public float Speed; public float SinOffset; public float Size; public float SwayPhaseX; public float SwayPhaseZ; public float SwayFreqX; public float SwayFreqZ; public float RollRotation; public bool HasCollisionPoint; public Vector3 CollisionPoint; public Vector3 CollisionNormal; public float CollisionY; public float DeathTimer; public Vector3 DeathPosition; } private struct FogData { public Transform Transform; public float Speed; public float Phase; } private struct SplashInstance { public GameObject GameObject; public Transform Transform; public MeshRenderer Renderer; public Vector3 BasePosition; public Vector3 StartScale; public float Life; public float MaxLife; public bool IsActive; } private class BoltSkeleton { public Vector3 top; public Vector3 bot; public float widthPx; public float rough; public int depth; public float dist; public List<BranchSkeleton> branches = new List<BranchSkeleton>(); } private class BranchSkeleton { public float t; public float angleDeg; public float side; public float lenFactor; public float widthPx; public float alphaMul; public float rough; public int depth; public List<BranchSkeleton> children = new List<BranchSkeleton>(); } private struct LightPreset { public string Name; public Color SunColor; public float SunIntensity; public float Shadow; public Color Ambient; public float Reflection; public Color FogColor; public float FogDensity; public FogMode Mode; public Color SkyColor; public float Scatter; public float SkyFogMaxDepth; public float GroundFogMaxDepth; public float SunPitch; public float SunYaw; } private static readonly int _colorPropID = Shader.PropertyToID("_Color"); private static readonly int _altColorPropID = Shader.PropertyToID("_BaseColor"); private static readonly int _mainTexPropID = Shader.PropertyToID("_MainTex"); private static readonly int _altMainTexPropID = Shader.PropertyToID("_BaseMap"); private static readonly int idSkyColorProp = Shader.PropertyToID("_SkyColor"); private static readonly int idFogColorProp = Shader.PropertyToID("_FogColor"); private static readonly int idFogLightScatterIntensityProp = Shader.PropertyToID("_FogLightScatterIntensity"); private static readonly int idSkyFogElevationProp = Shader.PropertyToID("_SkyFogElevation"); private static readonly int idSkyFogMaxDepthProp = Shader.PropertyToID("_SkyFogMaxDepth"); private static readonly int idGroundFogElevationProp = Shader.PropertyToID("_GroundFogElevation"); private static readonly int idGroundFogMaxDepthProp = Shader.PropertyToID("_GroundFogMaxDepth"); private static readonly BindingFlags _reflectFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private readonly WeatherType _type; private readonly TimeOfDay _timeOfDay; private readonly bool _isGirders; private readonly bool _isLighthouse; private readonly bool _isCrane; private readonly bool _isTrawler; private readonly bool _isIndoor; private readonly bool _isSubway; private readonly string _sceneName; private string _mapKey; private const float RAIN_DEATH_DURATION = 0.32f; private const float RAIN_DEATH_LIFT = 0.22f; private const float FLASH_DURATION = 1.2f; private const float MATERIAL_BLEND = 0.3f; private const float SHADOW_DAY = 1f; private const float SHADOW_EVENING = 1f; private const float SHADOW_NIGHT = 0.95f; private const float SHADOW_INDOOR = 0.95f; private const float MIN_SHADOW_DISTANCE = 120f; private const float EVENING_SUN_BOOST = 2.85f; private const float FAVORED_VARIANT_WEIGHT = 12f; private const float AO_INTENSITY = 3.75f; private const float AO_RADIUS = 0.16f; private const float AO_DIRECT_LIGHTING_STRENGTH = 1f; private const float PRETTY_EXPOSURE = 0.07f; private const float PRETTY_CONTRAST = 0.34f; private const float PRETTY_SATURATION = 0.18f; private const float PRETTY_BLOOM_INTENSITY = 0.42f; private const float PRETTY_BLOOM_THRESHOLD = 1.08f; private const float PRETTY_BLOOM_SCATTER = 0.66f; private const float PRETTY_VIGNETTE = 0.36f; private const float PRETTY_VIGNETTE_SMOOTHNESS = 0.42f; private const float PRETTY_CHROMATIC = 0.16f; private const float PRETTY_GRAIN = 0.045f; private Light _sunLight; private Quaternion _sunWorldRot; private bool _sunRotLocked; private readonly Dictionary<Light, Quaternion> _originalRotations = new Dictionary<Light, Quaternion>(); private static readonly bool ROTATE_ALL_DIRECTIONALS = false; private const float SUN_JITTER_PITCH = 4f; private const float SUN_JITTER_YAW = 12f; private Light _buoyBeacon; private float _origBeaconRange; private float _origBeaconIntensity; private bool _origBeaconEnabled; private const float BEACON_RANGE = 202f; private const float BEACON_EVENING_INTENSITY = 3f; private const float BEACON_NIGHT_INTENSITY = 6f; private ParticleSimData[] _simData; private FogData[] _fogBillows; private GameObject _particleMeshGo; private MeshFilter _meshFilter; private MeshRenderer _meshRenderer; private Mesh _particleMesh; private Vector3[] _vertices; private Vector2[] _uvs; private Color[] _colors; private int[] _triangles; private string _cacheFilePath; private int _vertsPerParticle; private string _cachedShaderName = "Sprites/Default"; private SplashInstance[] _splashCircularBuffer; private int _nextSplashIndex; private const int MAX_SPLASHES = 32; private Camera _mainCamera; private Transform _mainCameraTransform; private Texture2D _softCircleTex; private Texture2D _rainStreakTex; private Texture2D _snowflakeTex; private Material _particleMaterial; private Material _splashMaterial; private Material _fogMaterial; private MaterialPropertyBlock _splashPropertyBlock; private GameObject _boltGo; private MeshFilter _boltFilter; private MeshRenderer _boltRenderer; private Mesh _boltMesh; private Material _boltMat; private Light _boltLight; private Texture2D _boltLineTex; private float _boltAnimTimer; private bool _boltIntensityLogged; private const float BOLT_ANIM_INTERVAL = 0.06f; private readonly List<BoltSkeleton> _boltSkeletons = new List<BoltSkeleton>(); private readonly List<Vector3> _gv = new List<Vector3>(4096); private readonly List<Vector2> _guv = new List<Vector2>(4096); private readonly List<Color> _gcol = new List<Color>(4096); private readonly List<int> _gtri = new List<int>(8192); private readonly List<Vector3> _fractA = new List<Vector3>(64); private readonly List<Vector3> _fractB = new List<Vector3>(64); private readonly List<List<Vector3>> _freePolys = new List<List<Vector3>>(); private readonly List<List<Vector3>> _activePolys = new List<List<Vector3>>(64); private static readonly Color BOLT_GLOW = new Color(0.4f, 0.58f, 1f); private static readonly Color BOLT_CORE = new Color(0.97f, 0.99f, 1f); private readonly List<Light> _directionalLights = new List<Light>(); private readonly Dictionary<Light, float> _originalIntensities = new Dictionary<Light, float>(); private readonly Dictionary<Light, Color> _originalColors = new Dictionary<Light, Color>(); private readonly Dictionary<Light, float> _originalShadowStrength = new Dictionary<Light, float>(); private readonly Dictionary<Light, LightShadows> _originalShadowType = new Dictionary<Light, LightShadows>(); private readonly HashSet<Material> _modifiedMaterials = new HashSet<Material>(); private readonly Dictionary<Material, Color> _originalWaterEmission = new Dictionary<Material, Color>(); private readonly Dictionary<Material, Color> _originalWaterFoam = new Dictionary<Material, Color>(); private readonly Dictionary<Material, float> _originalBumpScales = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalNormalScales = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalDetailNormalScales = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalGlossiness = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalSmoothness = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalGlossMapScale = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalMetallic = new Dictionary<Material, float>(); private readonly Dictionary<Material, float> _originalRoughness = new Dictionary<Material, float>(); private float _originalLightIntensity = 1.1f; private float _originalShadowDistance = 150f; private Color _originalAmbientColor; private float _originalAmbientIntensity = 1f; private float _originalReflectionIntensity = 1f; private AmbientMode _originalAmbientMode; private bool _lightsCached; private Color _origGameSkyColor; private Color _origGameFogColor; private float _origGameScatter; private float _origGameSkyFogElevation; private float _origGameSkyFogMaxDepth; private float _origGameGroundFogElevation; private float _origGameGroundFogMaxDepth; private bool _thunderActive; private float _thunderStartTime; private float _nextThunderTime; private float _preFlashIntensity = 1f; private Color _preFlashAmbient = Color.white; private GameObject _audioHost; private AudioSource _weatherAudioSource; private AudioSource _thunderAudioSource; private AudioClip _weatherClip; private readonly List<AudioClip> _thunderClips = new List<AudioClip>(); private readonly float _rainSpeed = 40f; private readonly float _rainThickness = 0.055f; private readonly float _rainLongness = 0.45f; private readonly int _particleCount = 2100; private readonly Queue<int> _raycastQueue = new Queue<int>(); private readonly RaycastHit[] _raycastBuffer = (RaycastHit[])(object)new RaycastHit[8]; private const int MAX_RAYCASTS_PER_FRAME = 64; private const float BOX_W = 55f; private const float BOX_H_DOWN = -85f; private const float BOX_H_UP = 45f; private static bool BoltKeyPressed() { Keyboard current = Keyboard.current; if (current != null) { return ((ButtonControl)current.backslashKey).wasPressedThisFrame; } return false; } public WeatherController(WeatherType type, TimeOfDay tod) { //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_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Expected O, but got Unknown //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) _type = type; _timeOfDay = tod; _nextThunderTime = Time.time + Random.Range(12f, 25f); _mainCamera = Camera.main; _mainCameraTransform = (((Object)(object)_mainCamera != (Object)null) ? ((Component)_mainCamera).transform : null); Scene activeScene = SceneManager.GetActiveScene(); string text = (_sceneName = ((Scene)(ref activeScene)).name.ToLower()); _isGirders = text.Contains("girders"); _isLighthouse = text.Contains("lighthouse"); _isCrane = text.Contains("crane"); _isTrawler = text.Contains("trawler"); _isSubway = text.Contains("subway"); _isIndoor = text.Contains("incinerator") || text.Contains("chute") || text.Contains("grind") || text.Contains("meat") || text.Contains("vent") || text.Contains("fan") || text.Contains("ring") || _isSubway || text.Contains("aquarium"); _mapKey = DetectMapKey(text); _vertsPerParticle = ((_type == WeatherType.Rain) ? 4 : 8); FindDirectionalLights(); if (_mapKey == "buoy") { FindBuoyBeacon(); } CacheGameFogGlobals(); if (_type == WeatherType.None) { if (_isSubway) { RemoveSubwayReflectionProbes(); ApplyInteriorMaterialTweaks(1.2f, applySurfaceTweaks: false); EnhancePostProcessing(); return; } ApplyAtmosphericSettings(); if (_isIndoor) { ApplyIndoorLighting(1f); ApplyInteriorMaterialTweaks(1.6f); } else { ApplyTimeOfDayLighting(); } return; } InitializeDiskCache(); _softCircleTex = CreateSoftCircleTexture(); _splashPropertyBlock = new MaterialPropertyBlock(); SetupSharedMaterials(); InitLightning(); ApplyOutdoorSceneTweaks(); ApplyAtmosphericSettings(); SetupAudio(); InitializeDynamicMesh(); _simData = new ParticleSimData[_particleCount]; Vector3 boxCenter = (((Object)(object)_mainCamera != (Object)null) ? (_mainCameraTransform.position + _mainCameraTransform.forward * 15f) : Vector3.zero); for (int i = 0; i < _particleCount; i++) { _simData[i] = new ParticleSimData { Speed = Random.Range(0.91f, 1.13f), SinOffset = Random.Range(0f, 100f), Size = ((_type == WeatherType.Snow) ? Random.Range(0.16f, 0.32f) : ((_type == WeatherType.Rain) ? Random.Range(0.85f, 1.25f) : Random.Range(0.08f, 0.18f))), SwayPhaseX = Random.Range(0f, 100f), SwayPhaseZ = Random.Range(0f, 100f), SwayFreqX = Random.Range(0.8f, 1.5f), SwayFreqZ = Random.Range(0.8f, 1.5f), RollRotation = Random.Range(0f, 360f), DeathTimer = 0f }; ResetParticleSimulation(ref _simData[i], boxCenter, isStartup: true); if (_type == WeatherType.Rain) { _raycastQueue.Enqueue(i); } } _splashCircularBuffer = new SplashInstance[32]; for (int j = 0; j < 32; j++) { _splashCircularBuffer[j] = default(SplashInstance); } int num = ((_type != WeatherType.Snow) ? 9 : 0); _fogBillows = new FogData[num]; for (int k = 0; k < num; k++) { GameObject val = CreateFogBillow(); if ((Object)(object)val != (Object)null) { _fogBillows[k] = new FogData { Transform = val.transform, Speed = Random.Range(0.3f, 0.6f), Phase = Random.Range(0f, 10f) }; } } SpawnHeadlights(); ApplyTimeOfDayLighting(); } private void InitializeDiskCache() { try { string text = Path.Combine(Application.dataPath, "..", "UserData", "WeatherGB"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } _cacheFilePath = Path.Combine(text, "Cache.dat"); if (!File.Exists(_cacheFilePath)) { return; } string[] array = File.ReadAllLines(_cacheFilePath); foreach (string text2 in array) { if (text2.StartsWith("Shader:")) { _cachedShaderName = text2.Substring(7).Trim(); } } } catch (Exception) { } } private void SaveShaderToDiskCache(string shaderName) { try { if (!string.IsNullOrEmpty(_cacheFilePath)) { File.WriteAllText(_cacheFilePath, $"Shader:{shaderName}\nSavedAt:{DateTime.UtcNow}"); } } catch (Exception) { } } private Shader FindSafeShader() { Shader val = Shader.Find(_cachedShaderName); if ((Object)(object)val != (Object)null) { return val; } string[] array = new string[4] { "Sprites/Default", "UI/Default", "Legacy Shaders/Particles/Alpha Blended", "Unlit/Transparent" }; for (int i = 0; i < array.Length; i++) { Shader val2 = Shader.Find(array[i]); if ((Object)(object)val2 != (Object)null && ((Object)val2).name != "") { _cachedShaderName = ((Object)val2).name; SaveShaderToDiskCache(((Object)val2).name); return val2; } } return Shader.Find("Internal-Colored"); } private void SetupSharedMaterials() { //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_004c: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //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_01a6: 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_014e: 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_0118: 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) Shader val = FindSafeShader(); Texture2D val2; if (_type == WeatherType.Rain) { _rainStreakTex = CreateRainStreakTexture(); val2 = _rainStreakTex; } else { _snowflakeTex = CreateSnowflakeTexture(); val2 = _snowflakeTex; } _particleMaterial = new Material(val) { hideFlags = (HideFlags)61 }; _particleMaterial.SetTexture(_mainTexPropID, (Texture)(object)val2); _particleMaterial.SetTexture(_altMainTexPropID, (Texture)(object)val2); _splashMaterial = new Material(val) { hideFlags = (HideFlags)61 }; _splashMaterial.SetTexture(_mainTexPropID, (Texture)(object)_softCircleTex); _splashMaterial.SetTexture(_altMainTexPropID, (Texture)(object)_softCircleTex); _fogMaterial = new Material(val) { hideFlags = (HideFlags)61 }; Color val3 = ((_type == WeatherType.Snow) ? new Color(0.9f, 0.82f, 0.85f, 0.12f) : ((_timeOfDay == TimeOfDay.Night) ? new Color(0.02f, 0.03f, 0.08f, 0.18f) : ((_timeOfDay == TimeOfDay.Evening) ? new Color(0.42f, 0.3f, 0.18f, 0.12f) : ((_type == WeatherType.Rain) ? new Color(0.08f, 0.12f, 0.22f, 0.12f) : new Color(0.12f, 0.08f, 0.06f, 0.12f))))); _fogMaterial.SetTexture(_mainTexPropID, (Texture)(object)_softCircleTex); _fogMaterial.SetTexture(_altMainTexPropID, (Texture)(object)_softCircleTex); _fogMaterial.SetColor(_colorPropID, val3); _fogMaterial.SetColor(_altColorPropID, val3); } private Texture2D CreateSoftCircleTexture() { //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_0015: Expected O, but got Unknown //IL_002c: 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_0073: Unknown result type (might be due to invalid IL or missing references) int num = 32; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; 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, 1.8f); val.SetPixel(j, i, new Color(1f, 1f, 1f, num4)); } } val.Apply(); return val; } private Texture2D CreateRainStreakTexture() { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) int num = 16; int num2 = 128; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; for (int i = 0; i < num2; i++) { float num3 = (float)i / ((float)num2 - 1f); float num4; if (!(num3 > 0.82f)) { num4 = ((!(num3 < 0.45f)) ? 1f : Mathf.Pow(num3 / 0.45f, 0.55f)); } else { float num5 = (num3 - 0.82f) / 0.18f; num4 = Mathf.Sqrt(Mathf.Max(0f, 1f - num5 * num5)); } float num6 = Mathf.Pow(num3, 0.5f); float num7 = num4 * 0.45f; for (int j = 0; j < num; j++) { float num8 = Mathf.Abs((float)j / ((float)num - 1f) - 0.5f); float num9 = 0f; if (num8 < num7 && num7 > 0.0001f) { float num10 = num8 / num7; num9 = Mathf.Sqrt(Mathf.Max(0f, 1f - num10 * num10)) * num6; } val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01(num9))); } } val.Apply(); return val; } private Texture2D CreateSnowflakeTexture() { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) int num = 32; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1 }; float num2 = (float)(num - 1) / 2f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = ((float)j - num2) / num2; float num4 = ((float)i - num2) / num2; float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4); float num6 = Mathf.Clamp01(1f - num5); num6 = Mathf.Pow(num6, 1.4f); num6 *= Mathf.SmoothStep(0f, 0.15f, num6); val.SetPixel(j, i, new Color(1f, 1f, 1f, num6)); } } val.Apply(); return val; } private void InitializeDynamicMesh() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0138: 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) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01f1: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_02df: 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_02ee: Unknown result type (might be due to invalid IL or missing references) _particleMeshGo = new GameObject("WeatherMeshSystem") { hideFlags = (HideFlags)61 }; _meshFilter = _particleMeshGo.AddComponent<MeshFilter>(); _meshRenderer = _particleMeshGo.AddComponent<MeshRenderer>(); ((Renderer)_meshRenderer).sharedMaterial = _particleMaterial; ((Renderer)_meshRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_meshRenderer).receiveShadows = false; _particleMesh = new Mesh { name = "DynamicWeatherMesh", hideFlags = (HideFlags)61 }; _particleMesh.MarkDynamic(); int num = _particleCount * _vertsPerParticle; int num2 = _particleCount * _vertsPerParticle / 4 * 6; _vertices = (Vector3[])(object)new Vector3[num]; _uvs = (Vector2[])(object)new Vector2[num]; _colors = (Color[])(object)new Color[num]; _triangles = new int[num2]; Color val = ((_type == WeatherType.Snow) ? new Color(1f, 1f, 1f, 0.92f) : ((_type == WeatherType.Rain) ? new Color(1f, 1f, 1f, 0.95f) : new Color(0.95f, 0.48f, 0.12f, 0.65f))); int num3 = _particleCount * (_vertsPerParticle / 4); for (int i = 0; i < num3; i++) { int num4 = i * 4; int num5 = i * 6; _uvs[num4] = new Vector2(0f, 0f); _uvs[num4 + 1] = new Vector2(1f, 0f); _uvs[num4 + 2] = new Vector2(0f, 1f); _uvs[num4 + 3] = new Vector2(1f, 1f); _colors[num4] = val; _colors[num4 + 1] = val; _colors[num4 + 2] = val; _colors[num4 + 3] = val; _triangles[num5] = num4; _triangles[num5 + 1] = num4 + 2; _triangles[num5 + 2] = num4 + 1; _triangles[num5 + 3] = num4 + 2; _triangles[num5 + 4] = num4 + 3; _triangles[num5 + 5] = num4 + 1; } _particleMesh.SetVertices(Il2CppStructArray<Vector3>.op_Implicit(_vertices)); _particleMesh.SetUVs(0, Il2CppStructArray<Vector2>.op_Implicit(_uvs)); _particleMesh.SetColors(Il2CppStructArray<Color>.op_Implicit(_colors)); _particleMesh.SetTriangles(Il2CppStructArray<int>.op_Implicit(_triangles), 0); _particleMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 60000f); _meshFilter.sharedMesh = _particleMesh; } private void InitLightning() { //IL_0243: 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_026d: 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_0082: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0161: 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_0170: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_mainCamera == (Object)null) { _mainCamera = Camera.main; _mainCameraTransform = (((Object)(object)_mainCamera != (Object)null) ? ((Component)_mainCamera).transform : null); } if ((Object)(object)_mainCamera == (Object)null || (Object)(object)_mainCameraTransform == (Object)null) { MelonLogger.Error("[WeatherGB] InitLightning: no camera."); return; } _boltLineTex = CreateBoltLineTexture(); _boltGo = new GameObject("WeatherLightning"); _boltGo.layer = 0; _boltFilter = _boltGo.AddComponent<MeshFilter>(); _boltRenderer = _boltGo.AddComponent<MeshRenderer>(); ((Renderer)_boltRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_boltRenderer).receiveShadows = false; ((Renderer)_boltRenderer).lightProbeUsage = (LightProbeUsage)0; ((Renderer)_boltRenderer).reflectionProbeUsage = (ReflectionProbeUsage)0; ((Renderer)_boltRenderer).allowOcclusionWhenDynamic = false; ((Renderer)_boltRenderer).enabled = true; _boltMat = CreateBoltMaterial(); if ((Object)(object)_boltMat == (Object)null) { MelonLogger.Error("[WeatherGB] InitLightning: no material."); return; } ((Renderer)_boltRenderer).sharedMaterial = _boltMat; _boltMesh = new Mesh { name = "LightningMesh", hideFlags = (HideFlags)61 }; _boltMesh.MarkDynamic(); _boltMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 8000f); _boltFilter.sharedMesh = _boltMesh; try { GameObject val = new GameObject("LightningLight"); val.layer = 0; val.transform.SetParent(_boltGo.transform, false); _boltLight = val.AddComponent<Light>(); _boltLight.type = (LightType)2; _boltLight.color = new Color(0.55f, 0.8f, 1f); _boltLight.range = 320f; _boltLight.intensity = 0f; _boltLight.shadows = (LightShadows)0; } catch (Exception) { } _boltGo.transform.SetParent(_mainCameraTransform, false); _boltGo.transform.localPosition = Vector3.zero; _boltGo.transform.localRotation = Quaternion.identity; _boltGo.transform.localScale = Vector3.one; _boltGo.SetActive(false); MelonLogger.Msg("[WeatherGB] InitLightning: done. shader='" + ((Object)_boltMat.shader).name + "'"); } catch (Exception value) { MelonLogger.Error($"[WeatherGB] InitLightning FAILED: {value}"); } } private Material CreateBoltMaterial() { //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_0030: Expected O, but got Unknown //IL_008d: 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) try { Shader val = FindSafeShader(); if ((Object)(object)val == (Object)null) { MelonLogger.Error("[WeatherGB] CreateBoltMaterial: no shader."); return null; } Material val2 = new Material(val) { hideFlags = (HideFlags)61 }; if ((Object)(object)_boltLineTex != (Object)null) { if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)_boltLineTex); } if (val2.HasProperty("_BaseMap")) { val2.SetTexture("_BaseMap", (Texture)(object)_boltLineTex); } } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", Color.white); } val2.renderQueue = 3000; MelonLogger.Msg("[WeatherGB] CreateBoltMaterial: using '" + ((Object)val).name + "'"); return val2; } catch (Exception value) { MelonLogger.Error($"[WeatherGB] CreateBoltMaterial FAILED: {value}"); return null; } } private Texture2D CreateBoltLineTexture() { //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_0016: 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: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) int num = 32; int num2 = 4; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; for (int i = 0; i < num2; i++) { for (int j = 0; j < num; j++) { float num3 = Mathf.Abs((float)j / ((float)num - 1f) - 0.5f) * 2f; float num4 = Mathf.Pow(Mathf.Max(0f, 1f - num3), 7f); float num5 = Mathf.Pow(Mathf.Max(0f, 1f - num3), 1.3f) * 0.4f; float num6 = Mathf.Clamp01(num4 + num5); val.SetPixel(j, i, new Color(1f, 1f, 1f, num6)); } } val.Apply(); return val; } private void FireLightning() { //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_007a: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: 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_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: 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_02c5: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)_boltGo == (Object)null) && !((Object)(object)_mainCamera == (Object)null) && !((Object)(object)_boltMesh == (Object)null)) { if ((Object)(object)_mainCameraTransform != (Object)(object)((Component)_mainCamera).transform) { _mainCameraTransform = ((Component)_mainCamera).transform; _boltGo.transform.SetParent(_mainCameraTransform, false); _boltGo.transform.localPosition = Vector3.zero; _boltGo.transform.localRotation = Quaternion.identity; _boltGo.transform.localScale = Vector3.one; } float num = Random.Range(45f, 68f); float num2 = num * Mathf.Tan(_mainCamera.fieldOfView * 0.5f * ((float)Math.PI / 180f)); float num3 = num2 * _mainCamera.aspect; _boltSkeletons.Clear(); BoltSkeleton boltSkeleton = new BoltSkeleton(); float num4 = Random.Range(-0.62f, 0.62f) * num3 + Random.Range(-2f, 2f); float num5 = num2 * Random.Range(1.1f, 1.45f) + 10f; float num6 = (0f - num2) * Random.Range(0.55f, 1f) - 2f; float num7 = num4 + Random.Range((0f - num3) * 0.16f, num3 * 0.16f); boltSkeleton.top = new Vector3(num4, num5, num); boltSkeleton.bot = new Vector3(num7, num6, num + Random.Range(-3f, 3f)); boltSkeleton.dist = num; boltSkeleton.widthPx = Random.Range(11f, 15f); boltSkeleton.rough = Random.Range(0.16f, 0.23f); boltSkeleton.depth = 5; int num8 = Random.Range(3, 6); for (int i = 0; i < num8; i++) { float num9 = Random.Range(0.22f, 0.55f); boltSkeleton.branches.Add(MakeBranch(Random.Range(0.1f, 0.62f), Random.Range(24f, 52f), num9, boltSkeleton.widthPx * Random.Range(0.34f, 0.55f), 0.8f, Random.Range(0.22f, 0.3f), 4, (num9 > 0.4f) ? 2 : 0)); } _boltSkeletons.Add(boltSkeleton); Vector3 val = (boltSkeleton.top + boltSkeleton.bot) * 0.5f; if ((Object)(object)_boltLight != (Object)null) { ((Component)_boltLight).transform.localPosition = new Vector3(val.x, val.y, val.z * 0.85f); } _boltAnimTimer = 0f; ((Renderer)_boltRenderer).enabled = true; _boltGo.SetActive(true); RegenerateBolt(1f, 1f); MelonLogger.Msg($"[WeatherGB] FireLightning: 1 bolt, dist={num:F1}, forks={num8}"); } } catch (Exception value) { MelonLogger.Error($"[WeatherGB] FireLightning FAILED: {value}"); } } private BranchSkeleton MakeBranch(float t, float angle, float lenF, float widthPx, float alphaMul, float rough, int depth, int childCount) { BranchSkeleton branchSkeleton = new BranchSkeleton { t = t, angleDeg = angle, side = ((Random.value < 0.5f) ? (-1f) : 1f), lenFactor = lenF, widthPx = widthPx, alphaMul = alphaMul, rough = rough, depth = depth }; int num = ((childCount > 0) ? Random.Range(0, childCount + 1) : 0); for (int i = 0; i < num; i++) { branchSkeleton.children.Add(MakeBranch(Random.Range(0.25f, 0.8f), Random.Range(28f, 60f), Random.Range(0.25f, 0.55f), widthPx * 0.6f, alphaMul * 0.7f, rough + 0.05f, Mathf.Max(2, depth - 1), 0)); } return branchSkeleton; } private void RegenerateBolt(float crackle, float curve) { //IL_0047: 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_0061: 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) try { _gv.Clear(); _guv.Clear(); _gcol.Clear(); _gtri.Clear(); ReleasePolys(); for (int i = 0; i < _boltSkeletons.Count; i++) { BoltSkeleton boltSkeleton = _boltSkeletons[i]; float num = Vector3.Distance(boltSkeleton.top, boltSkeleton.bot); List<Vector3> poly = GetPoly(); Fractal(boltSkeleton.top, boltSkeleton.bot, num * boltSkeleton.rough * crackle, boltSkeleton.depth, poly); EmitChannel(poly, boltSkeleton.widthPx, boltSkeleton.dist, 1f, curve); for (int j = 0; j < boltSkeleton.branches.Count; j++) { BuildBranch(poly, num, boltSkeleton.branches[j], boltSkeleton.dist, crackle, curve); } } UploadBoltMesh(); } catch (Exception value) { MelonLogger.Error($"[WeatherGB] RegenerateBolt FAILED: {value}"); ReleasePolys(); } } private void BuildBranch(List<Vector3> parent, float parentLen, BranchSkeleton br, float dist, float crackle, float curve) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) int count = parent.Count; if (count >= 3) { int num = Mathf.Clamp(Mathf.RoundToInt(br.t * (float)(count - 1)), 1, count - 2); Vector3 val = parent[num]; Vector3 val2 = parent[num + 1] - parent[num - 1]; if (((Vector3)(ref val2)).sqrMagnitude < 1E-05f) { val2 = parent[num] - parent[num - 1]; } if (((Vector3)(ref val2)).sqrMagnitude < 1E-05f) { val2 = Vector3.down; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Quaternion.AngleAxis(br.side * br.angleDeg, Vector3.forward) * val2; Vector3 val4 = val + val3 * (parentLen * br.lenFactor); List<Vector3> poly = GetPoly(); Fractal(val, val4, parentLen * br.lenFactor * br.rough * crackle, br.depth, poly); EmitChannel(poly, br.widthPx, dist, br.alphaMul, curve); float parentLen2 = Vector3.Distance(val, val4); for (int i = 0; i < br.children.Count; i++) { BuildBranch(poly, parentLen2, br.children[i], dist, crackle, curve); } } } private void Fractal(Vector3 a, Vector3 b, float jitter, int depth, List<Vector3> dest) { //IL_0015: 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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0094: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00c4: 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_00cf: 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_00d6: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = _fractA; List<Vector3> list2 = _fractB; list.Clear(); list.Add(a); list.Add(b); float num = jitter; for (int i = 0; i < depth; i++) { list2.Clear(); for (int j = 0; j < list.Count - 1; j++) { Vector3 val = list[j]; Vector3 val2 = list[j + 1]; list2.Add(val); Vector3 val3 = (val + val2) * 0.5f; Vector3 val4 = val2 - val; float magnitude = ((Vector3)(ref val4)).magnitude; Vector3 val5 = ((magnitude > 0.0001f) ? (val4 / magnitude) : Vector3.down); Vector3 val6 = Vector3.Cross(val5, Vector3.forward); if (((Vector3)(ref val6)).sqrMagnitude < 0.0001f) { val6 = Vector3.right; } else { ((Vector3)(ref val6)).Normalize(); } Vector3 val7 = Vector3.Cross(val5, val6); Vector3 normalized = ((Vector3)(ref val7)).normalized; val3 += val6 * Random.Range(0f - num, num) + normalized * Random.Range((0f - num) * 0.22f, num * 0.22f); list2.Add(val3); } list2.Add(list[list.Count - 1]); List<Vector3> list3 = list; list = list2; list2 = list3; num *= 0.55f; } dest.Clear(); dest.AddRange(list); } private void EmitChannel(List<Vector3> pts, float baseWidthPx, float dist, float alphaMul, float curve) { //IL_000a: 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) AddRibbon(pts, baseWidthPx * 2.6f, dist, BOLT_GLOW, alphaMul * 0.42f, curve); AddRibbon(pts, baseWidthPx * 0.6f, dist, BOLT_CORE, alphaMul * 1f, curve); } private void AddRibbon(List<Vector3> pts, float widthPx, float dist, Color color, float alphaMul, float curve) { //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_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) //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_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_0075: 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) //IL_00b2: 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_00a2: 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_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_0127: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0164: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_01a2: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) int count = pts.Count; if (count < 2) { return; } float num = UnitsPerPixel(dist); float num2 = widthPx * 0.5f * num; int count2 = _gv.Count; for (int i = 0; i < count; i++) { Vector3 val = pts[i]; Vector3 val2 = ((i == 0) ? (pts[1] - pts[0]) : ((i != count - 1) ? (pts[i + 1] - pts[i - 1]) : (pts[i] - pts[i - 1]))); if (((Vector3)(ref val2)).sqrMagnitude < 1E-05f) { val2 = Vector3.down; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(val2, Vector3.forward); if (((Vector3)(ref val3)).sqrMagnitude < 1E-05f) { val3 = Vector3.right; } else { ((Vector3)(ref val3)).Normalize(); } float num3 = (float)i / (float)(count - 1); float num4 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(Mathf.Min(num3, 1f - num3) / 0.1f)); float num5 = num2 * num4; float num6 = alphaMul * num4 * curve; _gv.Add(val - val3 * num5); _gv.Add(val + val3 * num5); _guv.Add(new Vector2(0f, num3)); _guv.Add(new Vector2(1f, num3)); _gcol.Add(new Color(color.r, color.g, color.b, num6)); _gcol.Add(new Color(color.r, color.g, color.b, num6)); } for (int j = 0; j < count - 1; j++) { int num7 = count2 + j * 2; _gtri.Add(num7); _gtri.Add(num7 + 2); _gtri.Add(num7 + 1); _gtri.Add(num7 + 2); _gtri.Add(num7 + 3); _gtri.Add(num7 + 1); } } private float UnitsPerPixel(float dist) { int num = (((Object)(object)_mainCamera != (Object)null) ? Mathf.Max(1, _mainCamera.pixelHeight) : 1080); float num2 = (((Object)(object)_mainCamera != (Object)null) ? _mainCamera.fieldOfView : 60f); return 2f * dist * Mathf.Tan(num2 * 0.5f * ((float)Math.PI / 180f)) / (float)num; } private void UploadBoltMesh() { //IL_00a8: 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_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) if (!((Object)(object)_boltMesh == (Object)null)) { _boltMesh.Clear(); if (_gv.Count > 0) { _boltMesh.SetVertices(Il2CppStructArray<Vector3>.op_Implicit(_gv.ToArray())); _boltMesh.SetUVs(0, Il2CppStructArray<Vector2>.op_Implicit(_guv.ToArray())); _boltMesh.SetColors(Il2CppStructArray<Color>.op_Implicit(_gcol.ToArray())); _boltMesh.SetTriangles(Il2CppStructArray<int>.op_Implicit(_gtri.ToArray()), 0); _boltMesh.RecalculateBounds(); } else { _boltMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 8000f); } } } private List<Vector3> GetPoly() { int count = _freePolys.Count; List<Vector3> list = ((count > 0) ? _freePolys[count - 1] : new List<Vector3>(32)); if (count > 0) { _freePolys.RemoveAt(count - 1); } list.Clear(); _activePolys.Add(list); return list; } private void ReleasePolys() { for (int i = 0; i < _activePolys.Count; i++) { _activePolys[i].Clear(); _freePolys.Add(_activePolys[i]); } _activePolys.Clear(); } private void SetBoltIntensity(float k) { //IL_002b: 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) try { if ((Object)(object)_boltMat != (Object)null) { if (_boltMat.HasProperty("_Color")) { _boltMat.SetColor("_Color", Color.white); } if (_boltMat.HasProperty("_BaseColor")) { _boltMat.SetColor("_BaseColor", Color.white); } } if ((Object)(object)_boltLight != (Object)null) { _boltLight.intensity = Mathf.Clamp01(k) * 8f; } if (!_boltIntensityLogged && k > 0.01f) { _boltIntensityLogged = true; MelonLogger.Msg($"[WeatherGB] SetBoltIntensity: curve={k:F2}"); } } catch (Exception value) { MelonLogger.Error($"[WeatherGB] SetBoltIntensity FAILED: {value}"); } } private void CacheGameFogGlobals() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) _origGameSkyColor = Shader.GetGlobalColor(idSkyColorProp); _origGameFogColor = Shader.GetGlobalColor(idFogColorProp); _origGameScatter = Shader.GetGlobalFloat(idFogLightScatterIntensityProp); _origGameSkyFogElevation = Shader.GetGlobalFloat(idSkyFogElevationProp); _origGameSkyFogMaxDepth = Shader.GetGlobalFloat(idSkyFogMaxDepthProp); _origGameGroundFogElevation = Shader.GetGlobalFloat(idGroundFogElevationProp); _origGameGroundFogMaxDepth = Shader.GetGlobalFloat(idGroundFogMaxDepthProp); } private static void SetGameFog(Color skyColor, Color fogColor, float scatter, float skyFogElevation, float skyFogMaxDepth, float groundFogElevation, float groundFogMaxDepth) { //IL_0005: 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) Shader.SetGlobalColor(idSkyColorProp, skyColor); Shader.SetGlobalColor(idFogColorProp, fogColor); Shader.SetGlobalFloat(idFogLightScatterIntensityProp, Mathf.Clamp01(scatter)); Shader.SetGlobalFloat(idSkyFogElevationProp, Mathf.Max(0.001f, skyFogElevation)); Shader.SetGlobalFloat(idSkyFogMaxDepthProp, Mathf.Max(0.001f, skyFogMaxDepth)); Shader.SetGlobalFloat(idGroundFogElevationProp, groundFogElevation); Shader.SetGlobalFloat(idGroundFogMaxDepthProp, Mathf.Max(0.001f, groundFogMaxDepth)); } private void RestoreGameFogGlobals() { //IL_0006: 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) Shader.SetGlobalColor(idSkyColorProp, _origGameSkyColor); Shader.SetGlobalColor(idFogColorProp, _origGameFogColor); Shader.SetGlobalFloat(idFogLightScatterIntensityProp, _origGameScatter); Shader.SetGlobalFloat(idSkyFogElevationProp, _origGameSkyFogElevation); Shader.SetGlobalFloat(idSkyFogMaxDepthProp, _origGameSkyFogMaxDepth); Shader.SetGlobalFloat(idGroundFogElevationProp, _origGameGroundFogElevation); Shader.SetGlobalFloat(idGroundFogMaxDepthProp, _origGameGroundFogMaxDepth); } private void FindDirectionalLights() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0127: 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_0148: 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_007a: 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_00b5: Unknown result type (might be due to invalid IL or missing references) if (_lightsCached) { return; } foreach (Light item in Object.FindObjectsOfType<Light>()) { 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; _originalColors[item] = item.color; _originalShadowStrength[item] = item.shadowStrength; _originalShadowType[item] = item.shadows; _originalRotations[item] = ((Component)item).transform.rotation; _originalLightIntensity = item.intensity; } } } _sunLight = PickSun(); if ((Object)(object)_sunLight != (Object)null) { MelonLogger.Msg("[WeatherGB] Sun light: '" + ((Object)_sunLight).name + "'"); } _originalShadowDistance = QualitySettings.shadowDistance; _originalAmbientColor = RenderSettings.ambientLight; _originalAmbientIntensity = RenderSettings.ambientIntensity; _originalReflectionIntensity = RenderSettings.reflectionIntensity; _originalAmbientMode = RenderSettings.ambientMode; _lightsCached = true; } private void RemoveSubwayReflectionProbes() { Il2CppArrayBase<ReflectionProbe> obj = Object.FindObjectsOfType<ReflectionProbe>(); int num = 0; foreach (ReflectionProbe item in obj) { if (!((Object)(object)item == (Object)null)) { Object.Destroy((Object)(object)item); num++; } } MelonLogger.Msg($"[WeatherGB] Subway: removed {num} reflection probe(s)."); } private Light PickSun() { for (int i = 0; i < _directionalLights.Count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { string text = ((Object)val).name.ToLower(); if (text.Contains("city_directional") || text.Contains("sun")) { return val; } } } Light result = null; float num = -1f; for (int j = 0; j < _directionalLights.Count; j++) { Light val2 = _directionalLights[j]; if (!((Object)(object)val2 == (Object)null) && val2.intensity > num) { num = val2.intensity; result = val2; } } return result; } private void ApplySunRotation(float pitch, float yaw) { //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_00c1: 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) pitch += Random.Range(-4f, 4f); yaw += Random.Range(-12f, 12f); _sunWorldRot = Quaternion.Euler(Mathf.Clamp(pitch, 4f, 88f), yaw, 0f); if (ROTATE_ALL_DIRECTIONALS) { for (int i = 0; i < _directionalLights.Count; i++) { if ((Object)(object)_directionalLights[i] != (Object)null) { ((Component)_directionalLights[i]).transform.rotation = _sunWorldRot; } } _sunRotLocked = (Object)(object)_sunLight != (Object)null; } else if ((Object)(object)_sunLight != (Object)null) { ((Component)_sunLight).transform.rotation = _sunWorldRot; _sunRotLocked = true; } } private void MaintainSunRotation() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (_sunRotLocked && (Object)(object)_sunLight != (Object)null) { ((Component)_sunLight).transform.rotation = _sunWorldRot; } } private void FindBuoyBeacon() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 foreach (Light item in Object.FindObjectsOfType<Light>()) { if (!((Object)(object)item == (Object)null) && (int)item.type != 1) { Transform parent = ((Component)item).transform.parent; if ((Object)(object)parent != (Object)null && ((Object)parent).name.ToLower().Contains("beacon")) { _buoyBeacon = item; _origBeaconRange = item.range; _origBeaconIntensity = item.intensity; _origBeaconEnabled = ((Behaviour)item).enabled; MelonLogger.Msg($"[WeatherGB] Buoy beacon found (range {item.range:F0}, intensity {item.intensity:F1})."); return; } } } MelonLogger.Warning("[WeatherGB] Buoy beacon light not found."); } private void ApplyBuoyBeacon() { if (!((Object)(object)_buoyBeacon == (Object)null)) { ((Behaviour)_buoyBeacon).enabled = true; _buoyBeacon.range = 202f; if (_timeOfDay == TimeOfDay.Night) { _buoyBeacon.intensity = Mathf.Max(_origBeaconIntensity, 6f); } else if (_timeOfDay == TimeOfDay.Evening) { _buoyBeacon.intensity = Mathf.Max(_origBeaconIntensity, 3f); } else { _buoyBeacon.intensity = _origBeaconIntensity; } } } private void ApplyShadowStrength(float strength) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _directionalLights.Count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.shadowStrength = Mathf.Clamp01(strength); if ((int)val.shadows == 0) { val.shadows = (LightShadows)2; } } } QualitySettings.shadowDistance = Mathf.Max(_originalShadowDistance, 120f); } private static LightPreset LP(string name, string sun, float sunI, float shadow, string amb, float refl, string fog, float fogDens, FogMode mode, string sky, float scatter, float skyDepth, float groundDepth, float pitch, float yaw) { //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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) return new LightPreset { Name = name, SunColor = HexToColor(sun), SunIntensity = sunI, Shadow = shadow, Ambient = HexToColor(amb), Reflection = refl, FogColor = HexToColor(fog), FogDensity = fogDens, Mode = mode, SkyColor = HexToColor(sky), Scatter = scatter, SkyFogMaxDepth = skyDepth, GroundFogMaxDepth = groundDepth, SunPitch = pitch, SunYaw = yaw }; } private void ApplyPreset(LightPreset p) { //IL_0082: 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_00d8: 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_00b7: 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) if (_timeOfDay == TimeOfDay.Evening) { p.SunIntensity *= 2.85f; } for (int i = 0; i < _directionalLights.Count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.intensity = p.SunIntensity; val.color = p.SunColor; } } ApplyShadowStrength(p.Shadow); ApplySunRotation(p.SunPitch, p.SunYaw); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = p.Ambient; RenderSettings.ambientIntensity = 1f; RenderSettings.reflectionIntensity = p.Reflection; if (RenderSettings.fog = p.FogDensity > 0f) { RenderSettings.fogMode = p.Mode; RenderSettings.fogColor = p.FogColor; RenderSettings.fogDensity = p.FogDensity; } SetGameFog(p.SkyColor, p.FogColor, p.Scatter, 500f, p.SkyFogMaxDepth, -5f, p.GroundFogMaxDepth); } private static string DetectMapKey(string n) { if (n.Contains("blimp")) { return "blimp"; } if (n.Contains("roof")) { return "roof"; } if (n.Contains("lighthouse")) { return "lighthouse"; } if (n.Contains("trawler")) { return "trawler"; } if (n.Contains("wheel")) { return "wheel"; } if (n.Contains("buoy")) { return "buoy"; } return null; } private bool TryApplyMapPreset() { if (_mapKey == null) { return false; } LightPreset[] mapPresets = GetMapPresets(_mapKey, _timeOfDay); if (mapPresets == null || mapPresets.Length == 0) { return false; } List<LightPreset> list = new List<LightPreset>(mapPresets.Length); for (int i = 0; i < mapPresets.Length; i++) { if (!IsGreenLightingPreset(mapPresets[i])) { list.Add(mapPresets[i]); } } if (list.Count == 0) { return false; } float num = 0f; for (int j = 0; j < list.Count; j++) { num += GetPresetWeight(list[j]); } float num2 = Random.Range(0f, num); float num3 = 0f; LightPreset p = list[0]; for (int k = 0; k < list.Count; k++) { num3 += GetPresetWeight(list[k]); if (num2 <= num3) { p = list[k]; break; } } ApplyPreset(p); MelonLogger.Msg($"[WeatherGB] Lighting variant: {_mapKey} / {_timeOfDay} / '{p.Name}' (sun pitch {p.SunPitch:F0}, yaw {p.SunYaw:F0}, weighted)"); return true; } private float GetPresetWeight(LightPreset p) { float num = 1f; if (_timeOfDay == TimeOfDay.Evening && (_mapKey == "roof" || _mapKey == "wheel") && (p.Name == "City Sunset" || p.Name == "Golden Evening Haze")) { num *= 12f; } return num; } private static bool IsGreenLightingPreset(LightPreset p) { //IL_006c: 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_0086: 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) string text = ((p.Name != null) ? p.Name.ToLowerInvariant() : ""); if (text.Contains("green") || text.Contains("emerald") || text.Contains("moss") || text.Contains("toxic") || text.Contains("slime") || text.Contains("radioactive")) { return true; } if (!IsGreenish(p.FogColor) && !IsGreenish(p.SkyColor) && !IsGreenish(p.SunColor)) { return IsGreenish(p.Ambient); } return true; } private static bool IsGreenish(Color c) { //IL_0000: 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) //IL_0021: 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) if (c.g > 0.22f && c.g > c.r * 1.05f) { return c.g > c.b * 1.05f; } return false; } private static LightPreset[] GetMapPresets(string key, TimeOfDay tod) { return key switch { "blimp" => BlimpPresets(tod), "roof" => RoofPresets(tod), "lighthouse" => LighthousePresets(tod), "trawler" => TrawlerPresets(tod), "wheel" => WheelPresets(tod), "buoy" => BuoyPresets(tod), _ => null, }; } private static LightPreset[] BlimpPresets(TimeOfDay tod) { //IL_0001: 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_008b: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) FogMode mode = (FogMode)3; return tod switch { TimeOfDay.Day => new LightPreset[3] { LP("Clear Sky", "#fff4dc", 1.35f, 1f, "#a0b4d2", 1f, "#bcd2ee", 0f, mode, "#6fa8e8", 0.15f, 800f, 20f, 62f, 35f), LP("Cloud Sea", "#f2f4f8", 1f, 0.9f, "#b8c2d0", 0.9f, "#dfe6ef", 0.01f, mode, "#cfd9e6", 0.45f, 500f, 40f, 76f, 140f), LP("Golden Haze", "#ffe2a8", 1.3f, 1f, "#b0a898", 0.9f, "#f0dcb4", 0.005f, mode, "#d9c79a", 0.35f, 600f, 30f, 32f, 250f) }, TimeOfDay.Evening => new LightPreset[2] { LP("Sunset Blaze", "#ff8a3c", 0.75f, 1f, "#4a2a30", 0.6f, "#8a4a48", 0.009f, mode, "#ff9b6a", 0.55f, 550f, 30f, 10f, 280f), LP("Pink Horizon", "#ffa0a0", 0.6f, 1f, "#4d3248", 0.55f, "#7a4c70", 0.01f, mode, "#e58aa8", 0.5f, 550f, 30f, 15f, 70f) }, _ => new LightPreset[3] { LP("Moonlit Blue", "#9fb8ff", 0.42f, 0.95f, "#2a3358", 0.35f, "#1e2644", 0.01f, mode, "#1c2448", 0.35f, 400f, 30f, 48f, 200f), LP("Storm Dark", "#7d8aa8", 0.3f, 1f, "#1e2236", 0.22f, "#12162a", 0.014f, mode, "#10131f", 0.3f, 400f, 30f, 70f, 330f), LP("Violet Twilight", "#c08cff", 0.4f, 0.95f, "#352a5c", 0.3f, "#2c2050", 0.012f, mode, "#3a2a66", 0.4f, 400f, 30f, 28f, 110f) }, }; } private static LightPreset[] RoofPresets(TimeOfDay tod) { //IL_0001: 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_008b: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) FogMode mode = (FogMode)3; return tod switch { TimeOfDay.Day => new LightPreset[3] { LP("Bright Noon", "#fff6e0", 1.4f, 1f, "#a0b4d0", 1f, "#b8cce6", 0f, mode, "#6aa4e8", 0.15f, 800f, 20f, 68f, 20f), LP("Smoggy Haze", "#ffe8c0", 1.1f, 0.95f, "#b4aa9a", 0.9f, "#c2b49a", 0.008f, mode, "#c6b89a", 0.4f, 600f, 30f, 40f, 300f), LP("Overcast Grey", "#e8ecf2", 0.9f, 0.9f, "#aab2bf", 0.8f, "#b8c0cc", 0.009f, mode, "#b4bcc8", 0.35f, 600f, 30f, 78f, 180f) }, TimeOfDay.Evening => new LightPreset[2] { LP("City Sunset", "#ffc36a", 0.8f, 1f, "#6b5330", 0.62f, "#d9b65d", 0.0095f, mode, "#ffd48c", 0.58f, 560f, 30f, 12f, 245f), LP("Amber Smog", "#ffb060", 0.6f, 1f, "#523a30", 0.55f, "#7c5a40", 0.011f, mode, "#d89050", 0.5f, 500f, 30f, 18f, 120f) }, _ => new LightPreset[3] { LP("City Night", "#ffb890", 0.38f, 0.95f, "#2e2a4c", 0.3f, "#2a2440", 0.012f, mode, "#221c3a", 0.4f, 400f, 30f, 45f, 150f), LP("Deep Blue Moon", "#a8c0ff", 0.42f, 0.95f, "#28325a", 0.35f, "#1c2444", 0.01f, mode, "#182040", 0.35f, 400f, 30f, 58f, 330f), LP("Neon Glow", "#ff78d0", 0.36f, 0.95f, "#3a2652", 0.3f, "#3a1f52", 0.013f, mode, "#3a1e5a", 0.4f, 400f, 30f, 25f, 60f) }, }; } private static LightPreset[] LighthousePresets(TimeOfDay tod) { //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_003a: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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) FogMode mode = (FogMode)2; FogMode mode2 = (FogMode)3; return tod switch { TimeOfDay.Day => new LightPreset[3] { LP("Clear Coastal", "#fff8e6", 2f, 1f, "#c3cfdf", 1f, "#a8bcd4", 0.006f, mode2, "#c3d4e6", 0.2f, 800f, 20f, 58f, 200f), LP("Grey Overcast", "#dfe5ec", 1.4f, 0.9f, "#aab4c2", 0.8f, "#98a6b8", 0.011f, mode2, "#a6b2c2", 0.35f, 600f, 30f, 72f, 90f), LP("Sea Fog Morning", "#fff0d8", 1.2f, 0.9f, "#b8c4d0", 0.8f, "#cfd8e0", 0.016f, mode2, "#d8e0e8", 0.5f, 500f, 40f, 22f, 60f) }, TimeOfDay.Evening => new LightPreset[2] { LP("Sunset", "#ffa159", 0.6f, 1f, "#5d3440", 0.55f, "#3b3b62", 0.014f, mode, "#8b5f78", 0.55f, 550f, 30f, 9f, 260f), LP("Crimson Storm", "#ff6a48", 0.5f, 1f, "#48262e", 0.45f, "#4a2a44", 0.016f, mode, "#9a4c58", 0.55f, 500f, 30f, 14f, 310f) }, _ => new LightPreset[3] { LP("Dusk Violet", "#ffbdad", 0.22f, 0.95f, "#1c1a30", 0.22f, "#47335c", 0.012f, mode2, "#4d3861", 0.4f, 400f, 30f, 18f, 240f), LP("Moonlit Sea", "#a8c4ff", 0.4f, 0.95f, "#263256", 0.35f, "#1a2848", 0.01f, mode2, "#142040", 0.35f, 400f, 30f, 52f, 120f), LP("Pitch Storm", "#8090b0", 0.28f, 1f, "#1a1e30", 0.2f, "#0e1222", 0.016f, mode2, "#0c0f1a", 0.3f, 400f, 30f, 68f, 20f) }, }; } private static LightPreset[] TrawlerPresets(TimeOfDay tod) { //IL_0001: 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_008b: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) FogMode mode = (FogMode)3; return tod switch { TimeOfDay.Day => new LightPreset[2] { LP("Bright Sea", "#fff6e0", 1.4f, 1f, "#a8c0dc", 1f, "#c0d8ea", 0.008f, mode, "#8cc0ec", 0.25f, 700f, 30f, 60f, 160f), LP("Overcast Grey", "#e2e8ee", 1f, 0.9f, "#a8b4c0", 0.8f, "#aab8c6", 0.014f, mode, "#b0bcc8", 0.4f, 500f, 40f, 75f, 40f) }, TimeOfDay.Evening => new LightPreset[2] { LP("Sunset Sea", "#ff9350", 0.7f, 1f, "#4e3040", 0.55f, "#6a4658", 0.01f, mode, "#f09068", 0.55f, 550f, 30f, 10f, 90f), LP("Cold Amber", "#ffb878", 0.55f, 1f, "#404458", 0.5f, "#56607a", 0.012f, mode, "#c08a70", 0.5f, 500f, 30f, 17f, 220f) }, _ => new LightPreset[3] { LP("Cyan Mist", "#e5faff", 1.2f, 0.85f, "#b8e0fa", 0.95f, "#e5faff", 0.02f, mode, "#f2ffff", 1f, 400f, 60f, 55f, 30f), LP("Moonlit Deep", "#9cb8f0", 0.4f, 0.95f, "#22304f", 0.3f, "#16223c", 0.011f, mode, "#101a32", 0.35f, 400f, 30f, 40f, 300f), LP("Stormy Teal", "#6fa8a8", 0.32f, 1f, "#182c30", 0.25f, "#0f2226", 0.016f, mode, "#0c1c20", 0.3f, 400f, 30f, 66f, 170f) }, }; } private static LightPreset[] WheelPresets(TimeOfDay tod) { //IL_0001: 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_008b: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: 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_0192: 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) FogMode mode = (FogMode)3; return tod switch { TimeOfDay.Day => new LightPreset[3] { LP("Misty", "#fff5e0", 1.2f, 1f, "#b4c0d8", 0.95f, "#e5faff", 0.02f, mode, "#f2ffff", 1f, 400f, 60f, 50f, 100f), LP("Sunny Fair", "#fff2d0", 1.4f, 1f, "#a4b8d8", 1f, "#bcd0ec", 0f, mode, "#6aa8ec", 0.15f, 800f, 20f, 66f, 330f), LP("Hazy Gold", "#ffdc98", 1.25f, 1f, "#b8aa98", 0.9f, "#ecd4a0", 0.006f, mode, "#e0c890", 0.35f, 600f, 30f, 30f, 210f) }, TimeOfDay.Evening => new LightPreset[3] { LP("City Sunset", "#ffc36a", 0.8f, 1f, "#6b5330", 0.62f, "#d9b65d", 0.0095f, mode, "#ffd48c", 0.58f, 560f, 30f, 12f, 245f), LP("Carnival Sunset", "#ff8040", 0.75f, 1f, "#50303a", 0.6f, "#86465a", 0.009f, mode, "#ff8c66", 0.55f, 550f, 30f, 10f, 40f), LP("Pink Dusk", "#ff98b8", 0.6f, 1f, "#4c2e4c", 0.55f, "#7a4678", 0.01f, mode, "#e080b0", 0.5f, 550f, 30f, 16f, 200f) }, _ => new LightPreset[3] { LP("Purple Fair Night", "#ffb6d0", 0.36f, 0.95f, "#2e2650", 0.3f, "#2e2050", 0.012f, mode, "#2c2056", 0.4f, 400f, 30f, 42f, 260f), LP("Deep Blue", "#a0baff", 0.4f, 0.95f, "#26305a", 0.35f, "#1a2244", 0.01f, mode, "#141c40", 0.35f, 400f, 30f, 60f, 80f), LP("Carnival Glow", "#ffc888", 0.4f, 0.95f, "#382a40", 0.3f, "#341f3c", 0.012f, mode, "#2a1a38", 0.4f, 400f, 30f, 26f, 170f) }, }; } private static LightPreset[] BuoyPresets(TimeOfDay tod) { //IL_0001: 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_008b: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) FogMode mode = (FogMode)3; return tod switch { TimeOfDay.Day => new LightPreset[3] { LP("Polar Glare", "#f4faff", 1.5f, 1f, "#b4c8e0", 1f, "#e0eefa", 0.007f, mode, "#b4d4f4", 0.3f, 800f, 30f, 35f, 150f), LP("Flat Grey", "#dde4ec", 1f, 0.9f, "#aab6c4", 0.8f, "#b8c4d0", 0.014f, mode, "#b8c4d0", 0.4f, 500f, 40f, 70f, 250f), LP("Pink Polar", "#ffe0e0", 1.2f, 1f, "#bcaec4", 0.9f, "#f0d8e0", 0.01f, mode, "#e8c8d8", 0.4f, 600f, 30f, 14f, 30f) }, TimeOfDay.Evening => new LightPreset[2] { LP("Polar Twilight", "#ff9ab0", 0.6f, 1f, "#48385c", 0.5f, "#6a4c80", 0.011f, mode, "#c480b0", 0.5f, 550f, 30f, 7f, 300f), LP("Amber Low Sun", "#ffb070", 0.65f, 1f, "#4a4058", 0.5f, "#706078", 0.01f, mode, "#e8a078", 0.5f, 550f, 30f, 12f, 100f) }, _ => new LightPreset[3] { LP("Grey Overcast Night", "#9aa4b4", 0.1f, 0.95f, "#1a1b1e", 0.1f, "#1a1a1a", 0.012f, mode, "#141416", 0.3f, 400f, 30f, 55f, 200f), LP("Dim Moon", "#b8c0cc", 0.1f, 0.95f, "#17181a", 0.1f, "#1c1c1d", 0.012f, mode, "#131315", 0.3f, 400f, 30f, 35f, 320f), LP("Whiteout Blizzard", "#a0a8b0", 0.1f, 0.9f, "#1c1c1e", 0.1f, "#202022", 0.02f, mode, "#18181a", 0.3f, 300f, 40f, 70f, 60f) }, }; } private void ApplyTrawlerStyleFog(float densityMultiplier) { //IL_0038: 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) if (densityMultiplier <= 0f) { densityMultiplier = 1f; } Color fogColor = default(Color); ((Color)(ref fogColor))..ctor(0.9f, 0.98f, 1f); float fogDensity = 0.02f * densityMultiplier; RenderSettings.fog = true; RenderSettings.fogMode = (FogMode)3; RenderSettings.fogColor = fogColor; RenderSettings.fogDensity = fogDensity; SetGameFog(new Color(0.95f, 1f, 1f), fogColor, 1f, 500f, 400f, -10f, 60f * densityMultiplier); } private void ApplyDayLighting() { //IL_008f: 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_00d6: 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) int count = _directionalLights.Count; for (int i = 0; i < count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.intensity = (_originalIntensities.ContainsKey(val) ? _originalIntensities[val] : 1f); val.color = new Color(1f, 0.96f, 0.88f); } } ApplyShadowStrength(1f); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.62f, 0.68f, 0.8f); RenderSettings.ambientIntensity = 1f; RenderSettings.reflectionIntensity = 1f; RenderSettings.fog = false; SetGameFog(new Color(0.65f, 0.78f, 0.95f), new Color(0.75f, 0.85f, 0.98f), 0.15f, 500f, 800f, -5f, 20f); if (_sceneName.Contains("wheel") || _sceneName.Contains("train")) { ApplyTrawlerStyleFog(1f); } else if (_sceneName.Contains("truck")) { ApplyTrawlerStyleFog(0.32f); } else if (_sceneName.Contains("tower")) { ApplyTrawlerStyleFog(1f); } } private void ApplyEveningLighting() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) int count = _directionalLights.Count; float intensity = 1.8524998f; Color color = default(Color); ((Color)(ref color))..ctor(1f, 0.58f, 0.26f); for (int i = 0; i < count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.intensity = intensity; val.color = color; } } ApplyShadowStrength(1f); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.42f, 0.27f, 0.24f); RenderSettings.ambientIntensity = 1f; RenderSettings.reflectionIntensity = 0.7f; RenderSettings.fog = true; RenderSettings.fogMode = (FogMode)3; RenderSettings.fogColor = new Color(0.54f, 0.39f, 0.31f); RenderSettings.fogDensity = 0.008f; SetGameFog(new Color(1f, 0.7f, 0.5f), new Color(0.6f, 0.44f, 0.34f), 0.58f, 500f, 600f, -5f, 30f); } private void ApplyDuskLighting(float brightness) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (brightness <= 0f) { brightness = 1f; } Color color = default(Color); ((Color)(ref color))..ctor(1f, 0.74f, 0.68f); float intensity = 0.2f * brightness; Color ambientLight = new Color(0.11f, 0.1f, 0.19f) * brightness; Color fogColor = default(Color); ((Color)(ref fogColor))..ctor(0.28f, 0.2f, 0.36f); int count = _directionalLights.Count; for (int i = 0; i < count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.intensity = intensity; val.color = color; } } ApplyShadowStrength(0.95f); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = ambientLight; RenderSettings.ambientIntensity = 1f; RenderSettings.reflectionIntensity = Mathf.Clamp01(0.22f * brightness); RenderSettings.fog = true; RenderSettings.fogMode = (FogMode)3; RenderSettings.fogColor = fogColor; RenderSettings.fogDensity = 0.012f; SetGameFog(new Color(0.3f, 0.22f, 0.38f), new Color(0.32f, 0.22f, 0.38f), 0.4f, 500f, 400f, -5f, 30f); } private void ApplyTrawlerNightLighting() { //IL_00a0: 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_00e5: 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_007d: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.9f, 0.98f, 1f); float intensity = 1.2f; Color ambientLight = default(Color); ((Color)(ref ambientLight))..ctor(0.72f, 0.88f, 0.98f); Color fogColor = default(Color); ((Color)(ref fogColor))..ctor(0.9f, 0.98f, 1f); int count = _directionalLights.Count; for (int i = 0; i < count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.intensity = intensity; val.color = color; } } ApplyShadowStrength(0.85f); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = ambientLight; RenderSettings.ambientIntensity = 1f; RenderSettings.reflectionIntensity = 0.95f; RenderSettings.fog = true; RenderSettings.fogMode = (FogMode)3; RenderSettings.fogColor = fogColor; RenderSettings.fogDensity = 0.02f; SetGameFog(new Color(0.95f, 1f, 1f), new Color(0.9f, 0.98f, 1f), 1f, 500f, 400f, -10f, 60f); } private void ApplyIndoorLighting(float brightness) { //IL_0084: 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_00c4: 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_0052: Unknown result type (might be due to invalid IL or missing references) if (brightness <= 0f) { brightness = 1f; } int count = _directionalLights.Count; for (int i = 0; i < count; i++) { Light val = _directionalLights[i]; if (!((Object)(object)val == (Object)null)) { val.intensity = 0.35f * brightness; val.color = new Color(0.95f, 0.88f, 0.78f); } } ApplyShadowStrength(0.95f); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.16f, 0.15f, 0.18f) * brightness; RenderSettings.ambientIntensity = 1f; RenderSettings.reflectionIntensity = Mathf.Clamp01(0.25f * brightness); RenderSettings.fog = false; SetGameFog(new Color(0.02f, 0.02f, 0.03f), new Color(0.04f, 0.04f, 0.06f), 0f, 500f, 0.001f, -1000f, 0.001f); } private void ApplyNightLighting() { if (_isTrawler) { ApplyTrawlerNightLighting(); } else if (_sceneName.Contains("crane")) { ApplyDuskLighting(1f); } else if (_sceneName.Contains("lighthouse")) { ApplyDuskLighting(1f); } else if (_sceneName.Contains("tower")) { ApplyDuskLighting(1f); } else if (_sceneName.Contains("elevator")) { ApplyDuskLighting(1.5f); } else if (_sceneName.Contains("roof")) { ApplyDuskLighting(1.9f); } else if (_sceneName.Contains("train")) { ApplyDuskLighting(1.6f); } else if (_sceneName.Contains("blimp")) { ApplyDuskLighting(1.3f); } else if (_sceneName.Contains("menu") || _sceneName.Contains("customization")) { ApplyDuskLighting(1.25f); } else { ApplyDuskLighting(1.35f); } } private void ApplyCraneLighting() { if (_timeOfDay == TimeOfDay.Evening) { ApplyDuskLighting(1f); } else if (_timeOfDay == TimeOfDay.Day) { ApplyDayLighting(); ApplyCraneDayFog(); } else { ApplyDuskLighting(1f); } } private void ApplyCraneDayFog() { //IL_001b: 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_0052: Unknown result type (might be due to invalid IL or missing references) RenderSettings.fog = true; RenderSettings.fogMode = (FogMode)3; RenderSettings.fogColor = new Color(0.55f, 0.7f, 0.88f); RenderSettings.fogDensity = 0.008f; SetGameFog(new Color(0.68f, 0.82f, 0.96f), new Color(0.6f, 0.76f, 0.92f), 0.3f, 500f, 700f, -5f, 30f); } private void ApplyTimeOfDayLighting() { if (_isIndoor) { ApplyIndoorLighting(1f); return; } if (_mapKey == "buoy") { ApplyBuoyBeacon(); } if (!TryApplyMapPreset()) { if (_isCrane) { ApplyCraneLighting(); } else if (_timeOfDay == TimeOfDay.Day) { ApplyDayLighting(); } else if (_timeOfDay == TimeOfDay.Evening) { ApplyEveningLighting(); } else if (_timeOfDay == TimeOfDay.Night) { ApplyNightLighting(); } } } private static Color HexToColor(string hex) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(hex)) { return Color.white; } if (hex[0] == '#') { hex = hex.Substring(1); } if (hex.Length < 6) { return Color.white; } try { byte num = Convert.ToByte(hex.Substring(0, 2), 16); byte b = Convert.ToByte(hex.Substring(2, 2), 16); byte b2 = Convert.ToByte(hex.Substring(4, 2), 16); return new Color((float)(int)num / 255f, (float)(int)b / 255f, (float)(int)b2 / 255f, 1f); } catch { return Color.white; } } private static bool IsActorRenderer(string rName) { if (rName.IndexOf("Actor", StringComparison.OrdinalIgnoreCase) < 0 && rName.IndexOf("Ragdoll", StringComparison.OrdinalIgnoreCase) < 0 && rName.IndexOf("Player", StringComparison.OrdinalIgnoreCase) < 0) { return rName.IndexOf("C