Decompiled source of Sagolasin v1.0.0

Sagolasin.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Sagolasin.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sagolasin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Sagolasin")]
[assembly: AssemblyTitle("Sagolasin")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Sagolasin
{
	[BepInPlugin("karster.sagolasin", "sagolasin", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGuid = "karster.sagolasin";

		private const string modName = "sagolasin";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("karster.sagolasin");

		private static Plugin instance;

		internal static ManualLogSource mls;

		public static AssetBundle MainAssets;

		public static AudioClip[] sagoSongs;

		internal static CultureInfo defaultSortCulture = CultureInfo.CreateSpecificCulture("en-US");

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("karster.sagolasin");
			MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sagomat"));
			mls.LogDebug((object)MainAssets.GetAllAssetNames());
			Item val = MainAssets.LoadAsset<Item>("sagoBox.asset");
			TerminalNode val2 = MainAssets.LoadAsset<TerminalNode>("sagoBoxInfo.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, 100);
			UnlockablesList val3 = MainAssets.LoadAsset<UnlockablesList>("UnlockableList.asset");
			UnlockableItem val4 = val3.unlockables[0];
			NetworkPrefabs.RegisterNetworkPrefab(val4.prefabObject);
			Unlockables.RegisterUnlockable(val4, 30, (StoreType)2);
			sagoSongs = LoadAudioAssetBundle("sagosongs");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(SagoBoxPatch));
		}

		private static AudioClip[] LoadAudioAssetBundle(string assetBundleName)
		{
			try
			{
				AudioClip[] array = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Info.Location), assetBundleName)).LoadAllAssets<AudioClip>();
				mls.LogInfo((object)$"Successfully loaded {array.Length} audio clips from asset bundle: {assetBundleName}");
				return array;
			}
			catch
			{
				mls.LogError((object)"Failed to load audios Asset Bundle.");
				return (AudioClip[])(object)new AudioClip[0];
			}
		}
	}
}
namespace Sagolasin.Patches
{
	[HarmonyPatch(typeof(BoomboxItem), "Start")]
	internal class SagoBoxPatch
	{
		[HarmonyPostfix]
		private static void Patch(ref BoomboxItem __instance)
		{
			if (((Object)__instance).name.StartsWith("Sagobox"))
			{
				__instance.musicAudios = Plugin.sagoSongs;
			}
		}
	}
}