using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HTFWeather")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HTFWeather")]
[assembly: AssemblyTitle("HTFWeather")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("yoxi.htf.weather", "HTF Weather", "1.0.0")]
public class WeatherPlugin : BaseUnityPlugin
{
public const string Id = "yoxi.htf.weather";
internal static ManualLogSource Log;
private ConfigEntry<float> _volume;
private ConfigEntry<bool> _thunder;
private ConfigEntry<bool> _lightning;
private GameObject _rig;
private float _poll;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
_volume = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Volume", 0.7f, "Weather audio volume (0 = silent).");
_thunder = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "ThunderSounds", true, "Play thunder. Off = storms stay silent (visuals unchanged).");
_lightning = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "LightningStrikes", true, "Lightning strikes and flashes. Off = no bolts, no flashes, no thunder from strikes.");
}
private void Update()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
_poll -= Time.deltaTime;
if (_poll > 0f)
{
return;
}
_poll = 2f;
bool flag = Object.FindObjectsByType<IslandManager>((FindObjectsInactive)0, (FindObjectsSortMode)0).Length != 0;
if (flag && (Object)(object)_rig == (Object)null)
{
_rig = new GameObject("HTFWeather");
Object.DontDestroyOnLoad((Object)(object)_rig);
WeatherKeeper weatherKeeper = _rig.AddComponent<WeatherKeeper>();
weatherKeeper.Volume = Mathf.Clamp01(_volume.Value);
weatherKeeper.ThunderOn = _thunder.Value;
weatherKeeper.LightningOn = _lightning.Value;
weatherKeeper.SavePrefs = delegate(float vol, bool th, bool li)
{
_volume.Value = Mathf.Clamp01(vol);
_thunder.Value = th;
_lightning.Value = li;
};
Log.LogInfo((object)"Weather rig deployed.");
}
else if (!flag && (Object)(object)_rig != (Object)null)
{
Object.Destroy((Object)(object)_rig);
_rig = null;
Log.LogInfo((object)"Weather stands down.");
}
}
}
[DefaultExecutionOrder(500)]
public class WeatherKeeper : MonoBehaviour
{
public float StormChance = 0.3f;
public float EpochSeconds = 480f;
public float Intensity = 1f;
public float Volume = 0.7f;
public bool ThunderOn = true;
public bool LightningOn = true;
public Action<float, bool, bool> SavePrefs;
private bool _devMenu;
private int _state;
public int Override = -1;
private bool _menuOpen;
private CursorLockMode _wasLock;
private bool _wasCursor;
private Rect _menuRect = new Rect(60f, 60f, 370f, 360f);
private float _w;
private Func<double> _clock;
private double _localClock;
private ParticleSystem _rain;
private ParticleSystem _splash;
private ParticleSystem _spray;
private float _splashBudget;
private ParticleSystemRenderer _rainRenderer;
private GameObject _veilRoot;
private Material _veilMat;
private float _veilSpin;
private bool _debugOpen;
private AudioSource _rainA;
private AudioSource _rainB;
private AudioSource _stormLayer;
private AudioSource _wind;
private AudioLowPassFilter _rainFilter;
private AudioSource _thunderVoice;
private readonly List<AudioClip> _thunderFiles = new List<AudioClip>();
private bool _realRain;
private bool _realStorm;
private bool _realWind;
private float _lastDelay = 2f;
private float _nextStrike = 12f;
private const float FlashTime = 0.45f;
private float _flash;
private Light _flashLight;
private float _pendingThunder = -1f;
private Color _overcastNow = new Color(0.52f, 0.54f, 0.58f);
private Transform _deckA;
private Transform _deckB;
private MeshRenderer _shadeR;
private MeshRenderer _deckAR;
private MeshRenderer _deckBR;
private Material _shadeMat;
private Material _deckAMat;
private Material _deckBMat;
private float _skySearch;
private float _spinA;
private float _spinB;
private Vector3 _boltTop;
private Vector3 _gale;
private float _flashScale = 1f;
private float _sheetTimer = 18f;
private float _reFlash = -1f;
private Vector3 _stormCenter;
private bool _centerSet;
private float _localK = 1f;
private bool _tookFogLine;
private bool _baseFogOn;
private float _baseFogStart;
private float _baseFogEnd;
private float _lidA;
private bool _truthLogged;
private float _footprint = 380f;
private double _nowSeconds;
private static Type _nkType;
private Component _nightKeeperRef;
private PropertyInfo _nkTime;
private PropertyInfo _nkOffset;
private float _nkSearch;
private int _segIndex = -1;
private double _segStart;
private double _segEnd;
private float _lastClearLen = -1f;
private LineRenderer _bolt;
private LineRenderer _branchA;
private LineRenderer _branchB;
private Material _boltMat;
private bool _tookBase;
private readonly Dictionary<Light, float> _baseIntensity = new Dictionary<Light, float>();
private float _baseFogDensity;
private Color _baseFogColor;
private Color _baseAmbient;
private float _baseAmbientStrength;
private bool _dayNightPresent;
private float _rescan;
private Light[] _lights = (Light[])(object)new Light[0];
private static readonly long DaySalt = (long)(DateTime.UtcNow.Date - new DateTime(2020, 1, 1)).TotalDays * 7919;
private static bool _waterHeightBroken;
private static MethodInfo _setData;
private static int _inputMode;
private Rect _playerRect = new Rect(60f, 60f, 300f, 210f);
private GUISkin _skin;
private GUIStyle _clockStyle;
private void Start()
{
_clock = MakeNetClock();
BuildRain();
BuildAudio();
}
private int StateOfEpoch(long epoch)
{
if ((epoch & 1) == 0)
{
return 0;
}
ulong num = (ulong)((epoch + DaySalt) * 2654435761u + -7046029254386353131L);
num ^= num >> 29;
num *= 13787848793156543929uL;
num ^= num >> 32;
float num2 = (float)(num % 10000) / 10000f;
if (num2 < 0.35f)
{
return 2;
}
if (num2 < 0.7f)
{
return 1;
}
return 0;
}
private float DurOf(int st)
{
return st switch
{
1 => 150f,
2 => 120f,
_ => Mathf.Max(120f, EpochSeconds),
};
}
private int StateAt(double seconds)
{
if (_segIndex < 0 || seconds < _segStart || _lastClearLen != EpochSeconds)
{
_lastClearLen = EpochSeconds;
_segIndex = 0;
_segStart = 0.0;
_segEnd = DurOf(StateOfEpoch(0L));
}
while (seconds >= _segEnd)
{
_segIndex++;
_segStart = _segEnd;
_segEnd += DurOf(StateOfEpoch(_segIndex));
}
return StateOfEpoch(_segIndex);
}
private bool DarkEnough()
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
try
{
if ((Object)(object)_nightKeeperRef == (Object)null)
{
_nkSearch -= Time.deltaTime;
if (_nkSearch > 0f)
{
return true;
}
_nkSearch = 5f;
if (_nkType == null)
{
_nkType = Type.GetType("NightKeeper, HTFDayNight") ?? Type.GetType("NightKeeper, HTFMapLoader");
}
if (_nkType == null)
{
return true;
}
_nightKeeperRef = (Component)Object.FindFirstObjectByType(_nkType);
if ((Object)(object)_nightKeeperRef == (Object)null)
{
return true;
}
_nkTime = _nkType.GetProperty("TimeOfDay");
_nkOffset = _nkType.GetProperty("TimeOffset");
}
if (_nkTime == null)
{
return true;
}
float num = (float)_nkTime.GetValue(_nightKeeperRef, null);
if (_nkOffset != null)
{
num -= (float)_nkOffset.GetValue(_nightKeeperRef, null);
}
num = Mathf.Repeat(num, 1f);
return num >= 0.44f || num <= 0.02f;
}
catch (Exception)
{
return true;
}
}
private float LocalK(Camera eye)
{
//IL_0025: 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)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (!_centerSet || (Object)(object)eye == (Object)null)
{
return 1f;
}
Vector3 val = ((Component)eye).transform.position - _stormCenter;
val.y = 0f;
return Mathf.Clamp01(1f - (((Vector3)(ref val)).magnitude - _footprint) / 300f);
}
private static float WaterHeightAt(Vector3 pos)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (_waterHeightBroken)
{
return 0f;
}
try
{
float waterHeight = WaterManager.GetWaterHeight(pos);
return (float.IsNaN(waterHeight) || float.IsInfinity(waterHeight)) ? 0f : waterHeight;
}
catch (Exception)
{
_waterHeightBroken = true;
return 0f;
}
}
private static bool Near(Vector3 a, Vector3 b)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
a.y = 0f;
b.y = 0f;
Vector3 val = a - b;
return ((Vector3)(ref val)).magnitude < 500f;
}
private double SharedSeconds()
{
if (_clock != null)
{
double num = _clock();
if (num >= 0.0)
{
return num;
}
}
_localClock += Time.deltaTime;
return _localClock;
}
private void LateUpdate()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: 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)
if (Pressed((KeyCode)288))
{
_menuOpen = !_menuOpen;
if (_menuOpen)
{
_devMenu = Held((KeyCode)304) || Held((KeyCode)303);
_wasLock = Cursor.lockState;
_wasCursor = Cursor.visible;
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
else
{
CloseMenu();
}
}
if (_menuOpen)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
_nowSeconds = SharedSeconds();
int num = StateAt(_nowSeconds);
if (num == 2 && !DarkEnough())
{
num = 1;
}
_state = ((Override >= 0) ? Override : num);
float num2 = ((_state == 2) ? 1f : ((_state == 1) ? 0.45f : 0f));
_w = Mathf.MoveTowards(_w, num2, Time.deltaTime / 20f);
float num3 = _w * Intensity;
Camera val = Eye();
if ((Object)(object)val != (Object)null)
{
((Component)this).transform.position = ((Component)val).transform.position;
}
float num4 = Mathf.PerlinNoise(Time.time * 0.006f, 77.7f) * 6.2832f;
_gale = new Vector3(Mathf.Cos(num4), 0f, Mathf.Sin(num4)) * (1.2f + 3.8f * Mathf.Clamp01(num3));
_localK = LocalK(val);
float w = num3 * _localK;
if (_w > 0.95f && !_truthLogged)
{
_truthLogged = true;
WeatherPlugin.Log.LogInfo((object)("STORM TRUTH: shade=" + (((Object)(object)_shadeMat != (Object)null) ? ("on a=" + _lidA.ToString("0.00")) : "MISSING") + " localK=" + _localK.ToString("0.00") + " fogMode=" + ((object)RenderSettings.fogMode/*cast due to .constrained prefix*/).ToString() + " fogOn=" + RenderSettings.fog + " dens=" + RenderSettings.fogDensity.ToString("0.0000") + " end=" + RenderSettings.fogEndDistance.ToString("0") + " night=" + (_dayNightPresent ? "y" : "n") + " far=" + (((Object)(object)val != (Object)null) ? val.farClipPlane.ToString("0") : "?")));
}
else if (_w < 0.1f)
{
_truthLogged = false;
}
Rain(w, val);
Clouds(num3, val);
Darken(w, val);
Lightning(num3, val);
Sound(w);
}
private void BuildRain()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01d2: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: 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_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Expected O, but got Unknown
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_0521: Unknown result type (might be due to invalid IL or missing references)
//IL_0549: Unknown result type (might be due to invalid IL or missing references)
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
//IL_055f: Unknown result type (might be due to invalid IL or missing references)
//IL_057b: Unknown result type (might be due to invalid IL or missing references)
//IL_058c: Unknown result type (might be due to invalid IL or missing references)
//IL_0591: Unknown result type (might be due to invalid IL or missing references)
//IL_059a: Unknown result type (might be due to invalid IL or missing references)
//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
//IL_05db: Unknown result type (might be due to invalid IL or missing references)
//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0603: Expected O, but got Unknown
//IL_060d: Unknown result type (might be due to invalid IL or missing references)
//IL_0617: Unknown result type (might be due to invalid IL or missing references)
//IL_061c: Unknown result type (might be due to invalid IL or missing references)
//IL_0623: Unknown result type (might be due to invalid IL or missing references)
//IL_062d: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
//IL_0651: Unknown result type (might be due to invalid IL or missing references)
//IL_0656: Unknown result type (might be due to invalid IL or missing references)
//IL_0667: Unknown result type (might be due to invalid IL or missing references)
//IL_066c: Unknown result type (might be due to invalid IL or missing references)
//IL_067d: Unknown result type (might be due to invalid IL or missing references)
//IL_0682: Unknown result type (might be due to invalid IL or missing references)
//IL_0691: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Expected O, but got Unknown
//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0791: Unknown result type (might be due to invalid IL or missing references)
//IL_0798: Expected O, but got Unknown
//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
//IL_080f: Unknown result type (might be due to invalid IL or missing references)
//IL_0821: Unknown result type (might be due to invalid IL or missing references)
//IL_0842: Unknown result type (might be due to invalid IL or missing references)
//IL_0847: Unknown result type (might be due to invalid IL or missing references)
//IL_086f: Unknown result type (might be due to invalid IL or missing references)
//IL_0880: Unknown result type (might be due to invalid IL or missing references)
//IL_0885: Unknown result type (might be due to invalid IL or missing references)
//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0705: Unknown result type (might be due to invalid IL or missing references)
//IL_070a: Unknown result type (might be due to invalid IL or missing references)
//IL_0718: Expected O, but got Unknown
//IL_0745: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Rain");
val.transform.SetParent(((Component)this).transform, false);
val.transform.localPosition = new Vector3(0f, 22f, 0f);
_rain = val.AddComponent<ParticleSystem>();
MainModule main = _rain.main;
((MainModule)(ref main)).loop = true;
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.35f);
((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.065f);
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.75f, 0.82f, 0.95f, 0.55f));
((MainModule)(ref main)).maxParticles = 4200;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(3.2f);
ShapeModule shape = _rain.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5;
((ShapeModule)(ref shape)).scale = new Vector3(64f, 1f, 64f);
EmissionModule emission = _rain.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
CollisionModule collision = _rain.collision;
((CollisionModule)(ref collision)).enabled = true;
((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
((CollisionModule)(ref collision)).mode = (ParticleSystemCollisionMode)0;
((CollisionModule)(ref collision)).quality = (ParticleSystemCollisionQuality)0;
((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(1f);
((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(0f);
((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(1f);
((CollisionModule)(ref collision)).radiusScale = 0.5f;
GameObject val2 = new GameObject("RainSpatter");
val2.transform.SetParent(val.transform, false);
ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
MainModule main2 = val3.main;
((MainModule)(ref main2)).loop = false;
((MainModule)(ref main2)).startLifetime = MinMaxCurve.op_Implicit(0.24f);
((MainModule)(ref main2)).startSpeed = new MinMaxCurve(0.9f, 1.8f);
((MainModule)(ref main2)).startSize = new MinMaxCurve(0.09f, 0.14f);
((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(new Color(0.88f, 0.92f, 1f, 0.85f));
((MainModule)(ref main2)).maxParticles = 2200;
((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(2.4f);
ShapeModule shape2 = val3.shape;
((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape2)).radius = 0.02f;
EmissionModule emission2 = val3.emission;
((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(0f);
((EmissionModule)(ref emission2)).SetBursts((Burst[])(object)new Burst[1]
{
new Burst(0f, (short)2)
});
ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)component).receiveShadows = false;
SubEmittersModule subEmitters = _rain.subEmitters;
((SubEmittersModule)(ref subEmitters)).enabled = true;
((SubEmittersModule)(ref subEmitters)).AddSubEmitter(val3, (ParticleSystemSubEmitterType)1, (ParticleSystemSubEmitterProperties)0);
_rainRenderer = val.GetComponent<ParticleSystemRenderer>();
_rainRenderer.renderMode = (ParticleSystemRenderMode)1;
_rainRenderer.velocityScale = 0.09f;
_rainRenderer.lengthScale = 0.9f;
((Renderer)_rainRenderer).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)_rainRenderer).receiveShadows = false;
Material[] array = Resources.FindObjectsOfTypeAll<Material>();
foreach (Material val4 in array)
{
if (!((Object)(object)val4 != (Object)null) || !((Object)(object)val4.shader != (Object)null) || !(((Object)val4.shader).name == "HTF/NightSky") || !((Object)(object)val4.GetTexture("_MainTex") != (Object)null))
{
continue;
}
Material val5 = new Material(val4)
{
name = "RainStreak"
};
val5.SetColor("_Tint", new Color(1f, 1f, 1f, 0.34f));
val5.SetFloat("_Glow", 0.7f);
val5.renderQueue = 2990;
((Renderer)_rainRenderer).sharedMaterial = val5;
ParticleSystemRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>(true);
foreach (ParticleSystemRenderer val6 in componentsInChildren)
{
if (((Object)((Component)val6).gameObject).name == "RainSpatter")
{
((Renderer)val6).sharedMaterial = val5;
}
}
break;
}
GameObject val7 = new GameObject("RainSplash");
val7.transform.SetParent(((Component)this).transform, false);
_splash = val7.AddComponent<ParticleSystem>();
MainModule main3 = _splash.main;
((MainModule)(ref main3)).loop = true;
((MainModule)(ref main3)).startLifetime = MinMaxCurve.op_Implicit(0.45f);
((MainModule)(ref main3)).startSpeed = MinMaxCurve.op_Implicit(0f);
((MainModule)(ref main3)).startSize = new MinMaxCurve(0.22f, 0.5f);
((MainModule)(ref main3)).startColor = MinMaxGradient.op_Implicit(new Color(0.82f, 0.88f, 0.98f, 0.85f));
((MainModule)(ref main3)).maxParticles = 1600;
((MainModule)(ref main3)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main3)).gravityModifier = MinMaxCurve.op_Implicit(0f);
ShapeModule shape3 = _splash.shape;
((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)5;
((ShapeModule)(ref shape3)).scale = new Vector3(46f, 0.01f, 46f);
EmissionModule emission3 = _splash.emission;
((EmissionModule)(ref emission3)).rateOverTime = MinMaxCurve.op_Implicit(0f);
SizeOverLifetimeModule sizeOverLifetime = _splash.sizeOverLifetime;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.3f, 1f, 1f));
ColorOverLifetimeModule colorOverLifetime = _splash.colorOverLifetime;
((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
Gradient val8 = new Gradient();
val8.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(Color.white, 0f),
new GradientColorKey(Color.white, 1f)
};
val8.alphaKeys = (GradientAlphaKey[])(object)new GradientAlphaKey[3]
{
new GradientAlphaKey(0.9f, 0f),
new GradientAlphaKey(0.5f, 0.45f),
new GradientAlphaKey(0f, 1f)
};
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val8);
ParticleSystemRenderer component2 = val7.GetComponent<ParticleSystemRenderer>();
component2.renderMode = (ParticleSystemRenderMode)2;
((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)component2).receiveShadows = false;
if ((Object)(object)((Renderer)_rainRenderer).sharedMaterial != (Object)null && ((Object)((Renderer)_rainRenderer).sharedMaterial).name == "RainStreak")
{
Material val9 = new Material(((Renderer)_rainRenderer).sharedMaterial)
{
name = "SplashRing"
};
val9.SetTexture("_MainTex", (Texture)(object)RingTex());
val9.SetColor("_Tint", new Color(1f, 1f, 1f, 0.75f));
if (val9.HasProperty("_Glow"))
{
val9.SetFloat("_Glow", 0.9f);
}
val9.renderQueue = 2991;
((Renderer)component2).sharedMaterial = val9;
}
GameObject val10 = new GameObject("RainSpray");
val10.transform.SetParent(val7.transform, false);
val10.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
_spray = val10.AddComponent<ParticleSystem>();
MainModule main4 = _spray.main;
((MainModule)(ref main4)).loop = true;
((MainModule)(ref main4)).startLifetime = MinMaxCurve.op_Implicit(0.3f);
((MainModule)(ref main4)).startSpeed = new MinMaxCurve(1.2f, 2.2f);
((MainModule)(ref main4)).startSize = MinMaxCurve.op_Implicit(0.11f);
((MainModule)(ref main4)).startColor = MinMaxGradient.op_Implicit(new Color(0.85f, 0.9f, 1f, 0.7f));
((MainModule)(ref main4)).maxParticles = 1500;
((MainModule)(ref main4)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main4)).gravityModifier = MinMaxCurve.op_Implicit(2.6f);
ShapeModule shape4 = _spray.shape;
((ShapeModule)(ref shape4)).shapeType = (ParticleSystemShapeType)5;
((ShapeModule)(ref shape4)).scale = new Vector3(46f, 46f, 0.1f);
EmissionModule emission4 = _spray.emission;
((EmissionModule)(ref emission4)).rateOverTime = MinMaxCurve.op_Implicit(0f);
ParticleSystemRenderer component3 = val10.GetComponent<ParticleSystemRenderer>();
((Renderer)component3).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)component3).receiveShadows = false;
if ((Object)(object)((Renderer)_rainRenderer).sharedMaterial != (Object)null && ((Object)((Renderer)_rainRenderer).sharedMaterial).name == "RainStreak")
{
((Renderer)component3).sharedMaterial = ((Renderer)_rainRenderer).sharedMaterial;
}
}
private static Texture2D RingTex()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
float num = ((float)j + 0.5f) / 64f - 0.5f;
float num2 = ((float)i + 0.5f) / 64f - 0.5f;
float num3 = Mathf.Sqrt(num * num + num2 * num2) * 2f;
float num4 = Mathf.Exp(0f - Mathf.Pow((num3 - 0.62f) * 6.5f, 2f));
float num5 = Mathf.Exp((0f - num3) * num3 * 30f) * 0.7f;
val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01(num4 + num5)));
}
}
val.Apply();
return val;
}
private void Rain(float w, Camera eye)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: 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_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_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_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_rain == (Object)null)
{
return;
}
float num = 0.7f + 0.5f * Mathf.PerlinNoise(Time.time * 0.13f, 9.1f);
EmissionModule emission = _rain.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Lerp(0f, 2800f, Mathf.Clamp01(w)) * num);
if ((Object)(object)_splash != (Object)null && (Object)(object)eye != (Object)null)
{
_splashBudget += Mathf.Lerp(0f, 260f, Mathf.Clamp01(w)) * num * Time.deltaTime;
Vector3 position = ((Component)eye).transform.position;
Vector3 val2 = default(Vector3);
RaycastHit val3 = default(RaycastHit);
Vector3 val4 = default(Vector3);
while (_splashBudget >= 1f)
{
_splashBudget -= 1f;
Vector2 val = Random.insideUnitCircle * 17f;
((Vector3)(ref val2))..ctor(position.x + val.x, position.y + 28f, position.z + val.y);
float num2 = WaterHeightAt(val2);
bool flag;
if (Physics.Raycast(val2, Vector3.down, ref val3, 90f, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val3)).point.y > num2 + 0.05f)
{
val4 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.03f;
flag = false;
}
else
{
((Vector3)(ref val4))..ctor(val2.x, num2 + 0.02f, val2.z);
flag = true;
}
EmitParams val5 = default(EmitParams);
((EmitParams)(ref val5)).position = val4;
EmitParams val6 = val5;
_splash.Emit(val6, 1);
if (flag && (Object)(object)_spray != (Object)null && Random.value < 0.6f)
{
val5 = default(EmitParams);
((EmitParams)(ref val5)).position = val4 + Vector3.up * 0.02f;
((EmitParams)(ref val5)).velocity = new Vector3(Random.Range(-0.4f, 0.4f), Random.Range(1.1f, 2f), Random.Range(-0.4f, 0.4f));
EmitParams val7 = val5;
_spray.Emit(val7, 1);
}
}
}
VelocityOverLifetimeModule velocityOverLifetime = _rain.velocityOverLifetime;
((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(_gale.x * 0.85f);
((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(_gale.z * 0.85f);
}
private void Darken(float w, Camera eye)
{
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Invalid comparison between Unknown and I4
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Invalid comparison between Unknown and I4
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_046b: Unknown result type (might be due to invalid IL or missing references)
//IL_04a4: 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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
_rescan -= Time.deltaTime;
if (_rescan <= 0f)
{
_rescan = 2f;
_lights = Object.FindObjectsByType<Light>((FindObjectsInactive)0, (FindObjectsSortMode)0);
_dayNightPresent = (Object)(object)GameObject.Find("NightSky") != (Object)null;
if (_state == 0 && _w < 0.02f)
{
_centerSet = false;
}
else if (!_centerSet)
{
Vector3 position = ((Component)this).transform.position;
Vector3 val;
float num;
if ((Object)(object)Island.CurIsland != (Object)null && Near(Island.IslandPos, position))
{
val = Island.IslandPos;
num = Island.IslandSize;
}
else if ((Object)(object)Island.CurIsland != (Object)null && Near(((Component)Island.CurIsland).transform.position, position))
{
val = ((Component)Island.CurIsland).transform.position;
num = Island.IslandSize;
}
else
{
val = position;
num = 380f;
}
_stormCenter = new Vector3(val.x, 0f, val.z);
_footprint = Mathf.Max(450f, num + 220f);
_centerSet = true;
WeatherPlugin.Log.LogInfo((object)("Storm anchored at " + ((Vector3)(ref _stormCenter)).ToString("0") + ", footprint " + _footprint.ToString("0") + "m."));
}
}
float num2 = Mathf.Clamp01(w);
float num3 = Mathf.Lerp(1f, 0.25f, num2);
if (_dayNightPresent)
{
Light[] lights = _lights;
foreach (Light val2 in lights)
{
if ((Object)(object)val2 != (Object)null && (int)val2.type == 1)
{
val2.intensity *= num3;
val2.color = Color.Lerp(val2.color, Color.Lerp(val2.color, GreyOf(val2.color), 0.6f), num2);
}
}
RenderSettings.ambientLight *= num3 * Mathf.Lerp(1f, 0.8f, num2);
RenderSettings.ambientIntensity *= num3 * Mathf.Lerp(1f, 0.8f, num2);
if (!((Object)(object)eye != (Object)null) || !(((Component)eye).transform.position.y < -0.9f))
{
RenderSettings.fogColor = Color.Lerp(RenderSettings.fogColor, _overcastNow, 0.92f * num2);
RenderSettings.fogDensity = Mathf.Max(RenderSettings.fogDensity * Mathf.Lerp(1f, 3.5f, num2), 0.011f * num2 * num2);
FogLine(num2);
}
return;
}
if (!_tookBase && w < 0.01f)
{
_baseIntensity.Clear();
Light[] lights2 = _lights;
foreach (Light val3 in lights2)
{
if ((Object)(object)val3 != (Object)null && (int)val3.type == 1)
{
_baseIntensity[val3] = val3.intensity;
}
}
_baseFogDensity = RenderSettings.fogDensity;
_baseFogColor = RenderSettings.fogColor;
_baseAmbient = RenderSettings.ambientLight;
_baseAmbientStrength = RenderSettings.ambientIntensity;
_tookBase = true;
}
if (!_tookBase)
{
return;
}
foreach (KeyValuePair<Light, float> item in _baseIntensity)
{
if ((Object)(object)item.Key != (Object)null)
{
item.Key.intensity = item.Value * num3;
}
}
RenderSettings.ambientLight = _baseAmbient * num3 * Mathf.Lerp(1f, 0.8f, num2);
RenderSettings.ambientIntensity = _baseAmbientStrength * num3 * Mathf.Lerp(1f, 0.8f, num2);
if (!((Object)(object)eye != (Object)null) || !(((Component)eye).transform.position.y < -0.9f))
{
RenderSettings.fogColor = Color.Lerp(_baseFogColor, _overcastNow, 0.92f * num2);
RenderSettings.fogDensity = Mathf.Max(_baseFogDensity * Mathf.Lerp(1f, 3.5f, num2), 0.011f * num2 * num2);
FogLine(num2);
}
}
private void FogLine(float k)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
if (!_tookFogLine)
{
_baseFogOn = RenderSettings.fog;
_baseFogStart = RenderSettings.fogStartDistance;
_baseFogEnd = RenderSettings.fogEndDistance;
_tookFogLine = true;
}
RenderSettings.fog = k > 0.02f || _baseFogOn;
if ((int)RenderSettings.fogMode == 1)
{
RenderSettings.fogStartDistance = Mathf.Lerp(_baseFogStart, 12f, k);
RenderSettings.fogEndDistance = Mathf.Lerp(_baseFogEnd, 170f, k);
}
}
private static Color GreyOf(Color c)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
float grayscale = ((Color)(ref c)).grayscale;
return new Color(grayscale * 0.96f, grayscale, grayscale * 1.05f);
}
private void Clouds(float w, Camera eye)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_0474: Unknown result type (might be due to invalid IL or missing references)
_overcastNow = Color.Lerp(new Color(0.52f, 0.54f, 0.58f), new Color(0.275f, 0.285f, 0.315f), Mathf.Clamp01(w));
if ((Object)(object)_shadeMat != (Object)null && (Object)(object)_shadeR == (Object)null)
{
_shadeMat = null;
_deckAMat = null;
_deckBMat = null;
WeatherPlugin.Log.LogInfo((object)"Storm sky was rebuilt - re-adopting.");
}
if ((Object)(object)_shadeMat == (Object)null)
{
_skySearch -= Time.deltaTime;
if (_skySearch > 0f)
{
return;
}
_skySearch = 3f;
GameObject val = GameObject.Find("NightSky");
if ((Object)(object)val == (Object)null)
{
return;
}
Transform val2 = val.transform.Find("StormShade");
_deckA = val.transform.Find("StormCloudsA");
_deckB = val.transform.Find("StormCloudsB");
if ((Object)(object)val2 == (Object)null || (Object)(object)_deckA == (Object)null || (Object)(object)_deckB == (Object)null)
{
WeatherPlugin.Log.LogWarning((object)"This sky bundle has no storm in it - rebuild and re-export the sky from Unity (the build menu does it) to get storm visuals.");
_skySearch = 60f;
return;
}
_shadeR = ((Component)val2).GetComponent<MeshRenderer>();
_deckAR = ((Component)_deckA).GetComponent<MeshRenderer>();
_deckBR = ((Component)_deckB).GetComponent<MeshRenderer>();
((Renderer)_shadeR).SetPropertyBlock((MaterialPropertyBlock)null);
((Renderer)_deckAR).SetPropertyBlock((MaterialPropertyBlock)null);
((Renderer)_deckBR).SetPropertyBlock((MaterialPropertyBlock)null);
_shadeMat = ((Renderer)_shadeR).material;
_deckAMat = ((Renderer)_deckAR).material;
_deckBMat = ((Renderer)_deckBR).material;
WeatherPlugin.Log.LogInfo((object)"Storm sky adopted from the bundle.");
BuildVeils();
}
float num = Mathf.Clamp01(w);
float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_localK * 1.6f));
float num3 = (_lidA = Mathf.Clamp01(num * 2.2f) * num2);
float num4 = FlashK();
float num5 = Mathf.Lerp(1f, 0.44f, num);
float num6 = 1f + num4 * 0.9f;
_shadeMat.SetColor("_Tint", new Color(num5 * num6, num5 * num6, num5 * 1.04f * num6, num3));
_deckAMat.SetColor("_Tint", new Color(num5 * num6, num5 * num6, num5 * 1.04f * num6, num3 * 0.95f));
_deckBMat.SetColor("_Tint", new Color(num5 * 0.9f * num6, num5 * 0.9f * num6, num5 * 0.95f * num6, num3 * 0.9f));
_spinA += Time.deltaTime * 0.35f;
_spinB -= Time.deltaTime * 0.55f;
_deckA.localRotation = Quaternion.AngleAxis(_spinA, Vector3.up);
_deckB.localRotation = Quaternion.AngleAxis(_spinB, Vector3.up);
if ((Object)(object)_veilRoot != (Object)null)
{
_veilRoot.transform.position = (Vector3)(_centerSet ? _stormCenter : new Vector3(((Component)this).transform.position.x, 0f, ((Component)this).transform.position.z));
_veilSpin += Time.deltaTime * 0.55f;
_veilRoot.transform.rotation = Quaternion.AngleAxis(_veilSpin, Vector3.up);
Color val3 = _overcastNow * (1.05f + num4 * 0.5f);
val3.a = Mathf.Clamp01((num - 0.15f) * 1.3f) * 0.5f;
_veilMat.SetColor("_Tint", val3);
_veilRoot.SetActive(val3.a > 0.02f);
}
}
private void BuildVeils()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_veilRoot != (Object)null) && !((Object)(object)_shadeMat == (Object)null))
{
_veilRoot = new GameObject("RainVeils");
Object.DontDestroyOnLoad((Object)(object)_veilRoot);
_veilMat = new Material(_shadeMat.shader)
{
name = "RainVeil"
};
_veilMat.SetTexture("_MainTex", (Texture)(object)VeilTex());
if (_veilMat.HasProperty("_HorizonFade"))
{
_veilMat.SetFloat("_HorizonFade", 0f);
}
_veilMat.renderQueue = 2958;
Random random = new Random(1337);
for (int i = 0; i < 7; i++)
{
GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
((Object)val).name = "RainVeil" + i;
Object.Destroy((Object)(object)val.GetComponent<Collider>());
val.transform.SetParent(_veilRoot.transform, false);
float num = (float)i / 7f * 360f + (float)random.NextDouble() * 30f;
float num2 = 250f + (float)(i % 3) * 75f;
val.transform.localPosition = Quaternion.Euler(0f, num, 0f) * new Vector3(0f, 46f, num2);
val.transform.localRotation = Quaternion.Euler(0f, num + 90f, 0f);
val.transform.localScale = new Vector3(220f + (float)random.NextDouble() * 90f, 95f + (float)random.NextDouble() * 20f, 1f);
MeshRenderer component = val.GetComponent<MeshRenderer>();
((Renderer)component).sharedMaterial = _veilMat;
((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)component).receiveShadows = false;
}
}
}
private static Texture2D VeilTex()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(64, 128, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 64; j++)
{
float num = (float)j / 64f;
float num2 = (float)i / 128f;
float num3 = Mathf.Sin(num * (float)Math.PI);
float num4 = 0.55f + 0.45f * Mathf.PerlinNoise((float)j * 0.9f, 3.3f);
float num5 = num3 * num4 * Mathf.Lerp(0.25f, 1f, num2);
val.SetPixel(j, i, new Color(1f, 1f, 1f, num5 * 0.8f));
}
}
val.Apply();
return val;
}
private float FlashK()
{
if (_flash <= 0f)
{
return 0f;
}
return Mathf.Clamp01(_flash / 0.45f) * _flashScale * (0.55f + Mathf.PingPong(Time.time * 41f, 0.45f));
}
private void Lightning(float w, Camera eye)
{
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Expected O, but got Unknown
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: 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_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Invalid comparison between Unknown and I4
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
if (!LightningOn)
{
_flash = 0f;
_pendingThunder = -1f;
_reFlash = -1f;
if ((Object)(object)_flashLight != (Object)null)
{
((Behaviour)_flashLight).enabled = false;
}
ShowBolt(on: false, 0f);
return;
}
if (w > 0.7f)
{
_nextStrike -= Time.deltaTime;
if (_nextStrike <= 0f)
{
_nextStrike = 35f + (float)new Random((int)(Time.time * 613f)).NextDouble() * 40f;
Strike(fromMenu: false);
}
}
if (w > 0.35f)
{
_sheetTimer -= Time.deltaTime;
if (_sheetTimer <= 0f)
{
_sheetTimer = 55f + Random.value * 55f;
_flash = 0.27f;
_flashScale = 0.35f;
_lastDelay = 3.2f + Random.value * 1.4f;
_pendingThunder = _lastDelay;
}
}
if (_reFlash > 0f)
{
_reFlash -= Time.deltaTime;
if (_reFlash <= 0f)
{
_flash = 0.35999998f;
AimBolt();
}
}
if (_flash > 0f)
{
_flash -= Time.deltaTime;
float num = FlashK();
if ((Object)(object)_flashLight == (Object)null)
{
GameObject val = new GameObject("LightningFlash");
val.transform.SetParent(((Component)this).transform, false);
val.transform.localPosition = new Vector3(0f, 60f, 0f);
_flashLight = val.AddComponent<Light>();
_flashLight.type = (LightType)2;
_flashLight.range = 400f;
_flashLight.color = new Color(0.92f, 0.94f, 1f);
_flashLight.shadows = (LightShadows)0;
}
((Behaviour)_flashLight).enabled = true;
_flashLight.intensity = num * 9f;
if (_boltTop != Vector3.zero)
{
((Component)_flashLight).transform.position = _boltTop + Vector3.down * 18f;
}
bool flag = _flashScale > 0.6f && _flash > 0.17999999f;
ShowBolt(flag, num);
if (_dayNightPresent || _tookBase)
{
float num2 = num * (0.3f + 0.7f * _localK);
RenderSettings.ambientLight += new Color(0.65f, 0.7f, 0.95f) * num2;
RenderSettings.fogColor = Color.Lerp(RenderSettings.fogColor, new Color(0.62f, 0.68f, 0.88f), num2 * 0.55f);
Light[] lights = _lights;
foreach (Light val2 in lights)
{
if ((Object)(object)val2 != (Object)null && (int)val2.type == 1)
{
val2.intensity += num2 * 1.3f;
val2.color = Color.Lerp(val2.color, Color.white, num2 * 0.5f);
}
}
}
}
else
{
if ((Object)(object)_flashLight != (Object)null)
{
((Behaviour)_flashLight).enabled = false;
}
ShowBolt(on: false, 0f);
}
if (!(_pendingThunder > 0f))
{
return;
}
_pendingThunder -= Time.deltaTime;
if (_pendingThunder <= 0f && (Object)(object)_thunderVoice != (Object)null)
{
float num3 = Mathf.InverseLerp(1.2f, 3.8f, _lastDelay);
_thunderVoice.pitch = 0.9f + Random.value * 0.2f - num3 * 0.15f;
if (ThunderOn)
{
AudioClip val3 = ((_thunderFiles.Count > 0) ? _thunderFiles[Random.Range(0, _thunderFiles.Count)] : SynthThunder(Random.Range(1, 999999)));
_thunderVoice.PlayOneShot(val3, Volume * Mathf.Lerp(0.5f, 0.18f, num3) * (0.4f + 0.6f * _localK));
}
_pendingThunder = -1f;
}
}
private void Strike(bool fromMenu)
{
_flash = 0.45f;
_flashScale = 1f;
AimBolt();
if (!fromMenu)
{
_lastDelay = 1.2f + (float)new Random((int)(Time.time * 271f)).NextDouble() * 2.6f;
_pendingThunder = _lastDelay;
}
else
{
_lastDelay = 1.2f;
_pendingThunder = 1f;
}
_reFlash = ((Random.value < 0.35f) ? 0.55f : (-1f));
}
private void EnsureBolt()
{
//IL_00db: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
if ((Object)(object)_bolt != (Object)null || (Object)(object)_boltMat != (Object)null)
{
return;
}
Material[] array = Resources.FindObjectsOfTypeAll<Material>();
foreach (Material val in array)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.shader != (Object)null && ((Object)val.shader).name == "HTF/NightSky" && (Object)(object)val.GetTexture("_MainTex") != (Object)null)
{
_boltMat = new Material(val)
{
name = "BoltGlow"
};
break;
}
}
if (!((Object)(object)_boltMat == (Object)null))
{
_boltMat.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
_boltMat.SetColor("_Tint", Color.white);
_boltMat.renderQueue = 2992;
if (_boltMat.HasProperty("_Glow"))
{
_boltMat.SetFloat("_Glow", 2.5f);
}
_bolt = NewBolt("Bolt", 1.7f);
_branchA = NewBolt("BoltBranchA", 0.6f);
_branchB = NewBolt("BoltBranchB", 0.6f);
}
}
private LineRenderer NewBolt(string name, float width)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
GameObject val = new GameObject(name);
val.transform.SetParent(((Component)this).transform.parent, false);
LineRenderer val2 = val.AddComponent<LineRenderer>();
((Renderer)val2).material = _boltMat;
val2.startWidth = width;
val2.endWidth = width * 0.35f;
val2.useWorldSpace = true;
val2.numCapVertices = 2;
((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val2).receiveShadows = false;
((Renderer)val2).enabled = false;
return val2;
}
private void AimBolt()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
EnsureBolt();
if (!((Object)(object)_bolt == (Object)null))
{
Vector3 val = (_centerSet ? _stormCenter : ((Component)this).transform.position);
float num = _footprint * 0.55f;
Vector3 val2 = (_boltTop = val + new Vector3(Random.Range(0f - num, num), 95f + Random.Range(0f, 45f), Random.Range(0f - num, num)));
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(val2.x + Random.Range(-30f, 30f), 0f, val2.z + Random.Range(-30f, 30f));
Vector3[] array = (Vector3[])(object)new Vector3[14];
Vector3 val4 = Vector3.zero;
for (int i = 0; i < array.Length; i++)
{
float num2 = (float)i / (float)(array.Length - 1);
val4 += new Vector3(Random.Range(-7f, 7f), 0f, Random.Range(-7f, 7f));
val4 *= 0.82f;
array[i] = Vector3.Lerp(val2, val3, num2) + val4 * Mathf.Sin(num2 * 3.1416f);
}
array[0] = val2;
array[^1] = val3;
_bolt.positionCount = array.Length;
_bolt.SetPositions(array);
AimBranch(_branchA, array[4]);
AimBranch(_branchB, array[8]);
}
}
private static void AimBranch(LineRenderer lr, Vector3 from)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)lr == (Object)null))
{
Vector3[] array = (Vector3[])(object)new Vector3[5];
Vector3 val = new Vector3(Random.Range(-1f, 1f), -1.6f, Random.Range(-1f, 1f));
Vector3 normalized = ((Vector3)(ref val)).normalized;
array[0] = from;
for (int i = 1; i < array.Length; i++)
{
array[i] = array[i - 1] + normalized * Random.Range(6f, 14f) + new Vector3(Random.Range(-4f, 4f), 0f, Random.Range(-4f, 4f));
}
lr.positionCount = array.Length;
lr.SetPositions(array);
}
}
private void ShowBolt(bool on, float k)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_bolt == (Object)null))
{
((Renderer)_bolt).enabled = on;
if ((Object)(object)_branchA != (Object)null)
{
((Renderer)_branchA).enabled = on;
}
if ((Object)(object)_branchB != (Object)null)
{
((Renderer)_branchB).enabled = on;
}
if (on && (Object)(object)_boltMat != (Object)null)
{
_boltMat.SetColor("_Tint", new Color(1f, 1f, 1f, Mathf.Clamp01(k * 1.3f)));
}
}
}
private void BuildAudio()
{
_rainA = ((Component)this).gameObject.AddComponent<AudioSource>();
_rainA.clip = SynthRainLoop(11, 7.31f, 9f);
_rainA.loop = true;
_rainA.volume = 0f;
_rainA.spatialBlend = 0f;
_rainA.Play();
_rainB = ((Component)this).gameObject.AddComponent<AudioSource>();
_rainB.clip = SynthRainLoop(29, 11.17f, 4f);
_rainB.loop = true;
_rainB.volume = 0f;
_rainB.spatialBlend = 0f;
_rainB.pitch = 0.93f;
_rainB.Play();
_rainFilter = ((Component)this).gameObject.AddComponent<AudioLowPassFilter>();
_rainFilter.cutoffFrequency = 1600f;
_stormLayer = ((Component)this).gameObject.AddComponent<AudioSource>();
_stormLayer.loop = true;
_stormLayer.volume = 0f;
_stormLayer.spatialBlend = 0f;
_wind = ((Component)this).gameObject.AddComponent<AudioSource>();
_wind.loop = true;
_wind.volume = 0f;
_wind.spatialBlend = 0f;
_thunderVoice = ((Component)this).gameObject.AddComponent<AudioSource>();
_thunderVoice.spatialBlend = 0f;
((MonoBehaviour)this).StartCoroutine(LoadRealAudio());
}
private IEnumerator LoadRealAudio()
{
string dir = Path.Combine(Path.GetDirectoryName(typeof(WeatherPlugin).Assembly.Location), "HTFWeatherAudio");
if (!Directory.Exists(dir))
{
dir = Path.Combine(Paths.PluginPath, "HTFWeatherAudio");
}
if (!Directory.Exists(dir))
{
yield break;
}
string[] files = Directory.GetFiles(dir);
foreach (string file in files)
{
string name = Path.GetFileNameWithoutExtension(file).ToLowerInvariant();
AudioType type = AudioTypeOf(file);
if ((int)type == 0)
{
continue;
}
UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + file.Replace('\\', '/'), type);
try
{
yield return req.SendWebRequest();
if ((int)req.result != 1)
{
WeatherPlugin.Log.LogWarning((object)("Could not load " + file + ": " + req.error));
continue;
}
AudioClip clip = DownloadHandlerAudioClip.GetContent(req);
if ((Object)(object)clip == (Object)null)
{
continue;
}
((Object)clip).name = name;
switch (name)
{
case "rain":
_rainA.clip = clip;
_rainA.pitch = 1f;
_rainA.Play();
if ((Object)(object)_rainB != (Object)null)
{
_rainB.volume = 0f;
}
_realRain = true;
break;
case "storm":
_stormLayer.clip = clip;
_stormLayer.Play();
_realStorm = true;
break;
case "wind":
_wind.clip = clip;
_wind.Play();
_realWind = true;
break;
default:
if (name.StartsWith("thunder"))
{
_thunderFiles.Add(clip);
}
break;
}
WeatherPlugin.Log.LogInfo((object)("Weather audio loaded: " + name));
}
finally
{
((IDisposable)req)?.Dispose();
}
}
}
private static AudioType AudioTypeOf(string file)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0048: Unknown result type (might be due to invalid IL or missing references)
return (AudioType)(Path.GetExtension(file).ToLowerInvariant() switch
{
".ogg" => 14,
".wav" => 20,
".mp3" => 13,
_ => 0,
});
}
private void Sound(float w)
{
float num = Mathf.Clamp01(w) * Volume;
float num2 = (_realRain ? 0.55f : 0.2f);
if ((Object)(object)_rainA != (Object)null)
{
_rainA.volume = num * num2;
}
if ((Object)(object)_rainB != (Object)null && !_realRain)
{
_rainB.volume = num * 0.16f;
}
if ((Object)(object)_stormLayer != (Object)null && _realStorm)
{
_stormLayer.volume = Mathf.Clamp01((w - 0.5f) * 2f) * 0.6f * Volume;
}
if ((Object)(object)_wind != (Object)null && _realWind)
{
float num3 = 0.6f + 0.4f * Mathf.PerlinNoise(Time.time * 0.15f, 8.2f);
_wind.volume = Mathf.Clamp01(w * 1.4f) * 0.45f * num3 * Volume;
}
if ((Object)(object)_rainFilter != (Object)null)
{
_rainFilter.cutoffFrequency = (_realRain ? 22000f : (1100f + 900f * Mathf.PerlinNoise(Time.time * 0.11f, 3.7f) + 600f * Mathf.Clamp01(w)));
}
}
private static AudioClip SynthRainLoop(int seed, float seconds, float dropsPerSec)
{
int num = (int)(22050f * seconds);
float[] array = new float[num];
Random random = new Random(seed);
float num2 = 0f;
float num3 = 0f;
float num4 = 0f;
for (int i = 0; i < num; i++)
{
float num5 = (float)i / 22050f;
float num6 = (float)(random.NextDouble() * 2.0 - 1.0);
num2 += 0.02f * (num6 - num2);
num3 += 0.24f * (num6 - num3);
num4 += 0.07f * (num6 - num4);
float num7 = 0.85f + 0.15f * Mathf.Sin(num5 * 0.7f + (float)seed);
array[i] = (num2 * 2f + (num3 - num4) * 0.8f) * 0.16f * num7;
}
int num8 = (int)(seconds * dropsPerSec);
for (int j = 0; j < num8; j++)
{
int num9 = random.Next(num - 2756);
float num10 = 0.03f + (float)random.NextDouble() * 0.05f;
float num11 = 900f + (float)random.NextDouble() * 2200f;
int num12 = 551;
for (int k = 0; k < num12; k++)
{
float num13 = (float)k / 22050f;
array[num9 + k] += Mathf.Sin(num13 * num11 * 6.28f) * Mathf.Exp((0f - num13) * 220f) * num10;
}
}
int num14 = 22050;
for (int l = 0; l < num14; l++)
{
float num15 = (float)l / (float)num14;
array[l] = array[l] * num15 + array[num - num14 + l] * (1f - num15);
}
float[] array2 = new float[num - num14];
Array.Copy(array, array2, num - num14);
return Clip("Rain" + seed, array2, 22050);
}
private static AudioClip SynthWindLoop(int seed, float seconds)
{
int num = (int)(22050f * seconds);
float[] array = new float[num];
Random random = new Random(seed);
float num2 = 0f;
float num3 = 0f;
float num4 = 0f;
for (int i = 0; i < num; i++)
{
float num5 = (float)i / 22050f;
float num6 = (float)(random.NextDouble() * 2.0 - 1.0);
num2 += 0.015f * (num6 - num2);
num3 += 0.05f * (num6 - num3);
num4 += 0.6f * (num3 - num4);
float num7 = 0.65f + 0.35f * Mathf.Sin(num5 * 0.9f + (float)seed) * Mathf.Sin(num5 * 0.37f + 1.3f);
array[i] = (num2 * 3.2f + num4 * 0.8f) * 0.5f * num7;
}
int num8 = 22050;
for (int j = 0; j < num8; j++)
{
float num9 = (float)j / (float)num8;
array[j] = array[j] * num9 + array[num - num8 + j] * (1f - num9);
}
float[] array2 = new float[num - num8];
Array.Copy(array, array2, num - num8);
return Clip("Wind" + seed, array2, 22050);
}
private static AudioClip SynthThunder(int seed)
{
int num = 121275;
float[] array = new float[num];
Random random = new Random(seed);
float num2 = 0f;
float num3 = 0f;
float num4 = 0.05f + (float)random.NextDouble() * 0.09f;
float num5 = 1.1f + (float)random.NextDouble() * 0.9f;
float num6 = 11f + (float)random.NextDouble() * 12f;
for (int i = 0; i < num; i++)
{
float num7 = (float)i / 22050f;
float num8 = (float)(random.NextDouble() * 2.0 - 1.0);
num2 += 0.04f * (num8 - num2);
num3 += 0.3f * (num8 - num3);
float num9 = num3 * (Mathf.Exp((0f - num7) * 11f) + 0.7f * Mathf.Exp((0f - Mathf.Max(0f, num7 - num4)) * 13f) * ((num7 > num4) ? 1f : 0f));
float num10 = num2 * 5f * Mathf.Exp((0f - num7) * 0.9f) * (0.65f + 0.35f * Mathf.Sin(num7 * num6 + (float)seed));
float num11 = num2 * 2.6f * Mathf.Exp((0f - Mathf.Max(0f, num7 - num5)) * 1.6f) * ((num7 > num5) ? 1f : 0f);
array[i] = Mathf.Clamp(num9 * 0.55f + num10 + num11, -1f, 1f) * 0.55f;
}
return Clip("Thunder", array, 22050);
}
private static AudioClip Clip(string name, float[] samples, int rate)
{
AudioClip val = AudioClip.Create(name, samples.Length, 1, rate, false);
if (_setData == null)
{
_setData = typeof(AudioClip).GetMethod("SetData", new Type[2]
{
typeof(float[]),
typeof(int)
});
}
_setData.Invoke(val, new object[2] { samples, 0 });
return val;
}
private unsafe static bool Pressed(KeyCode key)
{
//IL_0012: 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)
if (_inputMode <= 1)
{
try
{
bool keyDown = Input.GetKeyDown(key);
_inputMode = 1;
return keyDown;
}
catch (Exception)
{
_inputMode = 2;
}
}
if (_inputMode == 2)
{
try
{
Keyboard current = Keyboard.current;
if (current == null)
{
return false;
}
if (!Enum.TryParse<Key>(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), ignoreCase: true, out Key result))
{
return false;
}
return ((ButtonControl)current[result]).wasPressedThisFrame;
}
catch (Exception)
{
_inputMode = -1;
}
}
return false;
}
private unsafe static bool Held(KeyCode key)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
if (_inputMode <= 1)
{
try
{
return Input.GetKey(key);
}
catch (Exception)
{
}
}
try
{
Keyboard current = Keyboard.current;
if (current == null)
{
return false;
}
if (!Enum.TryParse<Key>(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), ignoreCase: true, out Key result))
{
return false;
}
return ((ButtonControl)current[result]).isPressed;
}
catch (Exception)
{
return false;
}
}
private void CloseMenu()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
_menuOpen = false;
Cursor.lockState = _wasLock;
Cursor.visible = _wasCursor;
if (SavePrefs != null)
{
SavePrefs(Volume, ThunderOn, LightningOn);
}
}
private static Rect OnScreen(Rect r)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
((Rect)(ref r)).x = Mathf.Clamp(((Rect)(ref r)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref r)).width));
((Rect)(ref r)).y = Mathf.Clamp(((Rect)(ref r)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref r)).height));
return r;
}
private void EnsureSkin()
{
//IL_006e: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_0129: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Expected O, but got Unknown
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Expected O, but got Unknown
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Expected O, but got Unknown
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Expected O, but got Unknown
if (!((Object)(object)_skin != (Object)null))
{
_skin = Object.Instantiate<GUISkin>(GUI.skin);
Color val = default(Color);
((Color)(ref val))..ctor(0.95f, 0.93f, 0.87f);
Color textColor = default(Color);
((Color)(ref textColor))..ctor(1f, 0.58f, 0.25f);
Texture2D background = RoundedTex(44, 44, 12, new Color(0.1f, 0.09f, 0.13f, 0.94f), 2, new Color(0.93f, 0.9f, 0.84f, 0.9f));
Texture2D background2 = RoundedTex(24, 24, 7, new Color(0.23f, 0.21f, 0.28f, 0.95f), 1, new Color(0.93f, 0.9f, 0.84f, 0.5f));
Texture2D background3 = RoundedTex(24, 24, 7, new Color(0.95f, 0.55f, 0.2f, 0.95f), 1, new Color(1f, 1f, 1f, 0.8f));
Texture2D background4 = RoundedTex(16, 12, 5, new Color(0.21f, 0.19f, 0.25f, 0.9f), 1, new Color(0.93f, 0.9f, 0.84f, 0.4f));
Texture2D background5 = RoundedTex(16, 16, 7, val, 0, Color.clear);
GUIStyle window = _skin.window;
window.normal.background = background;
window.onNormal.background = background;
window.normal.textColor = textColor;
window.onNormal.textColor = textColor;
window.fontSize = 14;
window.fontStyle = (FontStyle)1;
window.border = new RectOffset(14, 14, 14, 14);
window.padding = new RectOffset(14, 14, 28, 14);
GUIStyle button = _skin.button;
button.normal.background = background2;
button.hover.background = background3;
button.active.background = background3;
button.focused.background = background2;
button.normal.textColor = val;
button.hover.textColor = Color.white;
button.active.textColor = Color.white;
button.border = new RectOffset(8, 8, 8, 8);
button.padding = new RectOffset(10, 10, 5, 5);
_skin.label.normal.textColor = val;
_skin.toggle.normal.textColor = val;
_skin.toggle.onNormal.textColor = textColor;
_skin.toggle.hover.textColor = Color.white;
_skin.toggle.onHover.textColor = textColor;
GUIStyle horizontalSlider = _skin.horizontalSlider;
horizontalSlider.normal.background = background4;
horizontalSlider.border = new RectOffset(6, 6, 5, 5);
horizontalSlider.fixedHeight = 14f;
GUIStyle horizontalSliderThumb = _skin.horizontalSliderThumb;
horizontalSliderThumb.normal.background = background5;
horizontalSliderThumb.hover.background = background5;
horizontalSliderThumb.active.background = background5;
horizontalSliderThumb.fixedWidth = 16f;
horizontalSliderThumb.fixedHeight = 16f;
}
}
private static Texture2D RoundedTex(int wpx, int hpx, int radius, Color fill, int border, Color edge)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(wpx, hpx, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
for (int i = 0; i < hpx; i++)
{
for (int j = 0; j < wpx; j++)
{
float num = Mathf.Max((float)Mathf.Max(radius - j, j - (wpx - 1 - radius)), 0f);
float num2 = Mathf.Max((float)Mathf.Max(radius - i, i - (hpx - 1 - radius)), 0f);
float num3 = Mathf.Sqrt(num * num + num2 * num2);
Color val2 = ((!(num3 > (float)radius + 0.5f)) ? ((border > 0 && num3 > (float)(radius - border) + 0.5f) ? edge : ((border <= 0 || (j >= border && i >= border && j < wpx - border && i < hpx - border)) ? fill : edge)) : Color.clear);
val.SetPixel(j, i, val2);
}
}
val.Apply();
return val;
}
private void OnGUI()
{
//IL_0070: 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_0090: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
EnsureSkin();
GUISkin skin = GUI.skin;
GUI.skin = _skin;
DrawStormClock();
if (_menuOpen)
{
if (_devMenu)
{
_menuRect = OnScreen(GUILayout.Window(823477, _menuRect, new WindowFunction(DrawMenu), "Weather Dev", Array.Empty<GUILayoutOption>()));
}
else
{
_playerRect = OnScreen(GUILayout.Window(823478, _playerRect, new WindowFunction(DrawPlayerMenu), "Weather", Array.Empty<GUILayoutOption>()));
}
}
GUI.skin = skin;
}
private void DrawStormClock()
{
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Expected O, but got Unknown
if (_state == 0 && _w < 0.05f)
{
return;
}
string text = ((Override >= 0) ? ((Override == 2) ? "Storm (forced)" : ((Override == 1) ? "Rain (forced)" : "")) : ((_state == 2) ? ("Storm " + FmtClock((float)(_segEnd - _nowSeconds))) : ((_state != 1) ? "Clearing" : ("Rain " + FmtClock((float)(_segEnd - _nowSeconds))))));
if (!string.IsNullOrEmpty(text))
{
if (_clockStyle == null)
{
_clockStyle = new GUIStyle(GUI.skin.label);
_clockStyle.alignment = (TextAnchor)6;
_clockStyle.fontSize = 13;
}
Rect val = default(Rect);
((Rect)(ref val))..ctor(12f, (float)Screen.height - 30f, 260f, 22f);
Rect val2 = val;
((Rect)(ref val2)).x = ((Rect)(ref val2)).x + 1f;
((Rect)(ref val2)).y = ((Rect)(ref val2)).y + 1f;
GUI.color = new Color(0f, 0f, 0f, 0.65f);
GUI.Label(val2, text, _clockStyle);
GUI.color = new Color(1f, 1f, 1f, 0.85f);
GUI.Label(val, text, _clockStyle);
GUI.color = Color.white;
}
}
private static string FmtClock(float sec)
{
if (sec < 0f)
{
sec = 0f;
}
int num = (int)(sec / 60f);
int num2 = (int)(sec % 60f);
return num + ":" + num2.ToString("00");
}
private void DrawPlayerMenu(int id)
{
GUILayout.Label("Weather now: " + StateName(_state), Array.Empty<GUILayoutOption>());
GUILayout.Space(8f);
GUILayout.Label("Volume " + Mathf.RoundToInt(Volume * 100f) + "%", Array.Empty<GUILayoutOption>());
Volume = GUILayout.HorizontalSlider(Volume, 0f, 1f, Array.Empty<GUILayoutOption>());
GUILayout.Space(8f);
ThunderOn = GUILayout.Toggle(ThunderOn, " Thunder sounds", Array.Empty<GUILayoutOption>());
GUILayout.Space(2f);
LightningOn = GUILayout.Toggle(LightningOn, " Lightning strikes", Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
if (GUILayout.Button("Save and close", Array.Empty<GUILayoutOption>()))
{
CloseMenu();
}
GUI.DragWindow();
}
private void DrawMenu(int id)
{
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0411: Unknown result type (might be due to invalid IL or missing references)
string text = ((Override < 0) ? "AUTO (shared forecast)" : ((Override == 0) ? "forced CLEAR" : ((Override == 1) ? "forced RAIN" : "forced STORM")));
GUILayout.Label("Mode: " + text + " blend: " + _w.ToString("0.00"), Array.Empty<GUILayoutOption>());
int num = StateAt(_nowSeconds);
GUILayout.Label("Forecast: " + StateName(num) + " > " + StateName(StateOfEpoch(_segIndex + 1)) + " > " + StateName(StateOfEpoch(_segIndex + 2)) + " (" + FmtTime((float)(_segEnd - _nowSeconds)) + " left)", Array.Empty<GUILayoutOption>());
if (num == 2 && Override < 0 && !DarkEnough())
{
GUILayout.Label("(storm spell is WAITING ON THE LIGHT - rolling as rain until late afternoon)", Array.Empty<GUILayoutOption>());
}
bool flag = _w * Intensity > 0.7f;
GUILayout.Label("Wind: " + ((Vector3)(ref _gale)).magnitude.ToString("0.0") + " m/s " + Compass(_gale) + " next bolt: " + (flag ? (Mathf.Max(0f, _nextStrike).ToString("0") + "s") : "-") + " storm sky: " + (((Object)(object)_shadeMat != (Object)null) ? "adopted" : "searching"), Array.Empty<GUILayoutOption>());
_debugOpen = GUILayout.Toggle(_debugOpen, "Debug info", Array.Empty<GUILayoutOption>());
Camera val = Eye();
if (_debugOpen)
{
GUILayout.Label("Truth: shade " + (((Object)(object)_shadeMat != (Object)null) ? ("on a=" + _lidA.ToString("0.00")) : "MISSING") + " localK " + _localK.ToString("0.00") + " fog " + ((object)RenderSettings.fogMode/*cast due to .constrained prefix*/).ToString() + " d=" + RenderSettings.fogDensity.ToString("0.0000") + " end=" + RenderSettings.fogEndDistance.ToString("0") + " far=" + (((Object)(object)val != (Object)null) ? val.farClipPlane.ToString("0") : "?"), Array.Empty<GUILayoutOption>());
}
if (_debugOpen && (Object)(object)_shadeR != (Object)null)
{
GUILayout.Label("Shade: vis=" + ((Renderer)_shadeR).isVisible + " on=" + (((Renderer)_shadeR).enabled && ((Component)_shadeR).gameObject.activeInHierarchy) + " q=" + _shadeMat.renderQueue + " scale=" + ((Component)_shadeR).transform.lossyScale.x.ToString("0.00") + " dist=" + (((Object)(object)val != (Object)null) ? Vector3.Distance(((Component)val).transform.position, ((Component)_shadeR).transform.position).ToString("0") : "?") + " deckA vis=" + ((Object)(object)_deckAR != (Object)null && ((Renderer)_deckAR).isVisible) + " q=" + (((Object)(object)_deckAMat != (Object)null) ? _deckAMat.renderQueue.ToString() : "?"), Array.Empty<GUILayoutOption>());
}
GUILayout.Label("Audio: " + (_realRain ? "rain file" : "synth rain") + (_realStorm ? " + storm file" : "") + (_realWind ? " + wind file" : "") + " | thunder: " + ((_thunderFiles.Count > 0) ? (_thunderFiles.Count + " file(s)") : "synth"), Array.Empty<GUILayoutOption>());
GUILayout.Space(4f);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Auto", Array.Empty<GUILayoutOption>()))
{
Override = -1;
}
if (GUILayout.Button("Clear", Array.Empty<GUILayoutOption>()))
{
Override = 0;
}
if (GUILayout.Button("Rain", Array.Empty<GUILayoutOption>()))
{
Override = 1;
}
if (GUILayout.Button("Storm", Array.Empty<GUILayoutOption>()))
{
Override = 2;
}
GUILayout.EndHorizontal();
if (GUILayout.Button("Snap blend (skip the slow roll-in)", Array.Empty<GUILayoutOption>()))
{
_w = ((_state == 2) ? 1f : ((_state == 1) ? 0.45f : 0f));
}
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Bolt strike NOW", Array.Empty<GUILayoutOption>()))
{
Strike(fromMenu: true);
}
if (GUILayout.Button("Distant sheet flash", Array.Empty<GUILayoutOption>()))
{
_flash = 0.27f;
_flashScale = 0.35f;
_lastDelay = 3.4f;
_pendingThunder = _lastDelay;
}
GUILayout.EndHorizontal();
GUILayout.Space(4f);
GUILayout.Label("Volume: " + Volume.ToString("0.00") + " (saved when you close this menu)", Array.Empty<GUILayoutOption>());
Volume = GUILayout.HorizontalSlider(Volume, 0f, 1f, Array.Empty<GUILayoutOption>());
GUILayout.Space(4f);
GUILayout.Label("Forced states are local to you - Auto returns to the shared forecast.", Array.Empty<GUILayoutOption>());
GUI.DragWindow();
}
private static string StateName(int st)
{
return st switch
{
1 => "rain",
2 => "STORM",
_ => "clear",
};
}
private static string FmtTime(float sec)
{
if (sec >= 90f)
{
return Mathf.CeilToInt(sec / 60f) + " min";
}
return Mathf.CeilToInt(sec) + "s";
}
private static string Compass(Vector3 v)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (((Vector3)(ref v)).sqrMagnitude < 0.01f)
{
return "calm";
}
float num = Mathf.Atan2(v.x, v.z) * 57.29578f;
if (num < 0f)
{
num += 360f;
}
string[] array = new string[8] { "N", "NE", "E", "SE", "S", "SW", "W", "NW" };
return "to the " + array[Mathf.RoundToInt(num / 45f) % 8];
}
private static Camera Eye()
{
Camera val = null;
Camera[] allCameras = Camera.allCameras;
foreach (Camera val2 in allCameras)
{
if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && !((Object)(object)val2.targetTexture != (Object)null) && ((Object)(object)val == (Object)null || val2.depth > val.depth))
{
val = val2;
}
}
return ((Object)(object)val != (Object)null) ? val : Camera.main;
}
private static Func<double> MakeNetClock()
{
try
{
Type type = Type.GetType("FishNet.InstanceFinder, FishNet.Runtime");
if (type == null)
{
return null;
}
PropertyInfo tmProp = type.GetProperty("TimeManager", BindingFlags.Static | BindingFlags.Public);
if (tmProp == null)
{
return null;
}
PropertyInfo tickProp = null;
PropertyInfo deltaProp = null;
return delegate
{
try
{
object value = tmProp.GetValue(null, null);
if (value == null)
{
return -1.0;
}
if (tickProp == null)
{
tickProp = value.GetType().GetProperty("Tick");
deltaProp = value.GetType().GetProperty("TickDelta");
}
if (tickProp == null || deltaProp == null)
{
return -1.0;
}
uint num = Convert.ToUInt32(tickProp.GetValue(value, null));
if (num == 0)
{
return -1.0;
}
return (double)num * Convert.ToDouble(deltaProp.GetValue(value, null));
}
catch (Exception)
{
return -1.0;
}
};
}
catch (Exception)
{
return null;
}
}
private void OnDestroy()
{
//IL_0037: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
Color val = default(Color);
((Color)(ref val))..ctor(1f, 1f, 1f, 0f);
if ((Object)(object)_shadeMat != (Object)null)
{
_shadeMat.SetColor("_Tint", val);
}
if ((Object)(object)_deckAMat != (Object)null)
{
_deckAMat.SetColor("_Tint", val);
}
if ((Object)(object)_deckBMat != (Object)null)
{
_deckBMat.SetColor("_Tint", val);
}
if ((Object)(object)_veilRoot != (Object)null)
{
Object.Destroy((Object)(object)_veilRoot);
}
if ((Object)(object)_bolt != (Object)null)
{
Object.Destroy((Object)(object)((Component)_bolt).gameObject);
}
if ((Object)(object)_branchA != (Object)null)
{
Object.Destroy((Object)(object)((Component)_branchA).gameObject);
}
if ((Object)(object)_branchB != (Object)null)
{
Object.Destroy((Object)(object)((Component)_branchB).gameObject);
}
if (!_dayNightPresent && _tookBase)
{
foreach (KeyValuePair<Light, float> item in _baseIntensity)
{
if ((Object)(object)item.Key != (Object)null)
{
item.Key.intensity = item.Value;
}
}
RenderSettings.fogDensity = _baseFogDensity;
RenderSettings.fogColor = _baseFogColor;
RenderSettings.ambientLight = _baseAmbient;
RenderSettings.ambientIntensity = _baseAmbientStrength;
}
if (_tookFogLine)
{
RenderSettings.fog = _baseFogOn;
RenderSettings.fogStartDistance = _baseFogStart;
RenderSettings.fogEndDistance = _baseFogEnd;
}
}
}