Decompiled source of Stagnant Pipeworks v1.0.0

plugins/SwampyBog_winslow.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using ShaderSwapper;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class ReplaceShaders : MonoBehaviour
{
}
namespace SwampyBog_winslow;

public class CalculateNetworkCost : MonoBehaviour
{
	private void Start()
	{
		if (NetworkServer.active)
		{
			PurchaseInteraction componentInChildren = ((Component)this).GetComponentInChildren<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.Networkcost = Run.instance.GetDifficultyScaledCost(componentInChildren.cost);
				componentInChildren.solitudeCost = componentInChildren.Networkcost;
			}
		}
	}
}
public class SwampyBog_winslowContent : IContentPackProvider
{
	internal const string ScenesAssetBundleFileName = "swampybog_winslowscene";

	internal const string AssetsAssetBundleFileName = "swampybog_winslowassets";

	internal const string MusicSoundBankFileName = "SwampyBogMusic.bnk";

	internal const string InitSoundBankFileName = "SwampyBogInit.bnk";

	internal const string SoundsSoundBankFileName = "SwampyBogSounds.bnk";

	private static AssetBundle scenesAssetBundle;

	private static AssetBundle contentAssetBundle;

	public static SceneDef SwampyBogSceneDef;

	public static SceneDef SwampyBogNightSceneDef;

	public string identifier => "com.Winslow.SwampyBog_winslow";

	public static ReadOnlyContentPack readOnlyContentPack => new ReadOnlyContentPack(SwampyBog_winslowContentPack);

	internal static ContentPack SwampyBog_winslowContentPack { get; } = new ContentPack();

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		LoadSoundBanks(Path.Combine(Path.GetDirectoryName(typeof(SwampyBog_winslowContent).Assembly.Location), "soundbanks"));
		yield return LoadAssetBundle(Path.Combine(SwampyBog_winslowMain.assetBundleDir, "swampybog_winslowscene"), args.progressReceiver, delegate(AssetBundle assetBundle)
		{
			scenesAssetBundle = assetBundle;
		});
		yield return LoadAssetBundle(Path.Combine(SwampyBog_winslowMain.assetBundleDir, "swampybog_winslowassets"), args.progressReceiver, delegate(AssetBundle assetBundle)
		{
			contentAssetBundle = assetBundle;
		});
		yield return LoadAllAssetsAsync<SceneDef>(contentAssetBundle, args.progressReceiver, (Action<SceneDef[]>)delegate(SceneDef[] assets)
		{
			SwampyBogSceneDef = assets.First((SceneDef sceneDef) => sceneDef.cachedName == "swampybog_winslow");
			SwampyBogNightSceneDef = assets.First((SceneDef sceneDef) => sceneDef.cachedName == "swampybognight_winslow");
			SwampyBog_winslowContentPack.sceneDefs.Add(assets);
		});
		IEnumerator upgradeStubbedShaders = ShaderSwapper.UpgradeStubbedShadersAsync(contentAssetBundle);
		while (upgradeStubbedShaders.MoveNext())
		{
			yield return upgradeStubbedShaders.Current;
		}
		yield return LoadAllAssetsAsync<UnlockableDef>(contentAssetBundle, args.progressReceiver, (Action<UnlockableDef[]>)delegate(UnlockableDef[] assets)
		{
			SwampyBog_winslowContentPack.unlockableDefs.Add(assets);
		});
		StageRegistration.RegisterSceneDefToNormalProgression(SwampyBogSceneDef, 1f, true, true);
		StageRegistration.RegisterSceneDefToNormalProgression(SwampyBogNightSceneDef, 1f, true, true);
	}

	private IEnumerator LoadAssetBundle(string assetBundleFullPath, IProgress<float> progress, Action<AssetBundle> onAssetBundleLoaded)
	{
		AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundleFullPath);
		while (!((AsyncOperation)assetBundleCreateRequest).isDone)
		{
			progress.Report(((AsyncOperation)assetBundleCreateRequest).progress);
			yield return null;
		}
		onAssetBundleLoaded(assetBundleCreateRequest.assetBundle);
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(SwampyBog_winslowContentPack, args.output);
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		args.ReportProgress(1f);
		yield break;
	}

	private void AddSelf(AddContentPackProviderDelegate addContentPackProvider)
	{
		addContentPackProvider.Invoke((IContentPackProvider)(object)this);
	}

	internal SwampyBog_winslowContent()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddSelf);
	}

	private static IEnumerator LoadAllAssetsAsync<T>(AssetBundle assetBundle, IProgress<float> progress, Action<T[]> onAssetsLoaded) where T : Object
	{
		AssetBundleRequest sceneDefsRequest = assetBundle.LoadAllAssetsAsync<T>();
		while (!((AsyncOperation)sceneDefsRequest).isDone)
		{
			progress.Report(((AsyncOperation)sceneDefsRequest).progress);
			yield return null;
		}
		onAssetsLoaded(sceneDefsRequest.allAssets.Cast<T>().ToArray());
	}

	internal static void LoadSoundBanks(string soundbanksFolderPath)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: 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)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//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)
		AKRESULT val = AkSoundEngine.AddBasePath(soundbanksFolderPath);
		SwampyBog_winslowMain.LogInfo($"AddBasePath result: {val} | Path: {soundbanksFolderPath}");
		uint num = default(uint);
		val = AkSoundEngine.LoadBank("SwampyBogInit.bnk", ref num);
		val = AkSoundEngine.LoadBank("SwampyBogSounds.bnk", ref num);
		val = AkSoundEngine.LoadBank("SwampyBogMusic.bnk", ref num);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Winslow.SwampyBog_winslow", "SwampyBog", "1.0.0")]
