Decompiled source of WeatherExpansion v1.0.0
WeatherExpansion.dll
Decompiled 11 hours 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace HowToFish.WeatherExpansion; public enum WeatherKind { Clear, Rain, Storm, Snow, Hurricane } public struct WeatherWeights { public int Clear; public int Rain; public int Storm; public int Snow; public int Hurricane; public int Total => Clear + Rain + Storm + Snow + Hurricane; public static WeatherWeights Default => new WeatherWeights { Clear = 40, Rain = 30, Storm = 15, Snow = 10, Hurricane = 5 }; public static WeatherWeights Parse(string text, Action<string> logWarning) { WeatherWeights result = default(WeatherWeights); if (string.IsNullOrEmpty(text)) { return Default; } string[] array = text.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); int num = text2.IndexOf(':'); if (num > 0 && num < text2.Length - 1) { string text3 = text2.Substring(0, num).Trim(); string text4 = text2.Substring(num + 1).Trim(); if (!int.TryParse(text4, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) || result2 < 0) { logWarning?.Invoke("Invalid weight for weather '" + text3 + "': " + text4); } else if (string.Equals(text3, "Clear", StringComparison.OrdinalIgnoreCase)) { result.Clear = result2; } else if (string.Equals(text3, "Rain", StringComparison.OrdinalIgnoreCase)) { result.Rain = result2; } else if (string.Equals(text3, "Storm", StringComparison.OrdinalIgnoreCase)) { result.Storm = result2; } else if (string.Equals(text3, "Snow", StringComparison.OrdinalIgnoreCase)) { result.Snow = result2; } else if (string.Equals(text3, "Hurricane", StringComparison.OrdinalIgnoreCase)) { result.Hurricane = result2; } else { logWarning?.Invoke("Unknown weather kind '" + text3 + "'."); } } } if (result.Total <= 0) { logWarning?.Invoke("Total weather weight was 0; falling back to default weights."); return Default; } return result; } } public static class WeatherScheduler { public static WeatherKind Select(int islandIndex, long weatherSlot, int seed, WeatherWeights weights) { int total = weights.Total; if (total <= 0) { return WeatherKind.Clear; } uint num = HashSlot(islandIndex, weatherSlot, seed, 439041101u); int num2 = (int)(num % (uint)total); if (num2 < weights.Clear) { return WeatherKind.Clear; } num2 -= weights.Clear; if (num2 < weights.Rain) { return WeatherKind.Rain; } num2 -= weights.Rain; if (num2 < weights.Storm) { return WeatherKind.Storm; } num2 -= weights.Storm; if (num2 < weights.Snow) { return WeatherKind.Snow; } return WeatherKind.Hurricane; } public static float WindAngle(int islandIndex, long weatherSlot, int seed) { uint num = HashSlot(islandIndex, weatherSlot, seed, 1584364171u); return (float)(num % 3600) / 10f; } public static bool ShouldTriggerLightning(int islandIndex, long lightningBucket, int seed, int percentChance) { uint num = HashSlot(islandIndex, lightningBucket, seed, 2626518639u); return num % 100 < (uint)percentChance; } public static float LightningPitch(int islandIndex, long lightningBucket, int seed) { uint num = HashSlot(islandIndex, lightningBucket, seed, 866197255u); return 0.88f + (float)(num % 25) * 0.01f; } public static float GameplayVariation(int islandIndex, long pulseBucket, int seed, uint salt) { uint num = HashSlot(islandIndex, pulseBucket, seed, salt); return (float)(num % 1000) / 500f - 1f; } private static uint HashSlot(int islandIndex, long slot, int seed, uint salt) { uint num = 2166136261u; num = (num ^ (uint)islandIndex) * 16777619; num = (num ^ (uint)(int)(slot & 0xFFFFFFFFu)) * 16777619; num = (num ^ (uint)(int)((slot >> 32) & 0xFFFFFFFFu)) * 16777619; num = (num ^ (uint)seed) * 16777619; num = (num ^ salt) * 16777619; num ^= num >> 13; num *= 1540483477; return num ^ (num >> 15); } } internal sealed class GameBridge { private Type _gameInfoType; private Type _waterManagerType; private Type _audioManagerType; private Type _timeManagerType; private PropertyInfo _curCameraProperty; private PropertyInfo _mainLightProperty; private PropertyInfo _islandIndexProperty; private MethodInfo _isUnderWaterMethod; private FieldInfo _fxMixerGroupField; private FieldInfo _timeManagerInstanceField; private MethodInfo _getExactTicksMethod; private bool _reflectionCached; internal void EnsureReflection() { if (!_reflectionCached) { _gameInfoType = Type.GetType("GameInfo, Assembly-CSharp"); if (_gameInfoType != null) { _curCameraProperty = _gameInfoType.GetProperty("CurCamera", BindingFlags.Static | BindingFlags.Public); _mainLightProperty = _gameInfoType.GetProperty("MainLight", BindingFlags.Static | BindingFlags.Public); _islandIndexProperty = _gameInfoType.GetProperty("IslandIndex", BindingFlags.Static | BindingFlags.Public); } _waterManagerType = Type.GetType("WaterManager, Assembly-CSharp"); if (_waterManagerType != null) { _isUnderWaterMethod = _waterManagerType.GetMethod("IsUnderWater", BindingFlags.Static | BindingFlags.Public); } _audioManagerType = Type.GetType("AudioManager, Assembly-CSharp"); if (_audioManagerType != null) { _fxMixerGroupField = _audioManagerType.GetField("Fx", BindingFlags.Static | BindingFlags.Public) ?? _audioManagerType.GetField("fx", BindingFlags.Static | BindingFlags.Public); } _timeManagerType = Type.GetType("FishNet.Managing.Timing.TimeManager, FishNet.Runtime"); if (_timeManagerType != null) { _timeManagerInstanceField = _timeManagerType.GetField("Instance", BindingFlags.Static | BindingFlags.Public) ?? _timeManagerType.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic); _getExactTicksMethod = _timeManagerType.GetMethod("GetExactTicks", BindingFlags.Instance | BindingFlags.Public); } _reflectionCached = true; } } internal Camera GetCamera() { EnsureReflection(); if (_curCameraProperty != null) { try { object? value = _curCameraProperty.GetValue(null, null); Camera val = (Camera)((value is Camera) ? value : null); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } } return Camera.main; } internal Light GetMainLight() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 EnsureReflection(); if (_mainLightProperty != null) { try { object? value = _mainLightProperty.GetValue(null, null); Light val = (Light)((value is Light) ? value : null); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } } Light[] array = Object.FindObjectsOfType<Light>(); for (int i = 0; i < array.Length; i++) { if ((int)array[i].type == 1) { return array[i]; } } return null; } internal int GetIslandIndex() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) EnsureReflection(); if (_islandIndexProperty != null) { try { object value = _islandIndexProperty.GetValue(null, null); if (value is int result) { return result; } if (value is int result2) { return result2; } } catch { } } Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (string.IsNullOrEmpty(name)) { return -1; } if (name.IndexOf("Island", StringComparison.OrdinalIgnoreCase) >= 0) { for (int i = 1; i <= 6; i++) { if (name.IndexOf(i.ToString(), StringComparison.OrdinalIgnoreCase) >= 0) { return i - 1; } } return 0; } if (name.IndexOf("Game", StringComparison.OrdinalIgnoreCase) >= 0) { return 0; } return -1; } internal bool IsUnderWater(Vector3 position) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) EnsureReflection(); if (_isUnderWaterMethod != null) { try { if (_isUnderWaterMethod.Invoke(null, new object[1] { position }) is bool result) { return result; } } catch { } } return position.y < 0f; } internal AudioMixerGroup GetFxMixerGroup() { EnsureReflection(); if (_fxMixerGroupField != null) { try { object? value = _fxMixerGroupField.GetValue(null); return (AudioMixerGroup)((value is AudioMixerGroup) ? value : null); } catch { } } return null; } internal double GetSynchronizedTime(out bool isNetworkTime) { EnsureReflection(); if (_timeManagerInstanceField != null && _getExactTicksMethod != null) { try { object value = _timeManagerInstanceField.GetValue(null); if (value != null) { object obj = _getExactTicksMethod.Invoke(value, new object[1] { false }); if (obj is double) { isNetworkTime = true; return (double)obj; } } } catch { } } isNetworkTime = false; return DateTime.UtcNow.Subtract(new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; } internal bool CanUseLocalGameplayOverride() { return true; } } internal sealed class WeatherEffects : IDisposable { private struct StarData { public Vector3 localPos; public float magnitude; public Color baseColor; public float twinkleFreq; public float twinklePhase; public float baseSize; } private readonly ManualLogSource _log; private GameObject _root; private ParticleSystem _rain; private ParticleSystem _snow; private ParticleSystem _spray; private ParticleSystem _debris; private ParticleSystem _stars; private ParticleSystem _meteors; private Particle[] _starParticles; private List<StarData> _starDataList = new List<StarData>(); private float _nextMeteorSpawn = 0f; private WindZone _windZone; private AudioSource _rainAudio; private AudioSource _rainDetailAudio; private AudioSource _windAudio; private AudioSource _thunderAudio; private AudioClip _rainClip; private AudioClip _rainDetailClip; private AudioClip _windClip; private AudioClip[] _thunderClips; private AudioLowPassFilter _rainLowPass; private AudioLowPassFilter _rainDetailLowPass; private AudioLowPassFilter _windLowPass; private AudioLowPassFilter _thunderLowPass; private Texture2D _rainTexture; private Texture2D _softTexture; private Texture2D _debrisTexture; private Texture2D _starTexture; private Material _rainMaterial; private Material _softMaterial; private Material _debrisMaterial; private Material _starMaterial; private Volume _volume; private VolumeProfile _volumeProfile; private ColorAdjustments _colorAdjustments; private bool _created; private bool _creationFailed; private bool _active; private long _lastLightningBucket = long.MinValue; private float _flashAge = 99f; private double _pendingThunderTime = double.PositiveInfinity; private int _pendingThunderIndex; private float _pendingThunderVolume; private AudioMixerGroup _mixerGroup; internal float RainAmount { get; private set; } internal float SnowAmount { get; private set; } internal float WindAmount { get; private set; } internal float CloudAmount { get; private set; } internal float LightningAmount { get; private set; } internal WeatherEffects(ManualLogSource log) { _log = log; } internal void Tick(Camera camera, WeatherKind weather, float transitionSeconds, float windAngle, float dayFactor, float nightExposure, float effectIntensity, float particleQuality, float audioVolume, AudioMixerGroup mixerGroup, double synchronizedTime, int islandIndex, int seed, bool underwater, bool enableStars, float starBrightness, float midnightPeak) { if (EnsureCreated()) { SetActive(camera); BindMixerGroup(mixerGroup); GetTargets(weather, out var rain, out var snow, out var wind, out var cloud); float num = Time.unscaledDeltaTime / Mathf.Max(0.1f, transitionSeconds); RainAmount = Mathf.MoveTowards(RainAmount, rain, num); SnowAmount = Mathf.MoveTowards(SnowAmount, snow, num); WindAmount = Mathf.MoveTowards(WindAmount, wind, num); CloudAmount = Mathf.MoveTowards(CloudAmount, cloud, num); UpdateLightning(weather, synchronizedTime, islandIndex, seed, audioVolume, underwater); UpdateEmitterPositions(camera, windAngle); UpdateParticles(windAngle, effectIntensity, particleQuality, underwater); UpdateStars(camera, dayFactor, starBrightness, weather, enableStars, midnightPeak); UpdateAudio(audioVolume, underwater); UpdatePostProcessing(dayFactor, nightExposure, effectIntensity, midnightPeak); UpdateWindZone(windAngle, effectIntensity); } } internal void FadeOut(float transitionSeconds) { if (_created) { float num = Time.unscaledDeltaTime / Mathf.Max(0.1f, transitionSeconds); RainAmount = Mathf.MoveTowards(RainAmount, 0f, num); SnowAmount = Mathf.MoveTowards(SnowAmount, 0f, num); WindAmount = Mathf.MoveTowards(WindAmount, 0f, num); CloudAmount = Mathf.MoveTowards(CloudAmount, 0f, num); LightningAmount = 0f; _lastLightningBucket = long.MinValue; _flashAge = 99f; _pendingThunderTime = double.PositiveInfinity; _pendingThunderVolume = 0f; UpdateParticleRate(_rain, 0f); UpdateParticleRate(_snow, 0f); UpdateParticleRate(_spray, 0f); UpdateParticleRate(_debris, 0f); _rain.Clear(true); _snow.Clear(true); _spray.Clear(true); _debris.Clear(true); if ((Object)(object)_stars != (Object)null) { _stars.Clear(); } if ((Object)(object)_meteors != (Object)null) { _meteors.Clear(); } _rainAudio.volume = Mathf.MoveTowards(_rainAudio.volume, 0f, Time.unscaledDeltaTime); _rainDetailAudio.volume = Mathf.MoveTowards(_rainDetailAudio.volume, 0f, Time.unscaledDeltaTime); _windAudio.volume = Mathf.MoveTowards(_windAudio.volume, 0f, Time.unscaledDeltaTime); _volume.weight = Mathf.MoveTowards(_volume.weight, 0f, Time.unscaledDeltaTime * 2f); _windZone.windMain = 0f; } } internal void SetInactiveImmediate() { if (_created) { RainAmount = 0f; SnowAmount = 0f; WindAmount = 0f; CloudAmount = 0f; LightningAmount = 0f; _lastLightningBucket = long.MinValue; _flashAge = 99f; _pendingThunderTime = double.PositiveInfinity; _pendingThunderVolume = 0f; UpdateParticleRate(_rain, 0f); UpdateParticleRate(_snow, 0f); UpdateParticleRate(_spray, 0f); UpdateParticleRate(_debris, 0f); _rain.Clear(true); _snow.Clear(true); _spray.Clear(true); _debris.Clear(true); if ((Object)(object)_stars != (Object)null) { _stars.Clear(); } if ((Object)(object)_meteors != (Object)null) { _meteors.Clear(); } _rainAudio.Stop(); _rainDetailAudio.Stop(); _windAudio.Stop(); _thunderAudio.Stop(); _rainAudio.volume = 0f; _rainDetailAudio.volume = 0f; _windAudio.volume = 0f; _thunderAudio.volume = 0f; _volume.weight = 0f; _windZone.windMain = 0f; _active = false; _root.SetActive(false); } } private bool EnsureCreated() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (_created) { return true; } if (_creationFailed) { return false; } try { _root = new GameObject("WeatherExpansion_EffectsRoot"); ((Object)_root).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)_root); CreateMaterials(); CreateParticles(); CreateStarCanopy(); CreateAudio(); CreatePostProcessing(); _created = true; _active = true; return true; } catch (Exception ex) { _creationFailed = true; _log.LogError((object)("Failed to create weather effects: " + ex)); DestroyResources(); return false; } } private void SetActive(Camera camera) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (!_active) { _root.SetActive(true); _rainAudio.Play(); _rainDetailAudio.Play(); _windAudio.Play(); _active = true; } if (Object.op_Implicit((Object)(object)camera)) { _root.transform.position = ((Component)camera).transform.position; } } private void BindMixerGroup(AudioMixerGroup mixerGroup) { if (!((Object)(object)_mixerGroup == (Object)(object)mixerGroup)) { _mixerGroup = mixerGroup; _rainAudio.outputAudioMixerGroup = mixerGroup; _rainDetailAudio.outputAudioMixerGroup = mixerGroup; _windAudio.outputAudioMixerGroup = mixerGroup; _thunderAudio.outputAudioMixerGroup = mixerGroup; } } private static void GetTargets(WeatherKind weather, out float rain, out float snow, out float wind, out float cloud) { switch (weather) { case WeatherKind.Rain: rain = 0.58f; snow = 0f; wind = 0.35f; cloud = 0.65f; break; case WeatherKind.Storm: rain = 1f; snow = 0f; wind = 0.85f; cloud = 1f; break; case WeatherKind.Snow: rain = 0f; snow = 0.9f; wind = 0.4f; cloud = 0.7f; break; case WeatherKind.Hurricane: rain = 0.95f; snow = 0f; wind = 1f; cloud = 1f; break; default: rain = 0f; snow = 0f; wind = 0f; cloud = 0f; break; } } private void UpdateEmitterPositions(Camera camera, float windAngle) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_016f: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)camera)) { Vector3 position = ((Component)camera).transform.position; Vector3 forward = ((Component)camera).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 0.001f) { ((Vector3)(ref forward)).Normalize(); } else { forward = Vector3.forward; } float num = windAngle * ((float)Math.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num)); Vector3 val2 = position + forward * 4.5f; ((Component)_rain).transform.position = val2 + Vector3.up * 13f - val * (WindAmount * 3.5f); ((Component)_rain).transform.rotation = Quaternion.Euler(80f - WindAmount * 28f, windAngle + 180f, 0f); ((Component)_snow).transform.position = val2 + Vector3.up * 11f; ((Component)_snow).transform.rotation = Quaternion.Euler(75f - WindAmount * 18f, windAngle + 180f, 0f); ((Component)_spray).transform.position = position + val * 5f + Vector3.up * 1.8f; ((Component)_spray).transform.rotation = Quaternion.Euler(0f, windAngle, 0f); ((Component)_debris).transform.position = position - val * 6f + Vector3.up * 2.2f; ((Component)_debris).transform.rotation = Quaternion.Euler(0f, windAngle, 0f); if ((Object)(object)_stars != (Object)null) { ((Component)_stars).transform.position = position; } if ((Object)(object)_meteors != (Object)null) { ((Component)_meteors).transform.position = position; } } } private void UpdateParticles(float windAngle, float intensity, float quality, bool underwater) { if (underwater) { UpdateParticleRate(_rain, 0f); UpdateParticleRate(_snow, 0f); UpdateParticleRate(_spray, 0f); UpdateParticleRate(_debris, 0f); return; } float rate = Mathf.Pow(RainAmount, 1.25f) * 1150f * quality * intensity; float rate2 = Mathf.Pow(SnowAmount, 1.15f) * 360f * quality * intensity; float rate3 = ((WindAmount > 0.45f) ? ((WindAmount - 0.45f) / 0.55f) : 0f) * ((RainAmount > 0.2f) ? 240f : 60f) * quality * intensity; float rate4 = ((WindAmount > 0.65f) ? ((WindAmount - 0.65f) / 0.35f) : 0f) * 35f * quality * intensity; UpdateParticleRate(_rain, rate); UpdateParticleRate(_snow, rate2); UpdateParticleRate(_spray, rate3); UpdateParticleRate(_debris, rate4); } private void CreateStarCanopy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("Weather_StarCanopy"); val.transform.SetParent(_root.transform, false); _stars = val.AddComponent<ParticleSystem>(); MainModule main = _stars.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = 800; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = _stars.emission; ((EmissionModule)(ref emission)).enabled = false; ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).material = _starMaterial; component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).sortingOrder = -95; InitStarField(); _starParticles = (Particle[])(object)new Particle[_starDataList.Count]; _stars.SetParticles(_starParticles, _starDataList.Count); GameObject val2 = new GameObject("Weather_Meteors"); val2.transform.SetParent(_root.transform, false); _meteors = val2.AddComponent<ParticleSystem>(); MainModule main2 = _meteors.main; ((MainModule)(ref main2)).loop = true; ((MainModule)(ref main2)).playOnAwake = true; ((MainModule)(ref main2)).maxParticles = 30; ((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main2)).startLifetime = new MinMaxCurve(2f, 3.2f); ((MainModule)(ref main2)).startSpeed = new MinMaxCurve(50f, 85f); ((MainModule)(ref main2)).startSize = new MinMaxCurve(1.5f, 3.2f); ((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 1f, 1f, 1f)); EmissionModule emission2 = _meteors.emission; ((EmissionModule)(ref emission2)).enabled = true; ((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(0f); ParticleSystemRenderer component2 = val2.GetComponent<ParticleSystemRenderer>(); ((Renderer)component2).material = _starMaterial; component2.renderMode = (ParticleSystemRenderMode)1; component2.velocityScale = 0.035f; component2.lengthScale = 2f; ((Renderer)component2).sortingOrder = -94; } catch (Exception ex) { _log.LogWarning((object)("Star canopy initialization error: " + ex.Message)); } } private void InitStarField() { //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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) _starDataList.Clear(); Random random = new Random(4001890); int num = 1200; float num2 = 220f; Color baseColor = default(Color); for (int i = 0; i < num; i++) { float num3 = (float)random.NextDouble(); float num4 = (float)random.NextDouble(); float num5 = num3 * 2f * (float)Math.PI; float num6 = Mathf.Acos(1f - num4 * 0.94f); float num7 = Mathf.Sin(num6); float num8 = num2 * num7 * Mathf.Cos(num5); float num9 = num2 * Mathf.Cos(num6) + 15f; float num10 = num2 * num7 * Mathf.Sin(num5); float num11 = (float)random.NextDouble(); float twinkleFreq = 0.8f + (float)random.NextDouble() * 2.5f; float twinklePhase = (float)random.NextDouble() * (float)Math.PI * 2f; double num12 = random.NextDouble(); if (num12 < 0.7) { ((Color)(ref baseColor))..ctor(1f, 1f, 1f, 1f); } else if (num12 < 0.88) { ((Color)(ref baseColor))..ctor(0.92f, 0.96f, 1f, 1f); } else { ((Color)(ref baseColor))..ctor(1f, 0.98f, 0.92f, 1f); } float baseSize = Mathf.Lerp(2.2f, 5.8f, Mathf.Pow(num11, 1.3f)); _starDataList.Add(new StarData { localPos = new Vector3(num8, num9, num10), magnitude = num11, baseColor = baseColor, twinkleFreq = twinkleFreq, twinklePhase = twinklePhase, baseSize = baseSize }); } } private void UpdateStars(Camera camera, float dayFactor, float starBrightness, WeatherKind weather, bool enableStars, float midnightPeak) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_stars == (Object)null || !enableStars || !Object.op_Implicit((Object)(object)camera)) { if ((Object)(object)_stars != (Object)null) { _stars.Clear(); } if ((Object)(object)_meteors != (Object)null) { UpdateParticleRate(_meteors, 0f); } return; } float num = Mathf.Clamp01((0.55f - dayFactor) / 0.4f); float num2 = weather switch { WeatherKind.Snow => 0.4f, WeatherKind.Clear => 1f, _ => 0f, }; float num3 = starBrightness * 3.5f * (1f + 0.65f * midnightPeak); float num4 = num * num2 * num3; if (num4 > 0.005f && _starDataList.Count > 0) { Vector3 position = ((Component)camera).transform.position; float time = Time.time; Quaternion val = Quaternion.Euler(0.02f * time, 25f, 0f); if (_starParticles == null || _starParticles.Length != _starDataList.Count) { _starParticles = (Particle[])(object)new Particle[_starDataList.Count]; } Color val2 = default(Color); for (int i = 0; i < _starDataList.Count; i++) { StarData starData = _starDataList[i]; float num5 = Mathf.Lerp(0.7f, 0.05f, starData.magnitude); float num6 = Mathf.Clamp01((num - num5) / 0.15f); if (num6 > 0f) { float num7 = 0.8f + 0.2f * Mathf.Sin(time * starData.twinkleFreq + starData.twinklePhase); float num8 = num6 * num7 * num2 * num3; ((Color)(ref val2))..ctor(Mathf.Min(4f, starData.baseColor.r * num8), Mathf.Min(4f, starData.baseColor.g * num8), Mathf.Min(4f, starData.baseColor.b * num8), Mathf.Clamp01(num8)); ((Particle)(ref _starParticles[i])).position = position + val * starData.localPos; ((Particle)(ref _starParticles[i])).startColor = Color32.op_Implicit(val2); ((Particle)(ref _starParticles[i])).startSize = starData.baseSize * (1f + 0.2f * midnightPeak); } else { ((Particle)(ref _starParticles[i])).startColor = Color32.op_Implicit(new Color(0f, 0f, 0f, 0f)); } } _stars.SetParticles(_starParticles, _starDataList.Count); if ((Object)(object)_meteors != (Object)null && num > 0.2f && weather == WeatherKind.Clear) { if (Time.time >= _nextMeteorSpawn) { float num9 = Mathf.Lerp(3.2f, 1.4f, midnightPeak); _nextMeteorSpawn = Time.time + Random.Range(num9 * 0.7f, num9 * 1.4f); SpawnShootingStar(position); } } else if ((Object)(object)_meteors != (Object)null) { UpdateParticleRate(_meteors, 0f); } } else { _stars.Clear(); if ((Object)(object)_meteors != (Object)null) { UpdateParticleRate(_meteors, 0f); } } } private void SpawnShootingStar(Vector3 camPos) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_meteors == (Object)null)) { float num = Random.Range(0f, 360f) * ((float)Math.PI / 180f); float num2 = Random.Range(90f, 160f); float num3 = Random.Range(70f, 140f); Vector3 position = camPos + new Vector3(Mathf.Cos(num) * num2, num3, Mathf.Sin(num) * num2); float num4 = Random.Range(65f, 105f); float num5 = Random.Range(0f, 360f) * ((float)Math.PI / 180f); Vector3 val = new Vector3(Mathf.Cos(num5), -0.4f, Mathf.Sin(num5)); Vector3 normalized = ((Vector3)(ref val)).normalized; EmitParams val2 = default(EmitParams); ((EmitParams)(ref val2)).position = position; ((EmitParams)(ref val2)).velocity = normalized * num4; ((EmitParams)(ref val2)).startLifetime = Random.Range(1.6f, 2.6f); ((EmitParams)(ref val2)).startSize = Random.Range(4f, 7.5f); ((EmitParams)(ref val2)).startColor = Color32.op_Implicit(new Color(3f, 3f, 3f, 1f)); _meteors.Emit(val2, 1); } } private void UpdateLightning(WeatherKind weather, double synchronizedTime, int islandIndex, int seed, float audioVolume, bool underwater) { if (weather != WeatherKind.Storm && weather != WeatherKind.Hurricane) { LightningAmount = 0f; _lastLightningBucket = long.MinValue; _flashAge = 99f; _pendingThunderTime = double.PositiveInfinity; return; } long num = (long)Math.Floor(synchronizedTime / 7.5); if (num != _lastLightningBucket) { _lastLightningBucket = num; int percentChance = ((weather == WeatherKind.Storm) ? 42 : 58); if (WeatherScheduler.ShouldTriggerLightning(islandIndex, num, seed, percentChance)) { _flashAge = 0f; _pendingThunderTime = synchronizedTime + 0.35 + (double)(num % 5) * 0.18; _pendingThunderIndex = (int)(num % (uint)_thunderClips.Length); _pendingThunderVolume = Mathf.Clamp01(0.72f + (float)(num % 4) * 0.08f) * audioVolume; _thunderAudio.pitch = WeatherScheduler.LightningPitch(islandIndex, num, seed); } } _flashAge += Time.unscaledDeltaTime; if (_flashAge < 0.28f) { float num2 = _flashAge / 0.28f; float num3 = 1f - Mathf.Clamp01(num2 / 0.35f); float num4 = ((num2 > 0.4f) ? (1f - Mathf.Clamp01((num2 - 0.4f) / 0.6f)) : 0f); LightningAmount = Mathf.Max(num3, num4 * 0.65f); } else { LightningAmount = 0f; } if (!underwater && synchronizedTime >= _pendingThunderTime) { _pendingThunderTime = double.PositiveInfinity; if (_thunderClips != null && _thunderClips.Length > 0 && _pendingThunderVolume > 0.001f) { _thunderAudio.PlayOneShot(_thunderClips[_pendingThunderIndex], _pendingThunderVolume); } } } private void UpdateAudio(float audioVolume, bool underwater) { float num = RainAmount * audioVolume; float num2 = WindAmount * audioVolume; _rainAudio.volume = Mathf.MoveTowards(_rainAudio.volume, num * 0.9f, Time.unscaledDeltaTime * 2f); _rainDetailAudio.volume = Mathf.MoveTowards(_rainDetailAudio.volume, num * 0.62f, Time.unscaledDeltaTime * 2f); _windAudio.volume = Mathf.MoveTowards(_windAudio.volume, num2 * 0.92f, Time.unscaledDeltaTime * 2f); float cutoffFrequency = (underwater ? 950f : 22000f); _rainLowPass.cutoffFrequency = cutoffFrequency; _rainDetailLowPass.cutoffFrequency = cutoffFrequency; _windLowPass.cutoffFrequency = cutoffFrequency; _thunderLowPass.cutoffFrequency = cutoffFrequency; } private void UpdatePostProcessing(float dayFactor, float nightExposure, float effectIntensity, float midnightPeak) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_colorAdjustments)) { float num = Mathf.Lerp(nightExposure, 0f, dayFactor); float num2 = -0.75f * midnightPeak * (1f - dayFactor); float num3 = (0f - CloudAmount) * 0.65f * effectIntensity; float num4 = LightningAmount * 1.55f * effectIntensity; ((VolumeParameter<float>)(object)_colorAdjustments.postExposure).value = num + num2 + num3 + num4; ((VolumeParameter<float>)(object)_colorAdjustments.contrast).value = Mathf.Lerp(18f, 0f, dayFactor) + CloudAmount * 8f; ((VolumeParameter<float>)(object)_colorAdjustments.saturation).value = Mathf.Lerp(-22f, 0f, dayFactor) - CloudAmount * 18f; Color val = default(Color); ((Color)(ref val))..ctor(0.85f, 0.9f, 0.98f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.35f, 0.44f, 0.6f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.55f, 0.68f, 0.88f, 1f); Color val4 = Color.Lerp(val3, val2, midnightPeak); Color val5 = Color.Lerp(val4, Color.white, dayFactor); val5 = Color.Lerp(val5, val, CloudAmount * 0.6f); ((VolumeParameter<Color>)(object)_colorAdjustments.colorFilter).value = val5; _volume.weight = Mathf.MoveTowards(_volume.weight, 1f, Time.unscaledDeltaTime * 3f); } } private void UpdateWindZone(float windAngle, float effectIntensity) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_windZone)) { ((Component)_windZone).transform.rotation = Quaternion.Euler(0f, windAngle, 0f); _windZone.windMain = WindAmount * 1.6f * effectIntensity; _windZone.windTurbulence = WindAmount * 1.2f * effectIntensity; _windZone.windPulseMagnitude = WindAmount * 0.65f * effectIntensity; _windZone.windPulseFrequency = 0.18f + WindAmount * 0.45f; } } private void CreateMaterials() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Universal Render Pipeline/Particles/Unlit") ?? Shader.Find("UI/Default") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Mobile/Particles/Alpha Blended"); _rainTexture = CreateRainTexture(); _softTexture = CreateSoftCircleTexture(); _debrisTexture = CreateDebrisTexture(); _starTexture = CreateStarTexture(); Material val2 = new Material(val); ((Object)val2).hideFlags = (HideFlags)61; val2.mainTexture = (Texture)(object)_rainTexture; _rainMaterial = val2; Material val3 = new Material(val); ((Object)val3).hideFlags = (HideFlags)61; val3.mainTexture = (Texture)(object)_softTexture; _softMaterial = val3; Material val4 = new Material(val); ((Object)val4).hideFlags = (HideFlags)61; val4.mainTexture = (Texture)(object)_debrisTexture; _debrisMaterial = val4; Material val5 = new Material(val); ((Object)val5).hideFlags = (HideFlags)61; val5.mainTexture = (Texture)(object)_starTexture; _starMaterial = val5; SetupMaterialBlendMode(_rainMaterial); SetupMaterialBlendMode(_softMaterial); SetupMaterialBlendMode(_debrisMaterial); SetupStarMaterialBlendMode(_starMaterial); } private static void SetupMaterialBlendMode(Material material) { if (Object.op_Implicit((Object)(object)material)) { if (material.HasProperty("_Surface")) { material.SetFloat("_Surface", 1f); } if (material.HasProperty("_Blend")) { material.SetFloat("_Blend", 0f); } if (material.HasProperty("_SrcBlend")) { material.SetFloat("_SrcBlend", 5f); } if (material.HasProperty("_DstBlend")) { material.SetFloat("_DstBlend", 10f); } if (material.HasProperty("_ZWrite")) { material.SetFloat("_ZWrite", 0f); } if (material.HasProperty("_Cull")) { material.SetFloat("_Cull", 0f); } material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); material.EnableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.DisableKeyword("_ALPHAMODULATE_ON"); material.DisableKeyword("_SURFACE_TYPE_OPAQUE"); material.renderQueue = 3050; } } private static void SetupStarMaterialBlendMode(Material material) { if (Object.op_Implicit((Object)(object)material)) { if (material.HasProperty("_Surface")) { material.SetFloat("_Surface", 1f); } if (material.HasProperty("_Blend")) { material.SetFloat("_Blend", 1f); } if (material.HasProperty("_SrcBlend")) { material.SetFloat("_SrcBlend", 5f); } if (material.HasProperty("_DstBlend")) { material.SetFloat("_DstBlend", 1f); } if (material.HasProperty("_ZWrite")) { material.SetFloat("_ZWrite", 0f); } if (material.HasProperty("_Cull")) { material.SetFloat("_Cull", 0f); } material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_SURFACE_TYPE_OPAQUE"); material.renderQueue = 3100; } } private void CreateParticles() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Expected O, but got Unknown _rain = CreateEmitter("Rain", _rainMaterial, (ParticleSystemRenderMode)1, 2200); MainModule main = _rain.main; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.45f, 0.65f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(32f, 44f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.08f, 0.14f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.85f, 0.92f, 1f, 0.68f)); ShapeModule shape = _rain.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = new Vector3(28f, 28f, 1f); ParticleSystemRenderer component = ((Component)_rain).GetComponent<ParticleSystemRenderer>(); component.lengthScale = 3.2f; component.velocityScale = 0.05f; _snow = CreateEmitter("Snow", _softMaterial, (ParticleSystemRenderMode)0, 1400); MainModule main2 = _snow.main; ((MainModule)(ref main2)).startLifetime = new MinMaxCurve(3.5f, 5.5f); ((MainModule)(ref main2)).startSpeed = new MinMaxCurve(2.2f, 4.8f); ((MainModule)(ref main2)).startSize = new MinMaxCurve(0.12f, 0.28f); ((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(new Color(0.96f, 0.98f, 1f, 0.85f)); ShapeModule shape2 = _snow.shape; ((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape2)).scale = new Vector3(32f, 32f, 6f); NoiseModule noise = _snow.noise; ((NoiseModule)(ref noise)).enabled = true; ((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.85f); ((NoiseModule)(ref noise)).frequency = 0.25f; _spray = CreateEmitter("Spray", _softMaterial, (ParticleSystemRenderMode)0, 900); MainModule main3 = _spray.main; ((MainModule)(ref main3)).startLifetime = new MinMaxCurve(0.8f, 1.4f); ((MainModule)(ref main3)).startSpeed = new MinMaxCurve(10f, 22f); ((MainModule)(ref main3)).startSize = new MinMaxCurve(0.6f, 1.8f); ((MainModule)(ref main3)).startColor = MinMaxGradient.op_Implicit(new Color(0.85f, 0.92f, 1f, 0.24f)); ShapeModule shape3 = _spray.shape; ((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape3)).angle = 22f; ((ShapeModule)(ref shape3)).radius = 4f; _debris = CreateEmitter("Debris", _debrisMaterial, (ParticleSystemRenderMode)0, 220); MainModule main4 = _debris.main; ((MainModule)(ref main4)).startLifetime = new MinMaxCurve(1.2f, 2.2f); ((MainModule)(ref main4)).startSpeed = new MinMaxCurve(14f, 28f); ((MainModule)(ref main4)).startSize = new MinMaxCurve(0.15f, 0.35f); ((MainModule)(ref main4)).startColor = MinMaxGradient.op_Implicit(new Color(0.35f, 0.45f, 0.3f, 0.8f)); ShapeModule shape4 = _debris.shape; ((ShapeModule)(ref shape4)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape4)).scale = new Vector3(18f, 6f, 12f); GameObject val = new GameObject("WindZone"); val.transform.SetParent(_root.transform, false); _windZone = val.AddComponent<WindZone>(); _windZone.mode = (WindZoneMode)0; } private ParticleSystem CreateEmitter(string name, Material material, ParticleSystemRenderMode mode, int maxParticles) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(_root.transform, false); ParticleSystem val2 = val.AddComponent<ParticleSystem>(); MainModule main = val2.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).maxParticles = maxParticles; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).material = material; component.renderMode = mode; ((Renderer)component).sortingOrder = 50; return val2; } private void CreateAudio() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("WeatherAudio"); val.transform.SetParent(_root.transform, false); _rainAudio = CreateAudioSource(val, "RainAudio", loop: true); _rainDetailAudio = CreateAudioSource(val, "RainDetailAudio", loop: true); _windAudio = CreateAudioSource(val, "WindAudio", loop: true); _thunderAudio = CreateAudioSource(val, "ThunderAudio", loop: false); _rainLowPass = ((Component)_rainAudio).gameObject.AddComponent<AudioLowPassFilter>(); _rainDetailLowPass = ((Component)_rainDetailAudio).gameObject.AddComponent<AudioLowPassFilter>(); _windLowPass = ((Component)_windAudio).gameObject.AddComponent<AudioLowPassFilter>(); _thunderLowPass = ((Component)_thunderAudio).gameObject.AddComponent<AudioLowPassFilter>(); _rainClip = SynthesizeRainLoop(44100, 6f); _rainDetailClip = SynthesizeRainDetailLoop(44100, 5f); _windClip = SynthesizeWindLoop(44100, 7f); _thunderClips = (AudioClip[])(object)new AudioClip[3] { SynthesizeThunder(44100, 3.8f, 0), SynthesizeThunder(44100, 4.4f, 1), SynthesizeThunder(44100, 5.2f, 2) }; _rainAudio.clip = _rainClip; _rainDetailAudio.clip = _rainDetailClip; _windAudio.clip = _windClip; } private AudioSource CreateAudioSource(GameObject parent, string name, bool loop) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent.transform, false); AudioSource val2 = val.AddComponent<AudioSource>(); val2.loop = loop; val2.playOnAwake = false; val2.spatialBlend = 0f; val2.volume = 0f; return val2; } private void CreatePostProcessing() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("PostProcessingVolume"); val.transform.SetParent(_root.transform, false); _volume = val.AddComponent<Volume>(); _volume.isGlobal = true; _volume.weight = 0f; _volumeProfile = ScriptableObject.CreateInstance<VolumeProfile>(); ((Object)_volumeProfile).hideFlags = (HideFlags)61; _volume.profile = _volumeProfile; _colorAdjustments = _volumeProfile.Add<ColorAdjustments>(true); ((VolumeComponent)_colorAdjustments).active = true; ((VolumeParameter)_colorAdjustments.postExposure).overrideState = true; ((VolumeParameter)_colorAdjustments.contrast).overrideState = true; ((VolumeParameter)_colorAdjustments.colorFilter).overrideState = true; ((VolumeParameter)_colorAdjustments.saturation).overrideState = true; } private static Texture2D CreateRainTexture() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) int num = 4; int num2 = 32; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[num * num2]; for (int i = 0; i < num2; i++) { float num3 = (float)i / (float)(num2 - 1); float num4 = Mathf.SmoothStep(0f, 1f, num3) * (1f - Mathf.Pow(num3, 6f)); for (int j = 0; j < num; j++) { float num5 = 1f - Mathf.Abs(((float)j - (float)(num - 1) / 2f) / ((float)(num - 1) / 2f)); num5 = Mathf.Clamp01(num5); ref Color reference = ref array[i * num + j]; reference = new Color(1f, 1f, 1f, num4 * num5); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D CreateSoftCircleTexture() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) int num = 64; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[num * num]; float num2 = (float)(num - 1) / 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)) / num2; float num4 = Mathf.Clamp01(1f - num3); num4 = Mathf.Pow(num4, 2.2f); ref Color reference = ref array[i * num + j]; reference = new Color(1f, 1f, 1f, num4); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D CreateDebrisTexture() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) int num = 32; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[num * num]; float num2 = (float)(num - 1) / 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)) / num2; float num4 = Mathf.Clamp01(1f - num3); num4 = Mathf.Pow(num4, 1.8f); ref Color reference = ref array[i * num + j]; reference = new Color(1f, 1f, 1f, num4); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D CreateStarTexture() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) int num = 64; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[num * num]; 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); float num7 = Mathf.Pow(num6, 3.5f) * 1.6f; float num8 = Mathf.Pow(num6, 1.4f) * 0.45f; float num9 = Mathf.Pow(Mathf.Clamp01(1f - Mathf.Abs(num3)), 16f) * Mathf.Pow(Mathf.Clamp01(1f - Mathf.Abs(num4 * 3.2f)), 2.2f); float num10 = Mathf.Pow(Mathf.Clamp01(1f - Mathf.Abs(num4)), 16f) * Mathf.Pow(Mathf.Clamp01(1f - Mathf.Abs(num3 * 3.2f)), 2.2f); float num11 = (num9 + num10) * 0.4f; float num12 = Mathf.Clamp01(num7 + num8 + num11); ref Color reference = ref array[i * num + j]; reference = new Color(1f, 1f, 1f, num12); } } val.SetPixels(array); val.Apply(); return val; } private static AudioClip SynthesizeRainLoop(int sampleRate, float lengthSeconds) { int num = Mathf.RoundToInt((float)sampleRate * lengthSeconds); int num2 = 2; int num3 = num + sampleRate; float[] array = new float[num3 * num2]; Random random = new Random(1337); float num4 = 0f; float num5 = 0f; for (int i = 0; i < num3; i++) { float num6 = (float)(random.NextDouble() * 2.0 - 1.0); float num7 = (float)(random.NextDouble() * 2.0 - 1.0); num4 = num4 * 0.94f + num6 * 0.06f; num5 = num5 * 0.94f + num7 * 0.06f; array[i * 2] = Mathf.Clamp(num4 * 1.8f + num6 * 0.15f, -0.95f, 0.95f); array[i * 2 + 1] = Mathf.Clamp(num5 * 1.8f + num7 * 0.15f, -0.95f, 0.95f); } float[] array2 = BuildLoop(array, num, num2, sampleRate / 2); AudioClip val = AudioClip.Create("WeatherExpansion.RainLoop", num, num2, sampleRate, false); ((Object)val).hideFlags = (HideFlags)61; val.SetData(array2, 0); return val; } private static AudioClip SynthesizeRainDetailLoop(int sampleRate, float lengthSeconds) { int num = Mathf.RoundToInt((float)sampleRate * lengthSeconds); int num2 = 2; int num3 = num + sampleRate; float[] array = new float[num3 * num2]; Random random = new Random(2442); for (int i = 0; i < num3; i++) { array[i * 2 + 1] = (array[i * 2] = ((random.NextDouble() < 0.008) ? ((float)(random.NextDouble() * 1.6 - 0.8)) : 0f)) * 0.85f; } float[] array2 = BuildLoop(array, num, num2, sampleRate / 2); AudioClip val = AudioClip.Create("WeatherExpansion.RainDetailLoop", num, num2, sampleRate, false); ((Object)val).hideFlags = (HideFlags)61; val.SetData(array2, 0); return val; } private static AudioClip SynthesizeWindLoop(int sampleRate, float lengthSeconds) { int num = Mathf.RoundToInt((float)sampleRate * lengthSeconds); int num2 = 2; int num3 = num + sampleRate; float[] array = new float[num3 * num2]; Random random = new Random(3553); float num4 = 0f; float num5 = 0f; for (int i = 0; i < num3; i++) { float num6 = (float)i / (float)sampleRate; float num7 = 0.75f + 0.25f * Mathf.Sin(num6 * 1.4f); float num8 = (float)(random.NextDouble() * 2.0 - 1.0); float num9 = (float)(random.NextDouble() * 2.0 - 1.0); num4 = num4 * 0.985f + num8 * 0.015f; num5 = num5 * 0.985f + num9 * 0.015f; array[i * 2] = Mathf.Clamp(num4 * 2.8f * num7, -0.95f, 0.95f); array[i * 2 + 1] = Mathf.Clamp(num5 * 2.8f * num7, -0.95f, 0.95f); } float[] array2 = BuildLoop(array, num, num2, sampleRate / 2); AudioClip val = AudioClip.Create("WeatherExpansion.WindLoop", num, num2, sampleRate, false); ((Object)val).hideFlags = (HideFlags)61; val.SetData(array2, 0); return val; } private static AudioClip SynthesizeThunder(int sampleRate, float lengthSeconds, int variant) { int num = Mathf.RoundToInt((float)sampleRate * lengthSeconds); int num2 = 2; float[] array = new float[num * num2]; Random random = new Random(4664 + variant * 101); float num3 = 0f; float num4 = 0f; int num5 = Mathf.RoundToInt((float)sampleRate * (0.24f + (float)variant * 0.06f)); float num6 = 34f + (float)variant * 8f; for (int i = 0; i < num; i++) { float num7 = (float)i / (float)sampleRate; float num8 = Mathf.Exp((0f - num7) * (1.1f + (float)variant * 0.2f)); float num9 = (float)(random.NextDouble() * 2.0 - 1.0); float num10 = (float)(random.NextDouble() * 2.0 - 1.0); num3 = num3 * 0.982f + num9 * 0.018f; num4 = num4 * 0.982f + num10 * 0.018f; float num11 = Mathf.Sin(num7 * (float)Math.PI * 2f * num6) * 0.18f + Mathf.Sin(num7 * (float)Math.PI * 2f * (num6 * 0.57f)) * 0.11f; float num12 = ((num7 < 0.085f) ? (1f - num7 / 0.085f) : 0f); float num13 = (num3 * 2.4f + num11 + num9 * num12 * 0.78f) * num8; float num14 = (num4 * 2.4f + num11 + num10 * num12 * 0.78f) * num8; if (i >= num5) { num13 += array[(i - num5) * num2 + 1] * 0.18f; num14 += array[(i - num5) * num2] * 0.18f; } array[i * num2] = Mathf.Clamp(num13, -0.96f, 0.96f); array[i * num2 + 1] = Mathf.Clamp(num14, -0.96f, 0.96f); } AudioClip val = AudioClip.Create("WeatherExpansion.Thunder" + (variant + 1), num, num2, sampleRate, false); ((Object)val).hideFlags = (HideFlags)61; val.SetData(array, 0); return val; } private static float[] BuildLoop(float[] raw, int frames, int channels, int fadeFrames) { float[] array = new float[frames * channels]; Array.Copy(raw, array, array.Length); int num = raw.Length / channels - frames; fadeFrames = Mathf.Clamp(fadeFrames, 2, Mathf.Min(frames / 3, num)); for (int i = 0; i < fadeFrames; i++) { float num2 = Mathf.SmoothStep(0f, 1f, (float)i / (float)(fadeFrames - 1)); for (int j = 0; j < channels; j++) { int num3 = i * channels + j; int num4 = (frames + i) * channels + j; array[num3] = Mathf.Lerp(raw[num4], raw[num3], num2); } } return array; } private static void UpdateParticleRate(ParticleSystem system, float rate) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)system == (Object)null)) { EmissionModule emission = system.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Max(0f, rate)); } } public void Dispose() { DestroyResources(); _created = false; } private void DestroyResources() { if (Object.op_Implicit((Object)(object)_root)) { Object.Destroy((Object)(object)_root); } if (Object.op_Implicit((Object)(object)_volumeProfile)) { Object.Destroy((Object)(object)_volumeProfile); } if (Object.op_Implicit((Object)(object)_rainMaterial)) { Object.Destroy((Object)(object)_rainMaterial); } if (Object.op_Implicit((Object)(object)_softMaterial)) { Object.Destroy((Object)(object)_softMaterial); } if (Object.op_Implicit((Object)(object)_debrisMaterial)) { Object.Destroy((Object)(object)_debrisMaterial); } if (Object.op_Implicit((Object)(object)_starMaterial)) { Object.Destroy((Object)(object)_starMaterial); } if (Object.op_Implicit((Object)(object)_rainTexture)) { Object.Destroy((Object)(object)_rainTexture); } if (Object.op_Implicit((Object)(object)_softTexture)) { Object.Destroy((Object)(object)_softTexture); } if (Object.op_Implicit((Object)(object)_debrisTexture)) { Object.Destroy((Object)(object)_debrisTexture); } if (Object.op_Implicit((Object)(object)_starTexture)) { Object.Destroy((Object)(object)_starTexture); } if (Object.op_Implicit((Object)(object)_rainClip)) { Object.Destroy((Object)(object)_rainClip); } if (Object.op_Implicit((Object)(object)_rainDetailClip)) { Object.Destroy((Object)(object)_rainDetailClip); } if (Object.op_Implicit((Object)(object)_windClip)) { Object.Destroy((Object)(object)_windClip); } if (_thunderClips != null) { AudioClip[] thunderClips = _thunderClips; foreach (AudioClip val in thunderClips) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } _root = null; _volumeProfile = null; _rainMaterial = null; _softMaterial = null; _debrisMaterial = null; _starMaterial = null; _rainTexture = null; _softTexture = null; _debrisTexture = null; _starTexture = null; _rainClip = null; _rainDetailClip = null; _windClip = null; _thunderClips = null; _mixerGroup = null; _stars = null; _meteors = null; _starParticles = null; _starDataList.Clear(); } } internal sealed class GameplayEffects : IDisposable { private struct MovementBaseline { internal float Acceleration; internal float BackwardAcceleration; internal float Deceleration; internal float MaxVelocity; internal float SlopeLimit; internal bool Captured; } private struct GameplayProfile { internal float PlayerTraction; internal float PlayerFriction; internal float PlayerSlopeModifier; internal float PlayerGust; internal float BoatWind; internal float BoatYaw; internal float BiteTimeMultiplier; internal static GameplayProfile For(WeatherKind weather) { return weather switch { WeatherKind.Rain => new GameplayProfile { PlayerTraction = 0.88f, PlayerFriction = 0.9f, PlayerSlopeModifier = -4f, PlayerGust = 0.45f, BoatWind = 0.85f, BoatYaw = 0.45f, BiteTimeMultiplier = 0.82f }, WeatherKind.Storm => new GameplayProfile { PlayerTraction = 0.76f, PlayerFriction = 0.8f, PlayerSlopeModifier = -8f, PlayerGust = 1.65f, BoatWind = 2.45f, BoatYaw = 1.35f, BiteTimeMultiplier = 0.72f }, WeatherKind.Snow => new GameplayProfile { PlayerTraction = 0.68f, PlayerFriction = 0.72f, PlayerSlopeModifier = -10f, PlayerGust = 0.65f, BoatWind = 0.6f, BoatYaw = 0.3f, BiteTimeMultiplier = 1.15f }, WeatherKind.Hurricane => new GameplayProfile { PlayerTraction = 0.58f, PlayerFriction = 0.62f, PlayerSlopeModifier = -14f, PlayerGust = 3.2f, BoatWind = 4.6f, BoatYaw = 2.4f, BiteTimeMultiplier = 0.65f }, _ => new GameplayProfile { PlayerTraction = 1f, PlayerFriction = 1f, PlayerSlopeModifier = 0f, PlayerGust = 0f, BoatWind = 0f, BoatYaw = 0f, BiteTimeMultiplier = 1f }, }; } } private readonly ManualLogSource _log; private MovementBaseline _movementBaseline; private object _lastMovementObject; private double _lastWarnTime; private PropertyInfo _movementAccelerationProperty; private PropertyInfo _movementBackwardAccelerationProperty; private PropertyInfo _movementDecelerationProperty; private PropertyInfo _movementMaxVelocityProperty; private PropertyInfo _movementSlopeLimitProperty; private PropertyInfo _movementOnBoatProperty; private PropertyInfo _movementVelocityProperty; private PropertyInfo _movementGroundedProperty; private Type _playerManagerType; private PropertyInfo _playersProperty; private PropertyInfo _localPlayerProperty; private PropertyInfo _movementProperty; private Type _boatManagerType; private PropertyInfo _boatProperty; private PropertyInfo _boatHiddenRigProperty; private PropertyInfo _boatPropellerInWaterField; private PropertyInfo _isServerInitializedProperty; private Type _creatureManagerType; private PropertyInfo _creatureManagerInstanceProperty; private FieldInfo _biteTimeField; private float _baselineBiteTime = -1f; private bool _reflectionCached; internal GameplayEffects(ManualLogSource log) { _log = log; } internal void Tick(WeatherKind weather, float windAngle, double synchronizedTime, int islandIndex, int seed, bool underwater, float strength, float transitionSeconds) { if (underwater || strength <= 0f) { Restore(); return; } EnsureReflectionCache(); GameplayProfile profile = GameplayProfile.For(weather); float amount = Mathf.Clamp01(strength); UpdateFishing(profile, amount); UpdatePlayer(profile, windAngle, synchronizedTime, islandIndex, seed, amount); } internal void FixedTick(WeatherKind weather, float windAngle, double synchronizedTime, int islandIndex, int seed, float strength) { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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) if (strength <= 0f) { return; } EnsureReflectionCache(); GameplayProfile gameplayProfile = GameplayProfile.For(weather); float num = Mathf.Clamp01(strength); if (num <= 0f || gameplayProfile.BoatWind <= 0f) { return; } try { object obj = ((_boatProperty != null) ? _boatProperty.GetValue(null, null) : null); if (IsAlive(obj) && ReadBool(_isServerInitializedProperty, obj) && ReadBool(_boatPropellerInWaterField, obj)) { Rigidbody val = (Rigidbody)((_boatHiddenRigProperty != null) ? /*isinst with value type is only supported in some contexts*/: null); if (Object.op_Implicit((Object)(object)val) && !val.isKinematic) { float num2 = windAngle * ((float)Math.PI / 180f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2)); long pulseBucket = (long)Math.Floor(synchronizedTime * 0.55); float num3 = WeatherScheduler.GameplayVariation(islandIndex, pulseBucket, seed, 45127u); float num4 = 0.78f + 0.22f * Mathf.Sin((float)synchronizedTime * 1.71f + num3 * (float)Math.PI); val.AddForce(val2 * (gameplayProfile.BoatWind * num * num4), (ForceMode)5); Vector3 val3 = Vector3.Cross(Vector3.up, val2); Vector3 normalized = ((Vector3)(ref val3)).normalized; Vector3 val4 = Vector3.up * (gameplayProfile.BoatYaw * num3) + normalized * (gameplayProfile.BoatYaw * 0.32f * num4); val.AddTorque(val4 * num, (ForceMode)5); } } } catch (Exception ex) { WarnOccasionally("Boat wind physics skipped: " + ex.Message); } } private void UpdatePlayer(GameplayProfile profile, float windAngle, double synchronizedTime, int islandIndex, int seed, float amount) { //IL_01bb: 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_01ea: 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_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) object localPlayerMovement = GetLocalPlayerMovement(); if (!IsAlive(localPlayerMovement)) { RestoreMovement(); return; } CaptureMovementBaseline(localPlayerMovement); float num = Mathf.Lerp(1f, profile.PlayerTraction, amount); float num2 = Mathf.Lerp(1f, profile.PlayerFriction, amount); float num3 = Mathf.Lerp(0f, profile.PlayerSlopeModifier, amount); WriteFloat(_movementAccelerationProperty, localPlayerMovement, _movementBaseline.Acceleration * num); WriteFloat(_movementBackwardAccelerationProperty, localPlayerMovement, _movementBaseline.BackwardAcceleration * num); WriteFloat(_movementDecelerationProperty, localPlayerMovement, _movementBaseline.Deceleration * num2); WriteFloat(_movementMaxVelocityProperty, localPlayerMovement, _movementBaseline.MaxVelocity * (0.85f + 0.15f * num)); WriteFloat(_movementSlopeLimitProperty, localPlayerMovement, Mathf.Clamp(_movementBaseline.SlopeLimit + num3, 15f, 75f)); if (!ReadBool(_movementGroundedProperty, localPlayerMovement) || profile.PlayerGust <= 0f || ReadBool(_movementOnBoatProperty, localPlayerMovement) || _movementVelocityProperty == null) { return; } try { long pulseBucket = (long)Math.Floor(synchronizedTime * 0.75); float num4 = WeatherScheduler.GameplayVariation(islandIndex, pulseBucket, seed, 49427u); if (!(num4 <= 0.15f)) { float num5 = windAngle * ((float)Math.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num5), 0f, Mathf.Sin(num5)); Vector3 val2 = (Vector3)_movementVelocityProperty.GetValue(localPlayerMovement, null); float num6 = profile.PlayerGust * amount * (num4 - 0.15f) * Time.deltaTime * 0.65f; _movementVelocityProperty.SetValue(localPlayerMovement, val2 + val * num6, null); } } catch (Exception ex) { WarnOccasionally("Player wind gust skipped: " + ex.Message); } } private void UpdateFishing(GameplayProfile profile, float amount) { if (_biteTimeField == null) { return; } try { object obj = ((_creatureManagerInstanceProperty != null) ? _creatureManagerInstanceProperty.GetValue(null, null) : null); if (!IsAlive(obj)) { return; } if (_baselineBiteTime < 0f) { object value = _biteTimeField.GetValue(obj); if (value is float) { _baselineBiteTime = (float)value; } } if (_baselineBiteTime > 0f) { float num = Mathf.Lerp(1f, profile.BiteTimeMultiplier, amount); _biteTimeField.SetValue(obj, Mathf.Max(0.5f, _baselineBiteTime * num)); } } catch (Exception ex) { WarnOccasionally("Bite time adjustment skipped: " + ex.Message); } } internal void Restore() { RestoreMovement(); RestoreFishing(); } private void RestoreMovement() { if (!_movementBaseline.Captured || !IsAlive(_lastMovementObject)) { _movementBaseline = default(MovementBaseline); _lastMovementObject = null; return; } WriteFloat(_movementAccelerationProperty, _lastMovementObject, _movementBaseline.Acceleration); WriteFloat(_movementBackwardAccelerationProperty, _lastMovementObject, _movementBaseline.BackwardAcceleration); WriteFloat(_movementDecelerationProperty, _lastMovementObject, _movementBaseline.Deceleration); WriteFloat(_movementMaxVelocityProperty, _lastMovementObject, _movementBaseline.MaxVelocity); WriteFloat(_movementSlopeLimitProperty, _lastMovementObject, _movementBaseline.SlopeLimit); _movementBaseline = default(MovementBaseline); _lastMovementObject = null; } private void RestoreFishing() { if (_baselineBiteTime <= 0f || _biteTimeField == null) { return; } try { object obj = ((_creatureManagerInstanceProperty != null) ? _creatureManagerInstanceProperty.GetValue(null, null) : null); if (IsAlive(obj)) { _biteTimeField.SetValue(obj, _baselineBiteTime); } } catch { } _baselineBiteTime = -1f; } public void Dispose() { Restore(); } private void CaptureMovementBaseline(object movement) { if (!_movementBaseline.Captured || _lastMovementObject != movement) { if (_movementBaseline.Captured && _lastMovementObject != null && _lastMovementObject != movement) { RestoreMovement(); } _movementBaseline = new MovementBaseline { Acceleration = ReadFloat(_movementAccelerationProperty, movement, 35f), BackwardAcceleration = ReadFloat(_movementBackwardAccelerationProperty, movement, 22f), Deceleration = ReadFloat(_movementDecelerationProperty, movement, 28f), MaxVelocity = ReadFloat(_movementMaxVelocityProperty, movement, 5.5f), SlopeLimit = ReadFloat(_movementSlopeLimitProperty, movement, 45f), Captured = true }; _lastMovementObject = movement; } } private object GetLocalPlayerMovement() { EnsureReflectionCache(); if (_localPlayerProperty != null) { try { object value = _localPlayerProperty.GetValue(null, null); if (IsAlive(value) && _movementProperty != null) { return _movementProperty.GetValue(value, null); } } catch { } } if (_playersProperty != null) { try { if (_playersProperty.GetValue(null, null) is IDictionary dictionary) { foreach (object value2 in dictionary.Values) { if (IsAlive(value2)) { PropertyInfo property = value2.GetType().GetProperty("IsOwner", BindingFlags.Instance | BindingFlags.Public); if (property != null && (bool)property.GetValue(value2, null) && _movementProperty != null) { return _movementProperty.GetValue(value2, null); } } } } } catch { } } return null; } private void EnsureReflectionCache() { if (!_reflectionCached) { Type type = Type.GetType("PlayerMovement, Assembly-CSharp"); if (type != null) { _movementAccelerationProperty = type.GetProperty("Acceleration", BindingFlags.Instance | BindingFlags.Public); _movementBackwardAccelerationProperty = type.GetProperty("BackwardAcceleration", BindingFlags.Instance | BindingFlags.Public); _movementDecelerationProperty = type.GetProperty("Deceleration", BindingFlags.Instance | BindingFlags.Public); _movementMaxVelocityProperty = type.GetProperty("MaxVelocity", BindingFlags.Instance | BindingFlags.Public); _movementSlopeLimitProperty = type.GetProperty("SlopeLimit", BindingFlags.Instance | BindingFlags.Public); _movementOnBoatProperty = type.GetProperty("OnBoat", BindingFlags.Instance | BindingFlags.Public); _movementVelocityProperty = type.GetProperty("Velocity", BindingFlags.Instance | BindingFlags.Public); _movementGroundedProperty = type.GetProperty("Grounded", BindingFlags.Instance | BindingFlags.Public); } _playerManagerType = Type.GetType("PlayerManager, Assembly-CSharp"); if (_playerManagerType != null) { _playersProperty = _playerManagerType.GetProperty("Players", BindingFlags.Static | BindingFlags.Public); _localPlayerProperty = _playerManagerType.GetProperty("LocalPlayer", BindingFlags.Static | BindingFlags.Public); } Type type2 = Type.GetType("Player, Assembly-CSharp"); if (type2 != null) { _movementProperty = type2.GetProperty("Movement", BindingFlags.Instance | BindingFlags.Public); } _boatManagerType = Type.GetType("BoatManager, Assembly-CSharp"); if (_boatManagerType != null) { _boatProperty = _boatManagerType.GetProperty("Boat", BindingFlags.Static | BindingFlags.Public); } Type type3 = Type.GetType("Boat, Assembly-CSharp"); if (type3 != null) { _boatHiddenRigProperty = type3.GetProperty("HiddenRig", BindingFlags.Instance | BindingFlags.Public); _boatPropellerInWaterField = type3.GetProperty("PropellerInWater", BindingFlags.Instance | BindingFlags.Public); } Type type4 = Type.GetType("FishNet.Object.NetworkBehaviour, FishNet.Runtime"); if (type4 != null) { _isServerInitializedProperty = type4.GetProperty("IsServerInitialized", BindingFlags.Instance | BindingFlags.Public); } _creatureManagerType = Type.GetType("CreatureManager, Assembly-CSharp"); if (_creatureManagerType != null) { _creatureManagerInstanceProperty = _creatureManagerType.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public); _biteTimeField = _creatureManagerType.GetField("BiteTime", BindingFlags.Instance | BindingFlags.Public) ?? _creatureManagerType.GetField("_biteTime", BindingFlags.Instance | BindingFlags.NonPublic); } _reflectionCached = true; } } private static bool IsAlive(object target) { if (target == null) { return false; } Object val = (Object)((target is Object) ? target : null); if (val != (Object)null) { return val != (Object)null; } return true; } private static float ReadFloat(PropertyInfo property, object target, float fallback) { if (property == null || target == null) { return fallback; } try { if (property.GetValue(target, null) is float result) { return result; } } catch { } return fallback; } private static void WriteFloat(PropertyInfo property, object target, float value) { if (property == null || target == null || !property.CanWrite) { return; } try { property.SetValue(target, value, null); } catch { } } private static bool ReadBool(PropertyInfo property, object target) { if (property == null || target == null) { return false; } try { if (property.GetValue(target, null) is bool result) { return result; } } catch { } return false; } private void WarnOccasionally(string message) { if ((double)Time.unscaledTime - _lastWarnTime > 5.0) { _lastWarnTime = Time.unscaledTime; _log.LogWarning((object)message); } } } public enum ModLanguage { English, Russian } [BepInProcess("How to Fish.exe")] [BepInPlugin("com.howToFish.weatherexpansion", "WeatherExpansion", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { private struct EnvironmentBaseline { internal ulong ActiveSceneHandle; internal bool Fog; internal FogMode FogMode; internal Color FogColor; internal float FogDensity; internal float FogStartDistance; internal float FogEndDistance; internal float AmbientIntensity; internal Color AmbientLight; internal Color AmbientSkyColor; internal Color AmbientEquatorColor; internal Color AmbientGroundColor; internal float ReflectionIntensity; internal Light Light; internal Quaternion LightRotation; internal Vector3 LightEuler; internal float LightIntensity; internal Color LightColor; internal float ShadowStrength; } public const string PluginGuid = "com.howToFish.weatherexpansion"; public const string PluginName = "WeatherExpansion"; public const string PluginVersion = "1.0.0"; private readonly GameBridge _bridge = new GameBridge(); private WeatherEffects _effects; private GameplayEffects _gameplay; private ConfigEntry<bool> _enabled; private ConfigEntry<float> _dayLengthMinutes; private ConfigEntry<float> _startingHour; private ConfigEntry<float> _weatherDurationMinutes; private ConfigEntry<float> _transitionSeconds; private ConfigEntry<float> _nightExposure; private ConfigEntry<bool> _enableNightStars; private ConfigEntry<float> _starBrightness; private ConfigEntry<float> _effectIntensity; private ConfigEntry<float> _particleQuality; private ConfigEntry<int> _weatherVolumePercent; private ConfigEntry<bool> _gameplayEnabled; private ConfigEntry<int> _gameplayStrengthPercent; private ConfigEntry<int> _seed; private readonly ConfigEntry<string>[] _profileConfigs = new ConfigEntry<string>[6]; private readonly WeatherWeights[] _profiles = new WeatherWeights[6]; private GameObject _flashlightHolder; private Light _flashlightSpotLight; private Light _flashlightFillLight; private GameObject _radarGlowHolder; private Light _radarGlowLight; private bool _isTimePaused = false; private float? _forcedTimeHour = null; private float _frozenDayPhase = 0.5f; private EnvironmentBaseline _baseline; private bool _environmentCaptured; private bool _fogBaselineCaptured; private int _surfaceFrames; private bool _worldActive; private int _lastIsland = -1; private long _lastWeatherSlot = long.MinValue; private WeatherKind _automaticWeather = WeatherKind.Clear; private WeatherKind? _forcedWeather; private WeatherKind _currentWeather = WeatherKind.Clear; private WeatherKind _gameplayWeather = WeatherKind.Clear; private bool _manualGameplayOverrideAllowed = true; private float _windAngle; private double _clock; private float _dayPhase; private float _dayFactor; private float _midnightPeak; private bool _networkClock; private bool _clockStateKnown; private bool _lastNetworkClock; private bool _underwater; private bool _showMenu = false; private Rect _windowRect = new Rect(40f, 40f, 580f, 580f); private int _currentTab = 0; private Texture2D _modIcon; private bool _isResizing = false; private Vector2 _resizeStartMouse; private Vector2 _resizeStartSize; private Vector2 _scrollPos; private Texture2D _winBgTex; private Texture2D _cardBgTex; private Texture2D _btnNormalTex; private Texture2D _btnHoverTex; private Texture2D _btnActiveTex; private Texture2D _tabNormalTex; private Texture2D _tabActiveTex; private Texture2D _accentBadgeTex; private Texture2D _greenBadgeTex; private Texture2D _goldBadgeTex; private Texture2D _scrollBgTex; private Texture2D _scrollThumbTex; private Texture2D _scrollThumbHoverTex; private GUIStyle _winStyle; private GUIStyle _cardStyle; private GUIStyle _titleStyle; private GUIStyle _subTitleStyle; private GUIStyle _tabStyle; private GUIStyle _tabActiveStyle; private GUIStyle _labelStyle; private GUIStyle _sectionHeaderStyle; private GUIStyle _btnStyle; private GUIStyle _weatherBtnActiveStyle; private GUIStyle _toggleActiveStyle; private GUIStyle _toggleInactiveStyle; private GUIStyle _badgeStyle; private GUIStyle _greenBadgeStyle; private GUIStyle _goldBadgeStyle; private GUIStyle _gripStyle; private GUIStyle _scrollBarStyle; private GUIStyle _scrollThumbStyle; private float _lastToggleTime = 0f; private float _lastFlashlightToggleTime = 0f; public static Plugin Instance { get; private set; } public static ConfigEntry<ModLanguage> SelectedLanguage { get; private set; } public static ConfigEntry<KeyCode> MenuKey { get; private set; } public static ConfigEntry<KeyCode> FlashlightKey { get; private set; } public static ConfigEntry<bool> EnablePlayerFlashlight { get; private set; } public static ConfigEntry<float> FlashlightBrightness { get; private set; } public static bool IsRussian => SelectedLanguage != null && SelectedLanguage.Value == ModLanguage.Russian; public static string T(string en, string ru) { return IsRussian ? ru : en; } private void Awake() { //IL_008a: 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) Instance = this; BindConfiguration(); ParseProfiles(); _effects = new WeatherEffects(((BaseUnityPlugin)this).Logger); _gameplay = new GameplayEffects(((BaseUnityPlugin)this).Logger); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.activeSceneChanged += OnActiveSceneChanged; ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Concat("WeatherExpansion v1.0.0 initialized. Press [", MenuKey.Value, "] for menu, [", FlashlightKey.Value, "] for flashlight.")); } public void SetMenuOpen(bool open) { _showMenu = open; try { PlayerCamera.ToggleMouse(open); } catch { } if (open) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } else { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } } private bool IsHotkeyPressed() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Invalid comparison between Unknown and I4 //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Invalid comparison between Unknown and I4 //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Invalid comparison between Unknown and I4 try { Keyboard current = Keyboard.current; if (current != null) { if (Enum.TryParse<Key>(((object)MenuKey.Value).ToString(), ignoreCase: true, out Key result) && ((ButtonControl)current[result]).wasPressedThisFrame) { return true; } if ((int)MenuKey.Value == 287 && ((ButtonControl)current.f6Key).wasPressedThisFrame) { return true; } if ((int)MenuKey.Value == 286 && ((ButtonControl)current.f5Key).wasPressedThisFrame) { return true; } if ((int)MenuKey.Value == 277 && ((ButtonControl)current.insertKey).wasPressedThisFrame) { return true; } if ((int)MenuKey.Value == 96 && ((ButtonControl)current.backquoteKey).wasPressedThisFrame) { return true; } } } catch { } try { if (Input.GetKeyDown(MenuKey.Value)) { return true; } } catch { } return false; } private bool IsFlashlightHotkeyPressed() { //IL_0019: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 try { Keyboard current = Keyboard.current; if (current != null) { if (Enum.TryParse<Key>(((object)FlashlightKey.Value).ToString(), ignoreCase: true, out Key result) && ((ButtonControl)current[result]).wasPressedThisFrame) { return true; } if ((int)FlashlightKey.Value == 108 && ((ButtonControl)current.lKey).wasPressedThisFrame) { return true; } if ((int)FlashlightKey.Value == 102 && ((ButtonControl)current.fKey).wasPressedThisFrame) { return true; } } } catch { } try { if (Input.GetKeyDown(FlashlightKey.Value)) { return true; } } catch { } return false; } private void Update() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (IsHotkeyPressed() && Time.unscaledTime - _lastToggleTime > 0.2f) { _lastToggleTime = Time.unscaledTime; SetMenuOpen(!_showMenu); } if (IsFlashlightHotkeyPressed() && Time.unscaledTime - _lastFlashlightToggleTime > 0.2f) { _lastFlashlightToggleTime = Time.unscaledTime; EnablePlayerFlashlight.Value = !EnablePlayerFlashlight.Value; } if (_showMenu) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } UpdateFlashlight(); if (!_enabled.Value) { DeactivateWorld(immediate: true); return; } int islandIndex = _bridge.GetIslandIndex(); Camera camera = _bridge.GetCamera(); if (islandIndex < 0 || !Object.op_Implicit((Object)(object)camera)) { DeactivateWorld(immediate: true); return; } _underwater = _bridge.IsUnderWater(((Component)camera).transform.position); if (!_worldActive) { ActivateWorld(_underwater); } if (_underwater) { _surfaceFrames = 0; } else if (!_fogBaselineCaptured && ++_surfaceFrames >= 2) { CaptureFogBaseline(); } Light mainLight = _bridge.GetMainLight(); EnsureLightBaseline(mainLight); _clock = _bridge.GetSynchronizedTime(out _networkClock); if (!_clockStateKnown || _networkClock != _lastNetworkClock) { _clockStateKnown = true; _lastNetworkClock = _networkClock; ((BaseUnityPlugin)this).Logger.LogInfo((object)(_networkClock ? "Weather clock synchronized with FishNet network time." : "FishNet unavailable; using deterministic UTC clock fallback.")); } double num = Math.Max(60.0, (double)_dayLengthMinutes.Value * 60.0); double num2 = (double)Mathf.Repeat(_startingHour.Value, 24f) / 24.0 * num; if (_forcedTimeHour.HasValue) { _dayPhase = Mathf.Repeat(_forcedTimeHour.Value / 24f, 1f); _frozenDayPhase = _dayPhase; } else if (_isTimePaused) { _dayPhase = _frozenDayPhase; } else { _dayPhase = (float)((_clock + num2) % num / num); if (_dayPhase < 0f) { _dayPhase += 1f; } _frozenDayPhase = _dayPhase; } float num3 = _dayPhase * 24f; float num4 = Mathf.Sin((_dayPhase - 0.25f) * (float)Math.PI * 2f); _dayFactor = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-0.08f, 0.22f, num4)); float num5 = Mathf.Abs(Mathf.DeltaAngle(num3 / 24f * 360f, 15f)); _midnightPeak = Mathf.Clamp01(1f - num5 / 45f); double num6 = Math.Max(30.0, (double)_weatherDurationMinutes.Value * 60.0); long num7 = (long)Math.Floor(_clock / num6); if (islandIndex != _lastIsland || num7 != _lastWeatherSlot) { _lastIsland = islandIndex; _lastWeatherSlot = num7; WeatherWeights weights = _profiles[Mathf.Clamp(islandIndex, 0, _profiles.Length - 1)]; _automaticWeather = WeatherScheduler.Select(islandIndex, num7, _seed.Value, weights); _windAngle = WeatherScheduler.WindAngle(islandIndex, num7, _seed.Value); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Island " + (islandIndex + 1) + ": automatic weather is now " + LocalizedWeather(_automaticWeather) + ".")); } WeatherKind weatherKind = (_currentWeather = _forcedWeather ?? _automaticWeather); _effects.Tick(camera, weatherKind, Mathf.Max(0.1f, _transitionSeconds.Value), _windAngle, _dayFactor, Mathf.Clamp(_nightExposure.Value, -5f, 0f), Mathf.Clamp(_effectIntensity.Value, 0f, 2f), Mathf.Clamp(_particleQuality.Value, 0.2f, 1.5f), Mathf.Clamp01((float)_weatherVolumePercent.Value / 100f), _bridge.GetFxMixerGroup(), _clock, islandIndex, _seed.Value, _underwater, _enableNightStars.Value, Mathf.Clamp(_starBrightness.Value, 0.1f, 3f), _midnightPeak); float strength = (_gameplayEnabled.Value ? Mathf.Clamp01((float)_gameplayStrengthPercent.Value / 100f) : 0f); _manualGameplayOverrideAllowed = !_forcedWeather.HasValue || _bridge.CanUseLocalGameplayOverride(); _gameplayWeather = (_manualGameplayOverrideAllowed ? weatherKind : _automaticWeather); _gameplay.Tick(_gameplayWeather, _windAngle, _clock, islandIndex, _seed.Value, _underwater, strength, Mathf.Max(0.5f, _transitionSeconds.Value)); ApplyEnvironment(mainLight, num4); Boat boat = null; try { if ((Object)(object)BoatManager.Boat != (Object)null && ((Component)BoatManager.Boat).gameObject.activeInHierarchy) { boat = BoatManager.Boat; } else { Boat[] array = Object.FindObjectsOfType<Boat>(); if (array != null && array.Length > 0) { for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && ((Component)array[i]).gameObject.activeInHierarchy) { boat = array[i]; break; } } } } } catch { } UpdateRadarEnhancement(boat); } private void UpdateFlashlight() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) try { Camera camera = _bridge.GetCamera(); if ((Object)(object)camera != (Object)null && EnablePlayerFlashlight.Value) { if ((Object)(object)_flashlightHolder == (Object)null || (Object)(object)_flashlightHolder.transform.parent != (Object)(object)((Component)camera).transform) { if ((Object)(object)_flashlightHolder != (Object)null) { Object.Destroy((Object)(object)_flashlightHolder); } _flashlightHolder = new GameObject("WeatherExpansion_PlayerFlashlight"); _flashlightHolder.transform.SetParent(((Component)camera).transform, false); _flashlightHolder.transform.localPosition = new Vector3(0f, 0f, 0.05f); _flashlightHolder.transform.localRotation = Quaternion.identity; _flashlightSpotLight = _flashlightHolder.AddComponent<Light>(); _flashlightSpotLight.type = (LightType)0; _flashlightSpotLight.spotAngle = 76f; _flashlightSpotLight.innerSpotAngle = 42f; _flashlightSpotLight.range = 140f; _flashlightSpotLight.color = new Color(1f, 0.98f, 0.92f); _flashlightSpotLight.shadows = (LightShadows)0; _flashlightSpotLight.cullingMask = -1; GameObject val = new GameObject("FlashlightFill"); val.transform.SetParent(_flashlightHolder.transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; _flashlightFillLight = val.AddComponent<Light>(); _flashlightFillLight.type = (LightType)0; _flashlightFillLight.spotAngle = 115f; _flashlightFillLight.innerSpotAngle = 50f; _flashlightFillLight.range = 30f; _flashlightFillLight.color = new Color(1f, 0.96f, 0.88f); _flashlightFillLight.shadows = (LightShadows)0; _flashlightFillLight.cullingMask = -1; } float num = Mathf.Max(1f, FlashlightBrightness.Value) * 7.5f; if ((Object)(object)_flashlightSpotLight != (Object)null) { ((Behaviour)_flashlightSpotLight).enabled = true; _flashlightSpotLight.intensity = num; } if ((Object)(object)_flashlightFillLight != (Object)null) { ((Behaviour)_flashlightFillLight).enabled = true; _flashlightFillLight.intensity = num * 0.3f; } } else { if ((Object)(object)_flashlightSpotLight != (Object)null) { ((Behaviour)_flashlightSpotLight).enabled = false; } if ((Object)(object)_flashlightFillLight != (Object)null) { ((Behaviour)_flashlightFillLight).enabled = false; } } } catch { } } private void UpdateRadarEnhancement(Boat boat) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0128: Unknown re