using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On;
using REPOLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DeeprootGarden")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("DeeprootGarden")]
[assembly: AssemblyTitle("DeeprootGarden")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DeeprootGarden
{
[BepInPlugin("Beaniebe.DeeprootGarden", "Deeproot_Garden", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Action<AssetBundle> <>9__14_0;
public static Func<PlayerAvatar, string> <>9__16_2;
public static Func<string, string> <>9__16_3;
public static Func<int, int, int> <>9__16_4;
public static hook_ChangeLevel <>9__16_0;
internal void <LoadAssets>b__14_0(AssetBundle bundle)
{
_rainPrefab = bundle.LoadAsset<GameObject>("Assets/Rain/Rain.prefab");
_rainAmbience = bundle.LoadAsset<AudioClip>("Assets/Rain/RainAmbience.mp3");
}
internal void <Hook>b__16_0(orig_ChangeLevel orig, RunManager self, bool level, bool failed, ChangeLevelType type)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, level, failed, type);
int num = RunManager.instance.levelsCompleted + StringToInt(SessionManager.instance.crownedPlayerSteamID) + DateTime.UtcNow.Minute + DateTime.UtcNow.Hour + DateTime.UtcNow.Day + DateTime.UtcNow.Month + DateTime.UtcNow.Year + (from player in SemiFunc.PlayerGetList()
select player.playerName into playerName
orderby playerName
select playerName).Select(StringToInt).Aggregate((int sum, int i) => sum + i);
_log.LogDebug((object)$"Seed: {num}");
Random random = new Random(num);
if (((Object)self.levelCurrent).name != "Level - Garden" || random.NextDouble() > (double)((float)_chance.Value / 100f))
{
_log.LogInfo((object)"It's raining somewhere else...");
_isRaining = false;
if ((Object)(object)_rain != (Object)null)
{
((Component)_rain).gameObject.SetActive(false);
}
return;
}
_log.LogInfo((object)"Rain has started!");
_isRaining = true;
if ((Object)(object)_rain != (Object)null)
{
((Component)_rain).gameObject.SetActive(true);
_rain.Play();
}
_applyAmbienceTrigger = true;
}
internal string <Hook>b__16_2(PlayerAvatar player)
{
return player.playerName;
}
internal string <Hook>b__16_3(string playerName)
{
return playerName;
}
internal int <Hook>b__16_4(int sum, int i)
{
return sum + i;
}
}
public const string Guid = "Beaniebe.DeeprootGarden";
private static ManualLogSource _log;
private static GameObject _rainPrefab;
private static AudioClip _rainAmbience;
private static ConfigEntry<int> _chance;
private static ConfigEntry<float> _fogDensity;
private static ParticleSystem _rain;
private static bool _isRaining;
private static bool _applyAmbienceTrigger;
private const float FogLerpSpeed = 4f;
private const float FogEndDistance = 11f;
private static float _currentFog;
private const string LevelName = "Level - Garden";
private void Awake()
{
_log = ((BaseUnityPlugin)this).Logger;
LoadAssets();
BindConfig();
Hook();
}
private void LoadAssets()
{
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "rain");
BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle bundle)
{
_rainPrefab = bundle.LoadAsset<GameObject>("Assets/Rain/Rain.prefab");
_rainAmbience = bundle.LoadAsset<AudioClip>("Assets/Rain/RainAmbience.mp3");
}, false);
}
private void BindConfig()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
_chance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "RainChance", 30, new ConfigDescription("The percent chance for rain.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
_fogDensity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RainFogDensity", 0.9f, new ConfigDescription("Density of the fog when standing outside in rain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>()));
}
private void Hook()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//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_001f: Expected O, but got Unknown
object obj = <>c.<>9__16_0;
if (obj == null)
{
hook_ChangeLevel val = delegate(orig_ChangeLevel orig, RunManager self, bool level, bool failed, ChangeLevelType type)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, level, failed, type);
int num = RunManager.instance.levelsCompleted + StringToInt(SessionManager.instance.crownedPlayerSteamID) + DateTime.UtcNow.Minute + DateTime.UtcNow.Hour + DateTime.UtcNow.Day + DateTime.UtcNow.Month + DateTime.UtcNow.Year + (from player in SemiFunc.PlayerGetList()
select player.playerName into playerName
orderby playerName
select playerName).Select(StringToInt).Aggregate((int sum, int i) => sum + i);
_log.LogDebug((object)$"Seed: {num}");
Random random = new Random(num);
if (((Object)self.levelCurrent).name != "Level - Garden" || random.NextDouble() > (double)((float)_chance.Value / 100f))
{
_log.LogInfo((object)"It's raining somewhere else...");
_isRaining = false;
if ((Object)(object)_rain != (Object)null)
{
((Component)_rain).gameObject.SetActive(false);
}
}
else
{
_log.LogInfo((object)"Rain has started!");
_isRaining = true;
if ((Object)(object)_rain != (Object)null)
{
((Component)_rain).gameObject.SetActive(true);
_rain.Play();
}
_applyAmbienceTrigger = true;
}
};
<>c.<>9__16_0 = val;
obj = (object)val;
}
RunManager.ChangeLevel += (hook_ChangeLevel)obj;
AmbienceLoop.Update += (hook_Update)delegate(orig_Update orig, AmbienceLoop self)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (LevelGenerator.Instance.Generated && !(((Object)LevelGenerator.Instance.Level).name != "Level - Garden") && _isRaining)
{
if (_applyAmbienceTrigger)
{
ApplyAmbienceLoop();
_applyAmbienceTrigger = false;
}
RoomVolumeCheck roomVolumeCheck = PlayerController.instance.playerAvatarScript.RoomVolumeCheck;
if (roomVolumeCheck.CurrentRooms.Count != 0 && _isRaining)
{
if ((Object)(object)_rain == (Object)null)
{
_rain = InstantiateRain();
}
((Component)_rain).transform.position = ((Component)PlayerAvatar.instance).transform.position;
UpdateFog(roomVolumeCheck);
}
}
};
}
private void ApplyAmbienceLoop()
{
AudioLoopDistance[] array = Object.FindObjectsOfType<AudioLoopDistance>(true);
AudioLoopDistance[] array2 = array;
foreach (AudioLoopDistance val in array2)
{
Module componentInParent = ((Component)val).GetComponentInParent<Module>();
if ((Object)(object)componentInParent == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"AudioLoopDistance is not in module!");
}
else if (!componentInParent.StartRoom)
{
val.audioSource.clip = _rainAmbience;
}
}
}
private static ParticleSystem InstantiateRain()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
ParticleSystem component = Object.Instantiate<GameObject>(_rainPrefab).GetComponent<ParticleSystem>();
ParticleSystem[] componentsInChildren = ((Component)component).GetComponentsInChildren<ParticleSystem>();
ParticleSystem[] array = componentsInChildren;
foreach (ParticleSystem val in array)
{
MainModule main = val.main;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
}
component.Play();
return component;
}
private static void UpdateFog(RoomVolumeCheck volumeCheck)
{
RoomVolume val = volumeCheck.CurrentRooms[0];
float num = ((!val.Truck && !val.Module.StartRoom) ? (10f / _fogDensity.Value) : RunManager.instance.levelCurrent.FogEndDistance);
_currentFog = Mathf.Lerp(_currentFog, num, 4f * Time.deltaTime);
RenderSettings.fogEndDistance = _currentFog;
}
private static int StringToInt(string input)
{
if (string.IsNullOrEmpty(input))
{
return 0;
}
byte[] array = Encoding.UTF8.GetBytes(input);
Array.Resize(ref array, 4);
return BitConverter.ToInt32(array, 0);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DeeprootGarden";
public const string PLUGIN_NAME = "DeeprootGarden";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}