Decompiled source of DynamicWeather v1.1.0
BepInEx/plugins/DynamicWeather/HowToFish.DynamicWeather.dll
Decompiled 3 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.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("HowToFish.DynamicWeather")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("HowToFish.DynamicWeather")] [assembly: AssemblyTitle("HowToFish.DynamicWeather")] [assembly: AssemblyVersion("1.1.0.0")] namespace HowToFish.DynamicWeather; internal sealed class GameBridge { private Type _onlineIslandType; private PropertyInfo _curIslandProperty; private Type _gameInfoType; private PropertyInfo _cameraProperty; private PropertyInfo _mainLightProperty; private Type _waterManagerType; private MethodInfo _isUnderWaterMethod; private Type _instanceFinderType; private PropertyInfo _timeManagerProperty; private PropertyInfo _networkManagerProperty; private Type _cachedTimeManagerType; private PropertyInfo _tickProperty; private MethodInfo _ticksToTimeMethod; private Type _cachedNetworkManagerType; private PropertyInfo _networkIsServerStartedProperty; private PropertyInfo _networkIsClientStartedProperty; private PropertyInfo _networkServerManagerProperty; private Type _cachedServerManagerType; private PropertyInfo _serverClientsProperty; private FieldInfo _serverClientsField; private Type _audioManagerType; private FieldInfo _audioManagerInstanceField; private FieldInfo _fxGroupField; private float _nextReflectionRefresh; internal int GetIslandIndex() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) EnsureReflectionCache(); try { object obj = _curIslandProperty?.GetValue(null, null); if (obj != null) { return Convert.ToInt32(obj); } } catch { } for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); if (((Scene)(ref sceneAt)).isLoaded) { if (((Scene)(ref sceneAt)).name.Equals("DevIsland", StringComparison.OrdinalIgnoreCase)) { return 5; } if (((Scene)(ref sceneAt)).name.StartsWith("Island", StringComparison.OrdinalIgnoreCase) && int.TryParse(((Scene)(ref sceneAt)).name.Substring("Island".Length), out var result)) { return Math.Max(0, result - 1); } } } return -1; } internal Camera GetCamera() { EnsureReflectionCache(); try { object? obj = _cameraProperty?.GetValue(null, null); Camera val = (Camera)((obj is Camera) ? obj : null); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } if (Object.op_Implicit((Object)(object)Camera.main)) { return Camera.main; } return (from camera in Resources.FindObjectsOfTypeAll<Camera>().Where(delegate(Camera camera) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)camera) && ((Behaviour)camera).enabled) { Scene scene = ((Component)camera).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)camera).gameObject.scene; return ((Scene)(ref scene)).isLoaded; } } return false; }) orderby camera.depth descending select camera).FirstOrDefault(); } internal Light GetMainLight() { EnsureReflectionCache(); try { object? obj = _mainLightProperty?.GetValue(null, null); Light val = (Light)((obj is Light) ? obj : null); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } return (from light in Resources.FindObjectsOfTypeAll<Light>().Where(delegate(Light light) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)light) && (int)light.type == 1) { Scene scene = ((Component)light).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)light).gameObject.scene; return ((Scene)(ref scene)).isLoaded; } } return false; }) orderby light.intensity descending select light).FirstOrDefault(); } internal bool IsUnderWater(Vector3 position) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) EnsureReflectionCache(); try { object obj = _isUnderWaterMethod?.Invoke(null, new object[1] { position }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } internal double GetSynchronizedTime(out bool networkSynchronized) { EnsureReflectionCache(); networkSynchronized = false; try { object obj = _timeManagerProperty?.GetValue(null, null); if (obj != null) { CacheTimeManagerMembers(obj.GetType()); object obj2 = _tickProperty?.GetValue(obj, null); if (obj2 != null && Convert.ToUInt64(obj2) != 0 && _ticksToTimeMethod != null) { double num = Convert.ToDouble(_ticksToTimeMethod.Invoke(obj, new object[1] { obj2 })); if (!double.IsNaN(num) && !double.IsInfinity(num)) { networkSynchronized = true; return num; } } } } catch { } return (DateTime.UtcNow - new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; } internal AudioMixerGroup GetFxMixerGroup() { EnsureReflectionCache(); try { object obj = _audioManagerInstanceField?.GetValue(null); return (AudioMixerGroup)((obj == null) ? null : /*isinst with value type is only supported in some contexts*/); } catch { return null; } } internal bool CanUseLocalGameplayOverride() { EnsureReflectionCache(); try { object obj = _networkManagerProperty?.GetValue(null, null); if (obj == null) { return true; } CacheNetworkManagerMembers(obj.GetType()); bool flag = ReadBool(_networkIsServerStartedProperty, obj); bool flag2 = ReadBool(_networkIsClientStartedProperty, obj); if (!flag && !flag2) { return true; } if (!flag) { return false; } object obj2 = _networkServerManagerProperty?.GetValue(obj, null); if (obj2 == null) { return false; } CacheServerManagerMembers(obj2.GetType()); object obj3 = _serverClientsProperty?.GetValue(obj2, null) ?? _serverClientsField?.GetValue(obj2); if (obj3 is ICollection collection) { return collection.Count <= 1; } PropertyInfo propertyInfo = obj3?.GetType().GetProperty("Count", BindingFlags.Instance | BindingFlags.Public); return propertyInfo != null && Convert.ToInt32(propertyInfo.GetValue(obj3, null)) <= 1; } catch { return false; } } private void EnsureReflectionCache() { if (!(Time.unscaledTime < _nextReflectionRefresh) || !(_gameInfoType != null)) { _nextReflectionRefresh = Time.unscaledTime + 2f; _onlineIslandType = _onlineIslandType ?? Type.GetType("OnlineIslandManager, Assembly-CSharp"); _curIslandProperty = _curIslandProperty ?? _onlineIslandType?.GetProperty("CurIsland", BindingFlags.Static | BindingFlags.Public); _gameInfoType = _gameInfoType ?? Type.GetType("GameInfo, Assembly-CSharp"); _cameraProperty = _cameraProperty ?? _gameInfoType?.GetProperty("CurCamera", BindingFlags.Static | BindingFlags.Public); _mainLightProperty = _mainLightProperty ?? _gameInfoType?.GetProperty("MainLight", BindingFlags.Static | BindingFlags.Public); _waterManagerType = _waterManagerType ?? Type.GetType("WaterManager, Assembly-CSharp"); _isUnderWaterMethod = _isUnderWaterMethod ?? _waterManagerType?.GetMethod("IsUnderWater", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Vector3) }, null); _instanceFinderType = _instanceFinderType ?? Type.GetType("FishNet.InstanceFinder, FishNet.Runtime"); _timeManagerProperty = _timeManagerProperty ?? _instanceFinderType?.GetProperty("TimeManager", BindingFlags.Static | BindingFlags.Public); _networkManagerProperty = _networkManagerProperty ?? _instanceFinderType?.GetProperty("NetworkManager", BindingFlags.Static | BindingFlags.Public); _audioManagerType = _audioManagerType ?? Type.GetType("AudioManager, Assembly-CSharp"); _audioManagerInstanceField = _audioManagerInstanceField ?? _audioManagerType?.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic); _fxGroupField = _fxGroupField ?? _audioManagerType?.GetField("_fxGroup", BindingFlags.Instance | BindingFlags.NonPublic); } } private void CacheTimeManagerMembers(Type type) { if (!(_cachedTimeManagerType == type)) { _cachedTimeManagerType = type; _tickProperty = type.GetProperty("Tick", BindingFlags.Instance | BindingFlags.Public); _ticksToTimeMethod = type.GetMethods(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault(delegate(MethodInfo method) { ParameterInfo[] parameters = method.GetParameters(); return method.Name == "TicksToTime" && parameters.Length == 1 && parameters[0].ParameterType == typeof(uint); }); } } private void CacheNetworkManagerMembers(Type type) { if (!(_cachedNetworkManagerType == type)) { _cachedNetworkManagerType = type; _networkIsServerStartedProperty = type.GetProperty("IsServerStarted", BindingFlags.Instance | BindingFlags.Public); _networkIsClientStartedProperty = type.GetProperty("IsClientStarted", BindingFlags.Instance | BindingFlags.Public); _networkServerManagerProperty = type.GetProperty("ServerManager", BindingFlags.Instance | BindingFlags.Public); } } private void CacheServerManagerMembers(Type type) { if (!(_cachedServerManagerType == type)) { _cachedServerManagerType = type; _serverClientsProperty = type.GetProperty("Clients", BindingFlags.Instance | BindingFlags.Public); _serverClientsField = type.GetField("Clients", BindingFlags.Instance | BindingFlags.Public); } } private static bool ReadBool(PropertyInfo property, object instance) { try { bool flag = default(bool); int num; if (property != null) { object value = property.GetValue(instance, null); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } } internal sealed class GameplayEffects : IDisposable { private sealed class BaitRecord { internal object Bait; internal float OriginalCatchTime; internal float LastAppliedCatchTime; } private struct WaterBaseline { internal float WaveHeight1; internal float WaveHeight2; internal float GradientSpeed1; internal float GradientSpeed2; internal Vector3 WaveDirection1; internal Vector3 WaveDirection2; internal float MaterialWaveHeight1; internal float MaterialWaveHeight2; internal float MaterialGradientSpeed1; internal float MaterialGradientSpeed2; internal Vector3 MaterialWaveDirection1; internal Vector3 MaterialWaveDirection2; } private readonly ManualLogSource _log; private readonly Dictionary<int, BaitRecord> _baitRecords = new Dictionary<int, BaitRecord>(); private readonly HashSet<int> _seenBaits = new HashSet<int>(); private readonly List<int> _removedBaits = new List<int>(); private Type _playerType; private FieldInfo _localPlayerField; private PropertyInfo _playerMovementProperty; private PropertyInfo _playerHoldingProperty; private PropertyInfo _playerScreenShakeProperty; private PropertyInfo _playerInsideProperty; private PropertyInfo _playerBlockInputsProperty; private PropertyInfo _heldItemProperty; private FieldInfo _walkSpeedField; private FieldInfo _sprintSpeedField; private FieldInfo _slipAngleField; private PropertyInfo _movementOnBoatProperty; private MethodInfo _knockbackMethod; private MethodInfo _screenShakeMethod; private Type _fishingRodType; private FieldInfo _holdReelSpeedField; private Type _baitType; private FieldInfo _baitsUnderWaterField; private PropertyInfo _baitFishingRodProperty; private FieldInfo _randomizedCatchTimeField; private PropertyInfo _isServerInitializedProperty; private Type _boatManagerType; private PropertyInfo _boatProperty; private PropertyInfo _boatHiddenRigProperty; private FieldInfo _boatPropellerInWaterField; private Type _waterManagerType; private FieldInfo _waterInstanceField; private FieldInfo _waterMaterialField; private FieldInfo _waterTilesField; private FieldInfo _waveHeight1Field; private FieldInfo _waveHeight2Field; private FieldInfo _gradientSpeed1Field; private FieldInfo _gradientSpeed2Field; private FieldInfo _waveDirection1Field; private FieldInfo _waveDirection2Field; private object _movement; private float _baseWalkSpeed; private float _baseSprintSpeed; private float _baseSlipAngle; private bool _movementCaptured; private object _activeRod; private float _baseReelSpeed; private bool _rodCaptured; private object _waterInstance; private Material _waterMaterial; private Material _waterOriginalMaterial; private Renderer[] _waterRenderers; private WaterBaseline _waterBaseline; private bool _waterCaptured; private long _lastGustBucket = long.MinValue; private float _nextReflectionRefresh; private float _nextWarning; private static readonly int WaveHeight1Id = Shader.PropertyToID("_Wave_Height_1"); private static readonly int WaveHeight2Id = Shader.PropertyToID("_Wave_Height_2"); private static readonly int GradientSpeed1Id = Shader.PropertyToID("_Gradient_Speed_1"); private static readonly int GradientSpeed2Id = Shader.PropertyToID("_Gradient_Speed_2"); private static readonly int WaveDirection1Id = Shader.PropertyToID("_Wave_Direction_1"); private static readonly int WaveDirection2Id = Shader.PropertyToID("_Wave_Direction_2"); 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) { EnsureReflectionCache(); GameplayProfile profile = GameplayProfile.For(weather); float strength2 = Mathf.Clamp01(strength); try { UpdatePlayer(profile, strength2, windAngle, synchronizedTime, islandIndex, seed, underwater); UpdateWater(profile, strength2, transitionSeconds); UpdateFishing(profile, strength2); } catch (Exception ex) { WarnOccasionally("Falha segura ao aplicar efeitos de jogabilidade: " + ex.Message); } } internal void FixedTick(WeatherKind weather, float windAngle, double synchronizedTime, int islandIndex, int seed, float strength) { //IL_0106: 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_011e: 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_0125: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) EnsureReflectionCache(); GameplayProfile gameplayProfile = GameplayProfile.For(weather); float num = Mathf.Clamp01(strength); if (num <= 0f || gameplayProfile.BoatWind <= 0f) { return; } try { object obj = _boatProperty?.GetValue(null, null); if (IsAlive(obj) && ReadBool(_isServerInitializedProperty, obj) && ReadBool(_boatPropellerInWaterField, obj)) { object? obj2 = _boatHiddenRigProperty?.GetValue(obj, null); Rigidbody val = (Rigidbody)((obj2 is Rigidbody) ? obj2 : null); if (Object.op_Implicit((Object)(object)val) && !val.isKinematic) { float num2 = windAngle * (MathF.PI / 180f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2)); long bucket = (long)Math.Floor(synchronizedTime * 0.55); float num3 = WeatherScheduler.GameplayVariation(islandIndex, bucket, seed, 45127); float num4 = 0.78f + 0.22f * Mathf.Sin((float)synchronizedTime * 1.71f + num3 * MathF.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("O vento físico do barco foi ignorado: " + ex.Message); } } private void UpdatePlayer(GameplayProfile profile, float strength, float windAngle, double synchronizedTime, int islandIndex, int seed, bool underwater) { //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) object obj = _localPlayerField?.GetValue(null); object obj2 = ((!IsAlive(obj)) ? null : _playerMovementProperty?.GetValue(obj, null)); if (!IsAlive(obj2)) { RestoreMovement(); RestoreRod(); _lastGustBucket = long.MinValue; return; } if (obj2 != _movement) { RestoreMovement(); _movement = obj2; _baseWalkSpeed = ReadFloat(_walkSpeedField, obj2); _baseSprintSpeed = ReadFloat(_sprintSpeedField, obj2); _baseSlipAngle = ReadFloat(_slipAngleField, obj2); _movementCaptured = true; } int num; float num2; if (!ReadBool(_playerInsideProperty, null)) { num = ((!underwater) ? 1 : 0); if (num != 0) { num2 = strength; goto IL_00cc; } } else { num = 0; } num2 = 0f; goto IL_00cc; IL_00cc: float num3 = num2; _walkSpeedField?.SetValue(obj2, _baseWalkSpeed * Mathf.Lerp(1f, profile.MoveSpeed, num3)); _sprintSpeedField?.SetValue(obj2, _baseSprintSpeed * Mathf.Lerp(1f, profile.MoveSpeed, num3)); _slipAngleField?.SetValue(obj2, _baseSlipAngle * Mathf.Lerp(1f, profile.Traction, num3)); UpdateHeldRod(obj, profile, num3); if (num == 0 || profile.PlayerGust <= 0f || ReadBool(_movementOnBoatProperty, obj2) || ReadBool(_playerBlockInputsProperty, obj)) { _lastGustBucket = long.MinValue; return; } long num4 = (long)Math.Floor(synchronizedTime / Math.Max(1.0, profile.GustInterval)); if (num4 != _lastGustBucket) { _lastGustBucket = num4; float num5 = WeatherScheduler.GameplayVariation(islandIndex, num4, seed, 17169) * 24f; float num6 = 0.78f + (WeatherScheduler.GameplayVariation(islandIndex, num4, seed, 17170) + 1f) * 0.17f; float num7 = (windAngle + num5) * (MathF.PI / 180f); Vector3 val = new Vector3(Mathf.Cos(num7), 0f, Mathf.Sin(num7)) * (profile.PlayerGust * num3 * num6); _knockbackMethod?.Invoke(obj2, new object[1] { val }); object obj3 = _playerScreenShakeProperty?.GetValue(obj, null); if (IsAlive(obj3) && _screenShakeMethod != null) { Vector2 val2 = new Vector2(val.x, val.z); Vector2 normalized = ((Vector2)(ref val2)).normalized; _screenShakeMethod.Invoke(obj3, new object[3] { 28f * profile.PlayerGust * num3, 0, normalized }); } } } private void UpdateHeldRod(object player, GameplayProfile profile, float exposure) { object obj = _playerHoldingProperty?.GetValue(player, null); object obj2 = ((!IsAlive(obj)) ? null : _heldItemProperty?.GetValue(obj, null)); object obj3 = ((IsAlive(obj2) && _fishingRodType != null && _fishingRodType.IsInstanceOfType(obj2)) ? obj2 : null); if (obj3 != _activeRod) { RestoreRod(); if (IsAlive(obj3) && _holdReelSpeedField != null) { _activeRod = obj3; _baseReelSpeed = ReadFloat(_holdReelSpeedField, obj3); _rodCaptured = true; } } if (_rodCaptured && IsAlive(_activeRod)) { _holdReelSpeedField.SetValue(_activeRod, _baseReelSpeed * Mathf.Lerp(1f, profile.ReelSpeed, exposure)); } } private void UpdateFishing(GameplayProfile profile, float strength) { if (!(_baitsUnderWaterField?.GetValue(null) is IEnumerable enumerable) || _randomizedCatchTimeField == null) { RestoreFishing(); return; } _seenBaits.Clear(); foreach (object item in enumerable) { if (!IsAlive(item)) { continue; } object obj = _baitFishingRodProperty?.GetValue(item, null); if (IsAlive(obj) && ReadBool(_isServerInitializedProperty, obj)) { int hashCode = RuntimeHelpers.GetHashCode(item); _seenBaits.Add(hashCode); float num = ReadFloat(_randomizedCatchTimeField, item); if (!_baitRecords.TryGetValue(hashCode, out var value)) { value = new BaitRecord { Bait = item, OriginalCatchTime = num, LastAppliedCatchTime = num }; _baitRecords.Add(hashCode, value); } else if (Math.Abs(num - value.LastAppliedCatchTime) > 0.001f) { value.OriginalCatchTime = num; } float num2 = Mathf.Lerp(1f, profile.FishingTime, strength); float num3 = Mathf.Max(0.2f, value.OriginalCatchTime * num2); _randomizedCatchTimeField.SetValue(item, num3); value.LastAppliedCatchTime = num3; } } _removedBaits.Clear(); foreach (KeyValuePair<int, BaitRecord> baitRecord in _baitRecords) { if (!_seenBaits.Contains(baitRecord.Key)) { _removedBaits.Add(baitRecord.Key); } } foreach (int removedBait in _removedBaits) { _baitRecords.Remove(removedBait); } } private void UpdateWater(GameplayProfile profile, float strength, float transitionSeconds) { //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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) object obj = _waterInstanceField?.GetValue(null); if (!IsAlive(obj)) { ReleaseWaterMaterial(); ClearWaterCapture(); return; } if (obj != _waterInstance) { RestoreWater(); _waterInstance = obj; ref Material waterOriginalMaterial = ref _waterOriginalMaterial; object? obj2 = _waterMaterialField?.GetValue(obj); waterOriginalMaterial = (Material)((obj2 is Material) ? obj2 : null); _waterMaterial = CreateRuntimeWaterMaterial(obj, _waterOriginalMaterial); float num = ReadFloat(_waveHeight1Field, null); float num2 = ReadFloat(_waveHeight2Field, null); float num3 = ReadFloat(_gradientSpeed1Field, null); float num4 = ReadFloat(_gradientSpeed2Field, null); Vector3 val = ReadVector(_waveDirection1Field, null); Vector3 val2 = ReadVector(_waveDirection2Field, null); _waterBaseline = new WaterBaseline { WaveHeight1 = num, WaveHeight2 = num2, GradientSpeed1 = num3, GradientSpeed2 = num4, WaveDirection1 = val, WaveDirection2 = val2, MaterialWaveHeight1 = ReadMaterialFloat(_waterMaterial, WaveHeight1Id, num), MaterialWaveHeight2 = ReadMaterialFloat(_waterMaterial, WaveHeight2Id, num2), MaterialGradientSpeed1 = ReadMaterialFloat(_waterMaterial, GradientSpeed1Id, num3), MaterialGradientSpeed2 = ReadMaterialFloat(_waterMaterial, GradientSpeed2Id, num4), MaterialWaveDirection1 = ReadMaterialVector(_waterMaterial, WaveDirection1Id, val), MaterialWaveDirection2 = ReadMaterialVector(_waterMaterial, WaveDirection2Id, val2) }; _waterCaptured = true; } float num5 = Mathf.Lerp(1f, profile.WaveHeight, strength); float num6 = Mathf.Lerp(1f, profile.WaveSpeed, strength); float num7 = Time.unscaledDeltaTime / Mathf.Max(0.5f, transitionSeconds); float num8 = Mathf.MoveTowards(ReadFloat(_waveHeight1Field, null), _waterBaseline.WaveHeight1 * num5, Mathf.Max(0.001f, Math.Abs(_waterBaseline.WaveHeight1)) * num7); float num9 = Mathf.MoveTowards(ReadFloat(_waveHeight2Field, null), _waterBaseline.WaveHeight2 * num5, Mathf.Max(0.001f, Math.Abs(_waterBaseline.WaveHeight2)) * num7); float num10 = Mathf.MoveTowards(ReadFloat(_gradientSpeed1Field, null), _waterBaseline.GradientSpeed1 * num6, Mathf.Max(0.001f, Math.Abs(_waterBaseline.GradientSpeed1)) * num7); float num11 = Mathf.MoveTowards(ReadFloat(_gradientSpeed2Field, null), _waterBaseline.GradientSpeed2 * num6, Mathf.Max(0.001f, Math.Abs(_waterBaseline.GradientSpeed2)) * num7); float height = Mathf.MoveTowards(ReadMaterialFloat(_waterMaterial, WaveHeight1Id, _waterBaseline.MaterialWaveHeight1), _waterBaseline.MaterialWaveHeight1 * num5, Mathf.Max(0.001f, Math.Abs(_waterBaseline.MaterialWaveHeight1)) * num7); float height2 = Mathf.MoveTowards(ReadMaterialFloat(_waterMaterial, WaveHeight2Id, _waterBaseline.MaterialWaveHeight2), _waterBaseline.MaterialWaveHeight2 * num5, Mathf.Max(0.001f, Math.Abs(_waterBaseline.MaterialWaveHeight2)) * num7); float speed = Mathf.MoveTowards(ReadMaterialFloat(_waterMaterial, GradientSpeed1Id, _waterBaseline.MaterialGradientSpeed1), _waterBaseline.MaterialGradientSpeed1 * num6, Mathf.Max(0.001f, Math.Abs(_waterBaseline.MaterialGradientSpeed1)) * num7); float speed2 = Mathf.MoveTowards(ReadMaterialFloat(_waterMaterial, GradientSpeed2Id, _waterBaseline.MaterialGradientSpeed2), _waterBaseline.MaterialGradientSpeed2 * num6, Mathf.Max(0.001f, Math.Abs(_waterBaseline.MaterialGradientSpeed2)) * num7); _waveHeight1Field?.SetValue(null, num8); _waveHeight2Field?.SetValue(null, num9); _gradientSpeed1Field?.SetValue(null, num10); _gradientSpeed2Field?.SetValue(null, num11); ApplyWaterMaterial(height, height2, speed, speed2, _waterBaseline.MaterialWaveDirection1, _waterBaseline.MaterialWaveDirection2); } private void ApplyWaterMaterial(float height1, float height2, float speed1, float speed2, Vector3 direction1, Vector3 direction2) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_waterMaterial)) { if (_waterMaterial.HasProperty(WaveHeight1Id)) { _waterMaterial.SetFloat(WaveHeight1Id, height1); } if (_waterMaterial.HasProperty(WaveHeight2Id)) { _waterMaterial.SetFloat(WaveHeight2Id, height2); } if (_waterMaterial.HasProperty(GradientSpeed1Id)) { _waterMaterial.SetFloat(GradientSpeed1Id, speed1); } if (_waterMaterial.HasProperty(GradientSpeed2Id)) { _waterMaterial.SetFloat(GradientSpeed2Id, speed2); } if (_waterMaterial.HasProperty(WaveDirection1Id)) { _waterMaterial.SetVector(WaveDirection1Id, Vector4.op_Implicit(direction1)); } if (_waterMaterial.HasProperty(WaveDirection2Id)) { _waterMaterial.SetVector(WaveDirection2Id, Vector4.op_Implicit(direction2)); } } } internal void Restore() { RestoreMovement(); RestoreRod(); RestoreFishing(); RestoreWater(); _lastGustBucket = long.MinValue; } private void RestoreMovement() { if (_movementCaptured && IsAlive(_movement)) { _walkSpeedField?.SetValue(_movement, _baseWalkSpeed); _sprintSpeedField?.SetValue(_movement, _baseSprintSpeed); _slipAngleField?.SetValue(_movement, _baseSlipAngle); } _movement = null; _movementCaptured = false; } private void RestoreRod() { if (_rodCaptured && IsAlive(_activeRod)) { _holdReelSpeedField?.SetValue(_activeRod, _baseReelSpeed); } _activeRod = null; _rodCaptured = false; } private void RestoreFishing() { foreach (BaitRecord value in _baitRecords.Values) { if (IsAlive(value.Bait)) { _randomizedCatchTimeField?.SetValue(value.Bait, value.OriginalCatchTime); } } _baitRecords.Clear(); _seenBaits.Clear(); _removedBaits.Clear(); } private void RestoreWater() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) object obj = null; try { obj = _waterInstanceField?.GetValue(null); } catch { } if (_waterCaptured && IsAlive(_waterInstance) && obj == _waterInstance) { _waveHeight1Field?.SetValue(null, _waterBaseline.WaveHeight1); _waveHeight2Field?.SetValue(null, _waterBaseline.WaveHeight2); _gradientSpeed1Field?.SetValue(null, _waterBaseline.GradientSpeed1); _gradientSpeed2Field?.SetValue(null, _waterBaseline.GradientSpeed2); _waveDirection1Field?.SetValue(null, _waterBaseline.WaveDirection1); _waveDirection2Field?.SetValue(null, _waterBaseline.WaveDirection2); } ReleaseWaterMaterial(); ClearWaterCapture(); } private Material CreateRuntimeWaterMaterial(object instance, Material original) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)original)) { return null; } Material val = null; try { val = new Material(original) { name = ((Object)original).name + " (DynamicWeather Runtime)", hideFlags = (HideFlags)61 }; _waterRenderers = _waterTilesField?.GetValue(instance) as Renderer[]; _waterMaterialField?.SetValue(instance, val); if (_waterRenderers != null) { Renderer[] waterRenderers = _waterRenderers; foreach (Renderer val2 in waterRenderers) { if (Object.op_Implicit((Object)(object)val2) && (Object)(object)val2.sharedMaterial == (Object)(object)original) { val2.sharedMaterial = val; } } } return val; } catch { if (_waterRenderers != null) { Renderer[] waterRenderers = _waterRenderers; foreach (Renderer val3 in waterRenderers) { if (Object.op_Implicit((Object)(object)val3) && (Object)(object)val3.sharedMaterial == (Object)(object)val) { val3.sharedMaterial = original; } } } try { if (IsAlive(instance)) { _waterMaterialField?.SetValue(instance, original); } } catch { } if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } _waterRenderers = null; return null; } } private void ReleaseWaterMaterial() { Material waterMaterial = _waterMaterial; if (_waterRenderers != null) { Renderer[] waterRenderers = _waterRenderers; foreach (Renderer val in waterRenderers) { if (Object.op_Implicit((Object)(object)val) && (Object)(object)val.sharedMaterial == (Object)(object)waterMaterial) { val.sharedMaterial = _waterOriginalMaterial; } } } try { if (IsAlive(_waterInstance) && _waterMaterialField?.GetValue(_waterInstance) == waterMaterial) { _waterMaterialField.SetValue(_waterInstance, _waterOriginalMaterial); } } catch { } if (Object.op_Implicit((Object)(object)waterMaterial) && (Object)(object)waterMaterial != (Object)(object)_waterOriginalMaterial) { Object.Destroy((Object)(object)waterMaterial); } } private void ClearWaterCapture() { _waterInstance = null; _waterMaterial = null; _waterOriginalMaterial = null; _waterRenderers = null; _waterCaptured = false; _waterBaseline = default(WaterBaseline); } private void EnsureReflectionCache() { if (!(Time.unscaledTime < _nextReflectionRefresh) || !(_playerType != null)) { _nextReflectionRefresh = Time.unscaledTime + 2f; _playerType = _playerType ?? Type.GetType("Player, Assembly-CSharp"); _localPlayerField = _localPlayerField ?? _playerType?.GetField("LocalPlayer", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _playerMovementProperty = _playerMovementProperty ?? _playerType?.GetProperty("Movement", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _playerHoldingProperty = _playerHoldingProperty ?? _playerType?.GetProperty("Holding", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _playerScreenShakeProperty = _playerScreenShakeProperty ?? _playerType?.GetProperty("ScreenShake", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _playerInsideProperty = _playerInsideProperty ?? _playerType?.GetProperty("IsInside", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _playerBlockInputsProperty = _playerBlockInputsProperty ?? _playerType?.GetProperty("BlockInputs", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Type type = Type.GetType("PlayerMovement, Assembly-CSharp"); _walkSpeedField = _walkSpeedField ?? type?.GetField("_walkSpeed", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _sprintSpeedField = _sprintSpeedField ?? type?.GetField("_sprintSpeed", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _slipAngleField = _slipAngleField ?? type?.GetField("_slipAngle", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _movementOnBoatProperty = _movementOnBoatProperty ?? type?.GetProperty("OnBoat", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _knockbackMethod = _knockbackMethod ?? type?.GetMethod("Knockback", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Vector3) }, null); Type type2 = Type.GetType("PlayerHolding, Assembly-CSharp"); _heldItemProperty = _heldItemProperty ?? type2?.GetProperty("HeldItem", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Type type3 = Type.GetType("PlayerScreenShake, Assembly-CSharp"); _screenShakeMethod = _screenShakeMethod ?? type3?.GetMethod("Shake", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[3] { typeof(float), typeof(int), typeof(Vector2) }, null); _fishingRodType = _fishingRodType ?? Type.GetType("FishingRod, Assembly-CSharp"); _holdReelSpeedField = _holdReelSpeedField ?? _fishingRodType?.GetField("_holdReelSpeed", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _baitType = _baitType ?? Type.GetType("Bait, Assembly-CSharp"); _baitsUnderWaterField = _baitsUnderWaterField ?? _baitType?.GetField("BaitsUnderWater", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _baitFishingRodProperty = _baitFishingRodProperty ?? _baitType?.GetProperty("FishingRod", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _randomizedCatchTimeField = _randomizedCatchTimeField ?? _baitType?.GetField("<RandomizedCatchTime>k__BackingField", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Type type4 = Type.GetType("FishNet.Object.NetworkBehaviour, FishNet.Runtime"); _isServerInitializedProperty = _isServerInitializedProperty ?? type4?.GetProperty("IsServerInitialized", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _boatManagerType = _boatManagerType ?? Type.GetType("BoatManager, Assembly-CSharp"); _boatProperty = _boatProperty ?? _boatManagerType?.GetProperty("Boat", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Type type5 = Type.GetType("Boat, Assembly-CSharp"); _boatHiddenRigProperty = _boatHiddenRigProperty ?? type5?.GetProperty("HiddenPhysicsRig", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _boatPropellerInWaterField = _boatPropellerInWaterField ?? type5?.GetField("_propellerInWater", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waterManagerType = _waterManagerType ?? Type.GetType("WaterManager, Assembly-CSharp"); _waterInstanceField = _waterInstanceField ?? _waterManagerType?.GetField("_instance", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waterMaterialField = _waterMaterialField ?? _waterManagerType?.GetField("_waterMat", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waterTilesField = _waterTilesField ?? _waterManagerType?.GetField("_waterTiles", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waveHeight1Field = _waveHeight1Field ?? _waterManagerType?.GetField("_waveHeight1", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waveHeight2Field = _waveHeight2Field ?? _waterManagerType?.GetField("_waveHeight2", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _gradientSpeed1Field = _gradientSpeed1Field ?? _waterManagerType?.GetField("_gradientSpeed1", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _gradientSpeed2Field = _gradientSpeed2Field ?? _waterManagerType?.GetField("_gradientSpeed2", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waveDirection1Field = _waveDirection1Field ?? _waterManagerType?.GetField("_waveDirection1", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _waveDirection2Field = _waveDirection2Field ?? _waterManagerType?.GetField("_waveDirection2", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } } private static bool IsAlive(object value) { if (value == null) { return false; } Object val = (Object)((value is Object) ? value : null); if (val == null) { return true; } return Object.op_Implicit(val); } private static bool ReadBool(PropertyInfo property, object instance) { try { bool flag = default(bool); int num; if (property != null) { object value = property.GetValue(instance, null); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } private static bool ReadBool(FieldInfo field, object instance) { try { bool flag = default(bool); int num; if (field != null) { object value = field.GetValue(instance); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } private static float ReadFloat(FieldInfo field, object instance) { try { return (field == null) ? 0f : Convert.ToSingle(field.GetValue(instance)); } catch { return 0f; } } private static Vector3 ReadVector(FieldInfo field, object instance) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) try { return (field != null && field.GetValue(instance) is Vector3 val) ? val : Vector3.forward; } catch { return Vector3.forward; } } private static float ReadMaterialFloat(Material material, int propertyId, float fallback) { try { return (Object.op_Implicit((Object)(object)material) && material.HasProperty(propertyId)) ? material.GetFloat(propertyId) : fallback; } catch { return fallback; } } private static Vector3 ReadMaterialVector(Material material, int propertyId, Vector3 fallback) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) try { if (!Object.op_Implicit((Object)(object)material) || !material.HasProperty(propertyId)) { return fallback; } Vector4 vector = material.GetVector(propertyId); return new Vector3(vector.x, vector.y, vector.z); } catch { return fallback; } } private void WarnOccasionally(string message) { if (!(Time.unscaledTime < _nextWarning)) { _nextWarning = Time.unscaledTime + 15f; _log.LogWarning((object)message); } } public void Dispose() { Restore(); } } [BepInPlugin("fernando.howtofish.dynamicweather", "Dynamic Weather", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("How to Fish.exe")] 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 = "fernando.howtofish.dynamicweather"; public const string PluginName = "Dynamic Weather"; public const string PluginVersion = "1.1.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<float> _effectIntensity; private ConfigEntry<float> _particleQuality; private ConfigEntry<int> _weatherVolumePercent; private ConfigEntry<bool> _gameplayEnabled; private ConfigEntry<int> _gameplayStrengthPercent; private ConfigEntry<int> _seed; private ConfigEntry<KeyCode> _nextWeatherKey; private ConfigEntry<KeyCode> _automaticWeatherKey; private readonly ConfigEntry<string>[] _profileConfigs = new ConfigEntry<string>[6]; private readonly WeatherWeights[] _profiles = new WeatherWeights[6]; 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; private WeatherKind? _forcedWeather; private WeatherKind _currentWeather; private WeatherKind _gameplayWeather; private bool _manualGameplayOverrideAllowed = true; private float _windAngle; private double _clock; private float _dayPhase; private float _dayFactor; private bool _networkClock; private bool _clockStateKnown; private bool _lastNetworkClock; private bool _underwater; private IDisposable _consoleRegistration; private float _nextConsoleRegistrationAttempt; private void Awake() { BindConfiguration(); ParseProfiles(); _effects = new WeatherEffects(((BaseUnityPlugin)this).Logger); _gameplay = new GameplayEffects(((BaseUnityPlugin)this).Logger); TryRegisterConsoleCommand(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.activeSceneChanged += OnActiveSceneChanged; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Dynamic Weather 1.1.0 loaded. F6: next weather; F7: automatic weather."); } private void Update() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (_consoleRegistration == null && Time.unscaledTime >= _nextConsoleRegistrationAttempt) { _nextConsoleRegistrationAttempt = Time.unscaledTime + 2f; TryRegisterConsoleCommand(); } HandleHotkeys(); 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 through FishNet." : "FishNet is not available yet; temporarily using the deterministic UTC clock.")); } double num = Math.Max(60.0, (double)_dayLengthMinutes.Value * 60.0); double num2 = (double)Mathf.Repeat(_startingHour.Value, 24f) / 24.0 * num; _dayPhase = (float)((_clock + num2) % num / num); if (_dayPhase < 0f) { _dayPhase += 1f; } float num3 = Mathf.Sin((_dayPhase - 0.25f) * MathF.PI * 2f); _dayFactor = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-0.12f, 0.24f, num3)); double num4 = Math.Max(30.0, (double)_weatherDurationMinutes.Value * 60.0); long num5 = (long)Math.Floor(_clock / num4); if (islandIndex != _lastIsland || num5 != _lastWeatherSlot) { _lastIsland = islandIndex; _lastWeatherSlot = num5; WeatherWeights weights = _profiles[Mathf.Clamp(islandIndex, 0, _profiles.Length - 1)]; _automaticWeather = WeatherScheduler.Select(islandIndex, num5, _seed.Value, weights); _windAngle = WeatherScheduler.WindAngle(islandIndex, num5, _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, -4f, 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); 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, num3); } private void FixedUpdate() { if (_worldActive && _enabled.Value && _lastIsland >= 0 && _gameplayEnabled.Value) { _gameplay.FixedTick(_gameplayWeather, _windAngle, _clock, _lastIsland, _seed.Value, Mathf.Clamp01((float)_gameplayStrengthPercent.Value / 100f)); } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; SceneManager.activeSceneChanged -= OnActiveSceneChanged; _consoleRegistration?.Dispose(); _consoleRegistration = null; RestoreEnvironment(); _effects?.Dispose(); _gameplay?.Dispose(); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { DeactivateWorld(immediate: true); _lastIsland = -1; _lastWeatherSlot = long.MinValue; } private void OnSceneUnloaded(Scene scene) { DeactivateWorld(immediate: true); _lastIsland = -1; _lastWeatherSlot = long.MinValue; } private void OnActiveSceneChanged(Scene previous, Scene next) { DeactivateWorld(immediate: true); _lastIsland = -1; _lastWeatherSlot = long.MinValue; } private void BindConfiguration() { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Ativado", true, "Ativa o ciclo de dia/noite e o clima dinâmico."); _dayLengthMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Geral", "DuracaoDoDiaEmMinutos", 24f, "Duração de um dia completo do jogo."); _startingHour = ((BaseUnityPlugin)this).Config.Bind<float>("Geral", "HoraInicial", 8f, "Hora em que o ciclo começa quando uma sessão é criada, de 0 a 24."); _weatherDurationMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("Geral", "DuracaoDoClimaEmMinutos", 5f, "Tempo de cada janela de clima antes de uma nova escolha por ilha."); _transitionSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Geral", "TransicaoEmSegundos", 9f, "Suavidade da troca entre climas."); _nightExposure = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "ExposicaoNoturna", -1.85f, "Escurecimento da noite; valores mais negativos deixam a noite mais escura."); _effectIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "IntensidadeDosEfeitos", 1f, "Multiplicador dos efeitos visuais, de 0 a 2."); _particleQuality = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "QualidadeDasParticulas", 1f, "Quantidade de partículas, de 0.2 a 1.5."); _weatherVolumePercent = ((BaseUnityPlugin)this).Config.Bind<int>("Audio", "VolumeDoClima", 75, new ConfigDescription("Volume próprio da chuva, vento e trovões, de 0 a 100. Também respeita Master e Efeitos do jogo.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); _gameplayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Jogabilidade", "ClimaAfetaJogabilidade", true, "Ativa vento físico, ondas, mobilidade, tração e alterações na pesca."); _gameplayStrengthPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Jogabilidade", "ForcaDoClima", 100, new ConfigDescription("Força das alterações de jogabilidade, de 0 a 100.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); _seed = ((BaseUnityPlugin)this).Config.Bind<int>("Sincronizacao", "SementeDoClima", 4001890, "Todos os jogadores devem usar a mesma semente e durações."); _nextWeatherKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controles", "ProximoClima", (KeyCode)287, "Alterna manualmente entre os cinco climas."); _automaticWeatherKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controles", "ClimaAutomatico", (KeyCode)288, "Volta ao clima automático da ilha."); _profileConfigs[0] = ((BaseUnityPlugin)this).Config.Bind<string>("ClimaPorIlha", "Ilha1_Farol", "Clear:60,Rain:30,Storm:10,Snow:0,Hurricane:0", "Pesos relativos do clima na ilha inicial."); _profileConfigs[1] = ((BaseUnityPlugin)this).Config.Bind<string>("ClimaPorIlha", "Ilha2_Floresta", "Clear:25,Rain:30,Storm:20,Snow:25,Hurricane:0", "A floresta é úmida e pode receber neve."); _profileConfigs[2] = ((BaseUnityPlugin)this).Config.Bind<string>("ClimaPorIlha", "Ilha3_Tropical", "Clear:35,Rain:25,Storm:20,Snow:0,Hurricane:20", "A ilha tropical tem risco maior de furacão."); _profileConfigs[3] = ((BaseUnityPlugin)this).Config.Bind<string>("ClimaPorIlha", "Ilha4_RochasECassino", "Clear:35,Rain:25,Storm:25,Snow:0,Hurricane:15", "Clima variável na ilha rochosa."); _profileConfigs[4] = ((BaseUnityPlugin)this).Config.Bind<string>("ClimaPorIlha", "Ilha5_Vulcao", "Clear:40,Rain:5,Storm:35,Snow:0,Hurricane:20", "O vulcão evita neve, mas recebe tempestades severas."); _profileConfigs[5] = ((BaseUnityPlugin)this).Config.Bind<string>("ClimaPorIlha", "Ilha6_Secreta", "Clear:25,Rain:10,Storm:10,Snow:55,Hurricane:0", "Perfil da ilha secreta/de desenvolvimento."); RemoveLegacyConfigEntry("Interface", "MostrarHUD"); RemoveLegacyConfigEntry("Controles", "AlternarHUD"); ((BaseUnityPlugin)this).Config.Save(); } private void RemoveLegacyConfigEntry(string section, string key) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(section, key); ((BaseUnityPlugin)this).Config.Remove(val); try { if (typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(((BaseUnityPlugin)this).Config, null) is IDictionary dictionary) { dictionary.Remove(val); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("A opção antiga " + section + "." + key + " será ignorada: " + ex.Message)); } } private void ParseProfiles() { for (int i = 0; i < _profileConfigs.Length; i++) { int displayIndex = i + 1; _profiles[i] = WeatherWeights.Parse(_profileConfigs[i].Value, delegate(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"Ilha {displayIndex}: {message}"); }); } } private void HandleHotkeys() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(_nextWeatherKey.Value)) { WeatherKind weatherKind = _forcedWeather ?? _automaticWeather; _forcedWeather = (WeatherKind)((int)(weatherKind + 1) % 5); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Clima manual: " + LocalizedWeather(_forcedWeather.Value) + (_bridge.CanUseLocalGameplayOverride() ? string.Empty : " (visual; física automática no cooperativo)"))); } if (Input.GetKeyDown(_automaticWeatherKey.Value)) { _forcedWeather = null; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Clima automático restaurado."); } } private void ActivateWorld(bool underwater) { CaptureEnvironment(underwater); _worldActive = true; } private void DeactivateWorld(bool immediate) { _gameplay?.Restore(); if (_worldActive) { if (immediate) { _effects.SetInactiveImmediate(); } else { _effects.FadeOut(Mathf.Min(2f, Mathf.Max(0.1f, _transitionSeconds.Value))); } RestoreEnvironment(); _worldActive = false; _currentWeather = WeatherKind.Clear; _lastIsland = -1; _lastWeatherSlot = long.MinValue; } } private void CaptureEnvironment(bool underwater) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!_environmentCaptured) { EnvironmentBaseline baseline = default(EnvironmentBaseline); Scene activeScene = SceneManager.GetActiveScene(); SceneHandle handle = ((Scene)(ref activeScene)).handle; baseline.ActiveSceneHandle = ((SceneHandle)(ref handle)).GetRawData(); baseline.AmbientIntensity = RenderSettings.ambientIntensity; baseline.AmbientLight = RenderSettings.ambientLight; baseline.AmbientSkyColor = RenderSettings.ambientSkyColor; baseline.AmbientEquatorColor = RenderSettings.ambientEquatorColor; baseline.AmbientGroundColor = RenderSettings.ambientGroundColor; baseline.ReflectionIntensity = RenderSettings.reflectionIntensity; _baseline = baseline; _fogBaselineCaptured = false; _surfaceFrames = 0; if (!underwater) { CaptureFogBaseline(); } EnsureLightBaseline(_bridge.GetMainLight()); _environmentCaptured = true; } } private void CaptureFogBaseline() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) _baseline.Fog = RenderSettings.fog; _baseline.FogMode = RenderSettings.fogMode; _baseline.FogColor = RenderSettings.fogColor; _baseline.FogDensity = RenderSettings.fogDensity; _baseline.FogStartDistance = RenderSettings.fogStartDistance; _baseline.FogEndDistance = RenderSettings.fogEndDistance; _fogBaselineCaptured = true; } private void EnsureLightBaseline(Light light) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)light) && (!Object.op_Implicit((Object)(object)_baseline.Light) || !((Object)(object)_baseline.Light == (Object)(object)light))) { _baseline.Light = light; _baseline.LightRotation = ((Component)light).transform.rotation; _baseline.LightEuler = ((Component)light).transform.eulerAngles; _baseline.LightIntensity = Mathf.Max(0.01f, light.intensity); _baseline.LightColor = light.color; _baseline.ShadowStrength = light.shadowStrength; } } private void ApplyEnvironment(Light light, float solarAltitude) { //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Invalid comparison between Unknown and I4 if (!_environmentCaptured) { return; } float num = Mathf.Clamp(_effectIntensity.Value, 0f, 2f); float num2 = Mathf.Clamp01(_effects.CloudAmount * num); float num3 = Mathf.Lerp(1f, 0.5f, num2); float num4 = _effects.LightningAmount * num; if (Object.op_Implicit((Object)(object)light)) { EnsureLightBaseline(light); float num5 = _dayPhase * 360f - 90f; float num6 = ((solarAltitude >= 0f) ? num5 : (num5 + 180f)); ((Component)light).transform.rotation = Quaternion.Euler(num6, _baseline.LightEuler.y, _baseline.LightEuler.z); float num7 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.08f, 0.82f, solarAltitude)); Color val = Color.Lerp(new Color(1f, 0.58f, 0.31f, 1f), _baseline.LightColor, num7); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.34f, 0.47f, 0.74f, 1f); light.color = Color.Lerp(val2, val, _dayFactor); light.intensity = Mathf.Lerp(_baseline.LightIntensity * 0.075f, _baseline.LightIntensity, _dayFactor) * num3 + num4 * _baseline.LightIntensity * 1.6f; light.shadowStrength = Mathf.Lerp(_baseline.ShadowStrength * 0.45f, _baseline.ShadowStrength, _dayFactor); } float num8 = Mathf.Lerp(0.11f, 1f, _dayFactor); RenderSettings.ambientIntensity = _baseline.AmbientIntensity * num8 * Mathf.Lerp(1f, 0.56f, num2) + num4 * 0.35f; Color val3 = default(Color); ((Color)(ref val3))..ctor(0.045f, 0.075f, 0.16f, 1f); Color val4 = new Color(0.035f, 0.055f, 0.11f, 1f); Color val5 = default(Color); ((Color)(ref val5))..ctor(0.018f, 0.025f, 0.05f, 1f); Color val6 = default(Color); ((Color)(ref val6))..ctor(0.32f, 0.38f, 0.43f, 1f); RenderSettings.ambientLight = Color.Lerp(val4, _baseline.AmbientLight, _dayFactor) * num3; RenderSettings.ambientSkyColor = Color.Lerp(val3, _baseline.AmbientSkyColor, _dayFactor) * num3; RenderSettings.ambientEquatorColor = Color.Lerp(val4, _baseline.AmbientEquatorColor, _dayFactor) * num3; RenderSettings.ambientGroundColor = Color.Lerp(val5, _baseline.AmbientGroundColor, _dayFactor) * num3; RenderSettings.reflectionIntensity = _baseline.ReflectionIntensity * Mathf.Lerp(0.24f, 1f, _dayFactor) * Mathf.Lerp(1f, 0.52f, num2); if (!_underwater && _fogBaselineCaptured) { float num9 = Mathf.Max(num2, 1f - _dayFactor); RenderSettings.fog = _baseline.Fog || num9 > 0.04f; RenderSettings.fogMode = _baseline.FogMode; RenderSettings.fogColor = Color.Lerp(Color.Lerp(val3, _baseline.FogColor, _dayFactor), val6, num2 * 0.68f); if ((int)_baseline.FogMode == 1) { RenderSettings.fogStartDistance = Mathf.Lerp(_baseline.FogStartDistance, Mathf.Min(_baseline.FogStartDistance, 22f), num2); RenderSettings.fogEndDistance = Mathf.Lerp(_baseline.FogEndDistance, Mathf.Min(_baseline.FogEndDistance, 82f), num2); } else { RenderSettings.fogDensity = _baseline.FogDensity + num2 * 0.0115f + (1f - _dayFactor) * 0.0015f; } } } private void RestoreEnvironment() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) if (!_environmentCaptured) { return; } Scene activeScene = SceneManager.GetActiveScene(); SceneHandle handle = ((Scene)(ref activeScene)).handle; if (((SceneHandle)(ref handle)).GetRawData() != _baseline.ActiveSceneHandle) { _environmentCaptured = false; _fogBaselineCaptured = false; _surfaceFrames = 0; _baseline = default(EnvironmentBaseline); return; } if (!_underwater && _fogBaselineCaptured) { RenderSettings.fog = _baseline.Fog; RenderSettings.fogMode = _baseline.FogMode; RenderSettings.fogColor = _baseline.FogColor; RenderSettings.fogDensity = _baseline.FogDensity; RenderSettings.fogStartDistance = _baseline.FogStartDistance; RenderSettings.fogEndDistance = _baseline.FogEndDistance; } RenderSettings.ambientIntensity = _baseline.AmbientIntensity; RenderSettings.ambientLight = _baseline.AmbientLight; RenderSettings.ambientSkyColor = _baseline.AmbientSkyColor; RenderSettings.ambientEquatorColor = _baseline.AmbientEquatorColor; RenderSettings.ambientGroundColor = _baseline.AmbientGroundColor; RenderSettings.reflectionIntensity = _baseline.ReflectionIntensity; if (Object.op_Implicit((Object)(object)_baseline.Light)) { ((Component)_baseline.Light).transform.rotation = _baseline.LightRotation; _baseline.Light.intensity = _baseline.LightIntensity; _baseline.Light.color = _baseline.LightColor; _baseline.Light.shadowStrength = _baseline.ShadowStrength; } _environmentCaptured = false; _fogBaselineCaptured = false; _surfaceFrames = 0; _baseline = default(EnvironmentBaseline); } private void TryRegisterConsoleCommand() { if (_consoleRegistration != null) { return; } try { MethodInfo methodInfo = Type.GetType("HowToFish.ModConsole.ModConsoleApi, HowToFish.ModConsole", throwOnError: false)?.GetMethod("RegisterCommand", BindingFlags.Static | BindingFlags.Public, null, new Type[6] { typeof(string), typeof(string), typeof(string), typeof(string), typeof(Func<string[], string>), typeof(string[]) }, null); if (!(methodInfo == null)) { Func<string[], string> func = ExecuteWeatherConsoleCommand; _consoleRegistration = methodInfo.Invoke(null, new object[6] { "fernando.howtofish.dynamicweather", "weather", "Shows or controls Dynamic Weather.", "weather <status|auto|clear|rain|storm|snow|hurricane|volume 0-100|gameplay on-off|strength 0-100>", func, new string[1] { "clima" } }) as IDisposable; if (_consoleRegistration != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"The weather/clima command was registered with Console Mod."); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not register the weather command with Console Mod: " + ex.Message)); } } private string ExecuteWeatherConsoleCommand(string[] args) { if (args == null || args.Length == 0 || args[0].Equals("status", StringComparison.OrdinalIgnoreCase)) { int num = Mathf.FloorToInt(_dayPhase * 24f * 60f) % 1440; string text = ((_lastIsland < 0) ? "outside an island" : ("island " + (_lastIsland + 1))); string text2 = (_forcedWeather.HasValue ? "manual" : "automatic"); string text3 = ((_forcedWeather.HasValue && !_manualGameplayOverrideAllowed) ? (", gameplay physics using " + LocalizedWeather(_gameplayWeather) + " for multiplayer synchronization") : string.Empty); return $"{text}, {num / 60:00}:{num % 60:00}, {LocalizedWeather(_currentWeather)} ({text2}), " + string.Format("volume {0}%, gameplay {1} {2}%", _weatherVolumePercent.Value, _gameplayEnabled.Value ? "enabled" : "disabled", _gameplayStrengthPercent.Value) + text3; } string text4 = args[0].Trim(); if (text4.Equals("auto", StringComparison.OrdinalIgnoreCase) || text4.Equals("automatico", StringComparison.OrdinalIgnoreCase) || text4.Equals("automático", StringComparison.OrdinalIgnoreCase)) { _forcedWeather = null; _currentWeather = _automaticWeather; return "Automatic weather restored."; } if (text4.Equals("volume", StringComparison.OrdinalIgnoreCase)) { if (args.Length < 2 || !int.TryParse(args[1], out var result)) { return "Usage: weather volume <0-100>"; } _weatherVolumePercent.Value = Mathf.Clamp(result, 0, 100); ((BaseUnityPlugin)this).Config.Save(); return "Weather volume: " + _weatherVolumePercent.Value + "%"; } if (text4.Equals("gameplay", StringComparison.OrdinalIgnoreCase)) { if (args.Length < 2) { return "Usage: weather gameplay <on|off>"; } string text5 = args[1].Trim().ToLowerInvariant(); if (text5 != "on" && text5 != "off") { return "Usage: weather gameplay <on|off>"; } _gameplayEnabled.Value = text5 == "on"; if (!_gameplayEnabled.Value) { _gameplay.Restore(); } ((BaseUnityPlugin)this).Config.Save(); return "Weather gameplay effects: " + (_gameplayEnabled.Value ? "enabled" : "disabled"); } if (text4.Equals("strength", StringComparison.OrdinalIgnoreCase) || text4.Equals("forca", StringComparison.OrdinalIgnoreCase)) { if (args.Length < 2 || !int.TryParse(args[1], out var result2)) { return "Usage: weather strength <0-100>"; } _gameplayStrengthPercent.Value = Mathf.Clamp(result2, 0, 100); ((BaseUnityPlugin)this).Config.Save(); return "Weather gameplay strength: " + _gameplayStrengthPercent.Value + "%"; } if (WeatherWeights.TryParseKind(text4, out var kind)) { _forcedWeather = kind; _currentWeather = kind; if (!_bridge.CanUseLocalGameplayOverride()) { return "Manual visual weather: " + LocalizedWeather(kind) + ". In multiplayer, gameplay physics continue using automatic weather to keep everyone synchronized."; } return "Manual weather: " + LocalizedWeather(kind); } return "Usage: weather <status|auto|clear|rain|storm|snow|hurricane|volume 0-100|gameplay on-off|strength 0-100>"; } private static string LocalizedWeather(WeatherKind weather) { return weather switch { WeatherKind.Rain => "Rain", WeatherKind.Storm => "Storm", WeatherKind.Snow => "Snow", WeatherKind.Hurricane => "Hurricane", _ => "Clear", }; } } internal sealed class WeatherEffects : IDisposable { private readonly ManualLogSource _log; private GameObject _root; private ParticleSystem _rain; private ParticleSystem _snow; private ParticleSystem _spray; private ParticleSystem _debris; private ParticleSystem _clouds; 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 Material _rainMaterial; private Material _softMaterial; private Material _debrisMaterial; 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) { 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); UpdateAudio(audioVolume, underwater); UpdatePostProcessing(dayFactor, nightExposure, effectIntensity); 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); UpdateParticleRate(_clouds, 0f); _rain.Clear(true); _snow.Clear(true); _spray.Clear(true); _debris.Clear(true); _clouds.Clear(true); _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; UpdateParticleRate(_rain, 0f); UpdateParticleRate(_snow, 0f); UpdateParticleRate(_spray, 0f); UpdateParticleRate(_debris, 0f); UpdateParticleRate(_clouds, 0f); _rain.Clear(true); _snow.Clear(true); _spray.Clear(true); _debris.Clear(true); _clouds.Clear(true); _rainAudio.volume = 0f; _rainDetailAudio.volume = 0f; _windAudio.volume = 0f; _thunderAudio.Stop(); _pendingThunderTime = double.PositiveInfinity; _volume.weight = 0f; _windZone.windMain = 0f; _active = false; } } private bool EnsureCreated() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (_created) { return true; } if (_creationFailed) { return false; } try { _root = new GameObject("HowToFish.DynamicWeather.Runtime"); ((Object)_root).hideFlags = (HideFlags)53; Object.DontDestroyOnLoad((Object)(object)_root); _rainTexture = CreateRainTexture(); _softTexture = CreateSoftTexture(); _debrisTexture = CreateDebrisTexture(); _rainMaterial = CreateParticleMaterial("DynamicWeather.RainMaterial", _rainTexture); _softMaterial = CreateParticleMaterial("DynamicWeather.SoftMaterial", _softTexture); _debrisMaterial = CreateParticleMaterial("DynamicWeather.DebrisMaterial", _debrisTexture); _rain = CreateRainSystem(); _snow = CreateSnowSystem(); _spray = CreateSpraySystem(); _debris = CreateDebrisSystem(); _clouds = CreateCloudSystem(); _windZone = CreateWindZone(); CreateAudio(); CreatePostProcessing(); _created = true; _log.LogInfo((object)"Efeitos procedurais de clima inicializados."); return true; } catch (Exception ex) { _creationFailed = true; _log.LogError((object)("Falha ao criar os efeitos de clima; o ciclo de iluminação continuará ativo. " + ex)); DestroyResources(); return false; } } private void SetActive(Camera camera) { _active = Object.op_Implicit((Object)(object)camera); if (_active) { _volume.weight = 1f; } } 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.48f; snow = 0f; wind = 0.25f; cloud = 0.74f; break; case WeatherKind.Storm: rain = 0.82f; snow = 0f; wind = 0.63f; cloud = 0.93f; break; case WeatherKind.Snow: rain = 0f; snow = 1f; wind = 0.36f; cloud = 0.78f; break; case WeatherKind.Hurricane: rain = 1f; snow = 0f; wind = 1f; cloud = 1f; break; default: rain = 0f; snow = 0f; wind = 0.05f; cloud = 0f; break; } } private void UpdateLightning(WeatherKind weather, double synchronizedTime, int islandIndex, int seed, float audioVolume, bool underwater) { if (weather == WeatherKind.Storm || weather == WeatherKind.Hurricane) { double num = ((weather == WeatherKind.Hurricane) ? 5.0 : 9.0); long num2 = (long)Math.Floor(synchronizedTime / num); if (_lastLightningBucket == long.MinValue) { _lastLightningBucket = num2; } else if (num2 != _lastLightningBucket) { _lastLightningBucket = num2; int chancePercent = ((weather == WeatherKind.Hurricane) ? 82 : 58); if (WeatherScheduler.ShouldTriggerLightning(islandIndex, num2, seed, chancePercent)) { _flashAge = 0f; float num3 = (WeatherScheduler.GameplayVariation(islandIndex, num2, seed, 31250) + 1f) * 0.5f; _pendingThunderTime = synchronizedTime + (double)Mathf.Lerp(0.28f, 1.75f, num3); float num4 = (WeatherScheduler.GameplayVariation(islandIndex, num2, seed, 31251) + 1f) * 0.5f; _pendingThunderIndex = Mathf.Clamp(Mathf.FloorToInt(num4 * (float)_thunderClips.Length), 0, _thunderClips.Length - 1); _pendingThunderVolume = ((weather == WeatherKind.Hurricane) ? 0.92f : 0.74f); _thunderAudio.pitch = WeatherScheduler.LightningPitch(islandIndex, num2, seed); } } } else { _lastLightningBucket = long.MinValue; _flashAge = 99f; } _flashAge += Time.unscaledDeltaTime; if (_flashAge < 0.07f) { LightningAmount = 1f; } else if (_flashAge < 0.15f) { LightningAmount = 0.12f; } else if (_flashAge < 0.23f) { LightningAmount = 0.72f; } else if (_flashAge < 0.65f) { LightningAmount = Mathf.InverseLerp(0.65f, 0.23f, _flashAge) * 0.35f; } else { LightningAmount = 0f; } if (synchronizedTime >= _pendingThunderTime && _thunderClips != null && _thunderClips.Length != 0) { _pendingThunderTime = double.PositiveInfinity; float num5 = (underwater ? 0.12f : 1f); _thunderAudio.PlayOneShot(_thunderClips[_pendingThunderIndex], Mathf.Clamp01(_pendingThunderVolume * Mathf.Clamp01(audioVolume) * num5)); } } private void UpdateEmitterPositions(Camera camera, float windAngle) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) float num = windAngle * (MathF.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num)); Vector3 position = ((Component)camera).transform.position; ((Component)_rain).transform.position = position + Vector3.up * 25f - val * 11f; ((Component)_snow).transform.position = position + Vector3.up * 19f - val * 7f; ((Component)_spray).transform.position = position + Vector3.up * 2f - val * 14f; ((Component)_debris).transform.position = position + Vector3.up * 3f - val * 18f; ((Component)_clouds).transform.position = position + Vector3.up * 62f - val * 28f; } private void UpdateParticles(float windAngle, float effectIntensity, float particleQuality, bool underwater) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_00a7: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0126: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) float num = windAngle * (MathF.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num)); float num2 = Mathf.Clamp(particleQuality, 0.2f, 1.5f); float num3 = (underwater ? 0f : 1f); UpdateParticleRate(_rain, 3400f * RainAmount * effectIntensity * num2 * num3); VelocityOverLifetimeModule velocityOverLifetime = _rain.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(val.x * Mathf.Lerp(2f, 26f, WindAmount)); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(-34f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(val.z * Mathf.Lerp(2f, 26f, WindAmount)); UpdateParticleRate(_snow, 520f * SnowAmount * effectIntensity * num2 * num3); VelocityOverLifetimeModule velocityOverLifetime2 = _snow.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime2)).x = MinMaxCurve.op_Implicit(val.x * Mathf.Lerp(0.6f, 6f, WindAmount)); ((VelocityOverLifetimeModule)(ref velocityOverLifetime2)).y = MinMaxCurve.op_Implicit(-1.7f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime2)).z = MinMaxCurve.op_Implicit(val.z * Mathf.Lerp(0.6f, 6f, WindAmount)); float num4 = Mathf.InverseLerp(0.78f, 1f, WindAmount) * RainAmount; UpdateParticleRate(_spray, 125f * num4 * effectIntensity * num2 * num3); VelocityOverLifetimeModule velocityOverLifetime3 = _spray.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime3)).x = MinMaxCurve.op_Implicit(val.x * Mathf.Lerp(14f, 30f, WindAmount)); ((VelocityOverLifetimeModule)(ref velocityOverLifetime3)).y = MinMaxCurve.op_Implicit(1.5f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime3)).z = MinMaxCurve.op_Implicit(val.z * Mathf.Lerp(14f, 30f, WindAmount)); UpdateParticleRate(_debris, 90f * num4 * effectIntensity * num2 * num3); VelocityOverLifetimeModule velocityOverLifetime4 = _debris.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime4)).x = MinMaxCurve.op_Implicit(val.x * Mathf.Lerp(16f, 34f, WindAmount)); ((VelocityOverLifetimeModule)(ref velocityOverLifetime4)).y = MinMaxCurve.op_Implicit(2.4f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime4)).z = MinMaxCurve.op_Implicit(val.z * Mathf.Lerp(16f, 34f, WindAmount)); UpdateParticleRate(_clouds, 7.5f * CloudAmount * effectIntensity * num2 * num3); VelocityOverLifetimeModule velocityOverLifetime5 = _clouds.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime5)).x = MinMaxCurve.op_Implicit(val.x * Mathf.Lerp(1.2f, 8f, WindAmount)); ((VelocityOverLifetimeModule)(ref velocityOverLifetime5)).y = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime5)).z = MinMaxCurve.op_Implicit(val.z * Mathf.Lerp(1.2f, 8f, WindAmount)); } private void UpdateAudio(float audioVolume, bool underwater) { float num = Mathf.Clamp01(audioVolume); float num2 = (underwater ? 0.12f : 1f); float num3 = RainAmount * Mathf.Lerp(0.24f, 0.58f, RainAmount) * num * num2; float num4 = Mathf.Sqrt(RainAmount) * Mathf.Lerp(0.08f, 0.24f, RainAmount) * num * num2; float num5 = WindAmount * Mathf.Lerp(0.06f, 0.62f, WindAmount) * num * num2; _rainAudio.volume = Mathf.MoveTowards(_rainAudio.volume, num3, Time.unscaledDeltaTime * 0.6f); _rainDetailAudio.volume = Mathf.MoveTowards(_rainDetailAudio.volume, num4, Time.unscaledDeltaTime * 0.7f); _windAudio.volume = Mathf.MoveTowards(_windAudio.volume, num5, Time.unscaledDeltaTime * 0.45f); _rainDetailAudio.pitch = 0.96f + Mathf.Sin(Time.unscaledTime * 0.17f) * 0.025f; _windAudio.pitch = Mathf.Lerp(0.8f, 1.07f, WindAmount) + Mathf.Sin(Time.unscaledTime * 0.11f) * 0.018f; float cutoffFrequency = (underwater ? 850f : 22000f); _rainLowPass.cutoffFrequency = cutoffFrequency; _rainDetailLowPass.cutoffFrequency = cutoffFrequency; _windLowPass.cutoffFrequency = (underwater ? 620f : Mathf.Lerp(5200f, 13000f, WindAmount)); _thunderLowPass.cutoffFrequency = (underwater ? 520f : 15000f); } private void UpdatePostProcessing(float dayFactor, float nightExposure, float effectIntensity) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) float num = -0.66f * CloudAmount * effectIntensity; float value = Mathf.Lerp(nightExposure, 0f, dayFactor) + num + LightningAmount * 2.4f * effectIntensity; Color val = new Color(0.43f, 0.55f, 0.82f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.67f, 0.72f, 0.77f, 1f); Color val3 = Color.Lerp(val, Color.white, dayFactor); val3 = Color.Lerp(val3, val2, CloudAmount * 0.48f * effectIntensity); ((VolumeParameter<float>)(object)_colorAdjustments.postExposure).value = value; ((VolumeParameter<Color>)(object)_colorAdjustments.colorFilter).value = val3; float num2 = CloudAmount * effectIntensity; ((VolumeParameter)_colorAdjustments.contrast).overrideState = num2 > 0.002f; ((VolumeParameter)_colorAdjustments.saturation).overrideState = num2 > 0.002f; ((VolumeParameter<float>)(object)_colorAdjustments.contrast).value = (0f - CloudAmount) * 12f * effectIntensity; ((VolumeParameter<float>)(object)_colorAdjustments.saturation).value = (0f - CloudAmount) * 15f * effectIntensity; float num3 = Mathf.Max(1f - dayFactor, Mathf.Max(num2, LightningAmount * effectIntensity)); _volume.weight = ((_active && num3 > 0.002f) ? 1f : 0f); } private void UpdateWindZone(float windAngle, float effectIntensity) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Component)_windZone).transform.rotation = Quaternion.Euler(12f, windAngle, 0f); _windZone.windMain = Mathf.Lerp(0.05f, 2.4f, WindAmount) * effectIntensity; _windZone.windTurbulence = Mathf.Lerp(0.08f, 1.2f, WindAmount) * effectIntensity; _windZone.windPulseMagnitude = Mathf.Lerp(0f, 1.1f, WindAmount) * effectIntensity; _windZone.windPulseFrequency = Mathf.Lerp(0.08f, 0.55f, WindAmount); } private ParticleSystem CreateRainSystem() { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) ParticleSystem obj = CreateParticleSystem("Rain", _rainMaterial); MainModule main = obj.main; ((MainModule)(ref main)).maxParticles = 6500; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1f, 1.45f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.035f, 0.065f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.72f, 0.82f, 1f, 0.72f)); ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = new Vector3(62f, 1f, 62f); VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)1; component.lengthScale = 3.2f; component.velocityScale = 0.055f; component.cameraVelocityScale = 0f; return obj; } private ParticleSystem CreateSnowSystem() { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid I