using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CelestialTintPlus.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
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: AssemblyTitle("LcOffice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LcOffice")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CelestialTintPlus
{
[BepInPlugin("Piggy.CelestialTintEdit", "CelestialTintEdit", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "Piggy.CelestialTintEdit";
private const string modName = "CelestialTintEdit";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Piggy.CelestialTintEdit");
private static Plugin Instance;
public static ManualLogSource mls;
public static AssetBundle Bundle;
public static string PluginDirectory;
public static AudioClip shipArrivalResound;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
mls = Logger.CreateLogSource("Piggy.CelestialTintEdit");
mls.LogInfo((object)"Celestial Tint Edit is loaded!");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "celestialplus"));
shipArrivalResound = Bundle.LoadAsset<AudioClip>("shipArrivalResound.wav");
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(StartOfRoundPatch));
}
}
}
namespace CelestialTintPlus.Patches
{
public static class CoroutineManager
{
internal class CoroutineManagerBehaviour : MonoBehaviour
{
}
private static MonoBehaviour _instance;
private static MonoBehaviour instance
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_instance == (Object)null)
{
_instance = (MonoBehaviour)(object)new GameObject("CoroutineManager").AddComponent<CoroutineManagerBehaviour>();
}
return _instance;
}
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
return instance.StartCoroutine(routine);
}
}
[HarmonyPatch(typeof(StartMatchLever))]
internal class StartMatchLeverPatch
{
[HarmonyPrefix]
[HarmonyPatch("PullLever")]
private static void PullLever_Prefix(StartMatchLever __instance)
{
if (__instance.leverHasBeenPulled)
{
CoroutineManager.StartCoroutine(StartOfRoundPatch.StartGameDelayed(GameObject.Find("Graphics Volume").GetComponent<Volume>().weight));
}
else
{
__instance.EndGame();
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix()
{
CoroutineManager.StartCoroutine(SetMoonBrightnessOnStart());
}
[HarmonyPostfix]
[HarmonyPatch("ArriveAtLevel")]
private static void ArriveAtLevel_Postfix(ref AudioSource ___ship3DAudio)
{
CoroutineManager.StartCoroutine(SetMoonBrightnessDelay(___ship3DAudio));
}
public static IEnumerator SetMoonBrightnessDelay(AudioSource ___ship3DAudio)
{
yield return (object)new WaitForSeconds(0.5f);
___ship3DAudio.PlayOneShot(Plugin.shipArrivalResound);
HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
if ((Object)(object)GameObject.Find("Prefab_Snow(Clone)") != (Object)null)
{
GameObject.Find("Graphics Volume").GetComponent<Volume>().weight = 0.75f;
GameObject.Find("Sky").GetComponentInChildren<Light>().intensity = 4f;
GameObject.Find("Sky").GetComponentInChildren<Light>().colorTemperature = 20000f;
}
else if ((Object)(object)GameObject.Find("Prefab_Wasteland(Clone)") != (Object)null)
{
GameObject.Find("Graphics Volume").GetComponent<Volume>().weight = 0.8f;
GameObject.Find("Sky").GetComponentInChildren<Light>().intensity = 12f;
}
else if ((Object)(object)GameObject.Find("Prefab_Forest(Clone)") != (Object)null)
{
GameObject.Find("Graphics Volume").GetComponent<Volume>().weight = 0.5f;
GameObject.Find("Sky").GetComponentInChildren<Light>().intensity = 10f;
}
}
public static IEnumerator SetMoonBrightnessOnStart()
{
yield return (object)new WaitForSeconds(0.5f);
if ((Object)(object)GameObject.Find("Prefab_Snow(Clone)") != (Object)null)
{
GameObject.Find("Graphics Volume").GetComponent<Volume>().weight = 0.75f;
GameObject.Find("Sky").GetComponentInChildren<Light>().intensity = 4f;
GameObject.Find("Sky").GetComponentInChildren<Light>().colorTemperature = 20000f;
}
else if ((Object)(object)GameObject.Find("Prefab_Wasteland(Clone)") != (Object)null)
{
GameObject.Find("Graphics Volume").GetComponent<Volume>().weight = 0.8f;
GameObject.Find("Sky").GetComponentInChildren<Light>().intensity = 12f;
}
else if ((Object)(object)GameObject.Find("Prefab_Forest(Clone)") != (Object)null)
{
GameObject.Find("Graphics Volume").GetComponent<Volume>().weight = 0.5f;
GameObject.Find("Sky").GetComponentInChildren<Light>().intensity = 10f;
}
}
public static IEnumerator StartGameDelayed(float weight)
{
Plugin.mls.LogInfo((object)"Delaying StartGame");
yield return (object)new WaitForSeconds(5f);
while (weight > 0.0001f)
{
weight -= Time.deltaTime * 0.1f;
}
Object.FindObjectOfType<StartMatchLever>().StartGame();
}
}
}