public class SwampyBog_winslowMain : BaseUnityPlugin
{
	public const string GUID = "com.Winslow.SwampyBog_winslow";

	public const string MODNAME = "SwampyBog";

	public const string VERSION = "1.0.0";

	public static PluginInfo pluginInfo { get; private set; }

	public static SwampyBog_winslowMain instance { get; private set; }

	internal static AssetBundle assetBundle { get; private set; }

	internal static string assetBundleDir => Path.Combine(Path.GetDirectoryName(pluginInfo.Location));

	private void Awake()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		instance = this;
		pluginInfo = ((BaseUnityPlugin)this).Info;
		new SwampyBog_winslowContent();
		MusicController.StartIntroMusic += new hook_StartIntroMusic(MusicController_StartIntroMusic);
		Language.collectLanguageRootFolders += CollectLanguageRootFolders;
	}

	private void MusicController_StartIntroMusic(orig_StartIntroMusic orig, MusicController self)
	{
		orig.Invoke(self);
		AkSoundEngine.PostEvent("SwampyBog_Play_Music_System", ((Component)self).gameObject);
	}

	private void Destroy()
	{
		Language.collectLanguageRootFolders -= CollectLanguageRootFolders;
	}

	public void CollectLanguageRootFolders(List<string> folders)
	{
		folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language"));
		folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Plugins/Language"));
	}

	internal static void LogFatal(object data)
	{
		((BaseUnityPlugin)instance).Logger.LogFatal(data);
	}

	internal static void LogError(object data)
	{
		((BaseUnityPlugin)instance).Logger.LogError(data);
	}

	internal static void LogWarning(object data)
	{
		((BaseUnityPlugin)instance).Logger.LogWarning(data);
	}

	internal static void LogMessage(object data)
	{
		((BaseUnityPlugin)instance).Logger.LogMessage(data);
	}

	internal static void LogInfo(object data)
	{
		((BaseUnityPlugin)instance).Logger.LogInfo(data);
	}

	internal static void LogDebug(object data)
	{
		((BaseUnityPlugin)instance).Logger.LogDebug(data);
	}
}