Decompiled source of ChefBazaar v1.0.0

ChefBazaar.dll

Decompiled 14 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[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("ChefBazaar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChefBazaar")]
[assembly: AssemblyTitle("ChefBazaar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ChefBazaar
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("acanthi.ChefBazaar", "ChefBazaar", "1.0.0")]
	public class ChefBazaar : BaseUnityPlugin
	{
		public const string PluginGUID = "acanthi.ChefBazaar";

		public const string PluginAuthor = "acanthi";

		public const string PluginName = "ChefBazaar";

		public const string PluginVersion = "1.0.0";

		public static List<string> chefPhrases;

		public static float chefChance;

		public static bool spawnScrapper;

		public static ExpansionDef expansionNeeded;

		public static GameObject tablePrefab;

		public void Awake()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			InitConfig();
			CreateTablePrefab();
			LanguageAPI.Add("CHEFBAZAAR_IAMHERE_1", "I come and I go, but today I am here.");
			LanguageAPI.Add("CHEFBAZAAR_IAMHERE_2", "Come, mon ami, we shall cook!");
			LanguageAPI.Add("CHEFBAZAAR_IAMHERE_3", "Tired, mon ami? Surely a meal will help.");
			LanguageAPI.Add("CHEFBAZAAR_IAMHERE_4", "It is okay to take a break every once in a while. Come now.");
			chefPhrases = new List<string>(4) { "CHEFBAZAAR_IAMHERE_1", "CHEFBAZAAR_IAMHERE_2", "CHEFBAZAAR_IAMHERE_3", "CHEFBAZAAR_IAMHERE_4" };
			if (spawnScrapper)
			{
				LanguageAPI.Add("CHEFBAZAAR_IAMHERE_5", "Please, do not use the scrapper as a garbage bin.");
				chefPhrases.Add("CHEFBAZAAR_IAMHERE_5");
			}
			expansionNeeded = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC3/DLC3.asset").WaitForCompletion();
			SceneDirector.onPostPopulateSceneServer += SceneDirector_onPostPopulateSceneServer;
		}

		private void CreateTablePrefab()
		{
			//IL_0020: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			tablePrefab = PrefabAPI.CreateEmptyPrefab("tablePrefab");
			tablePrefab.AddComponent<NetworkIdentity>();
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/bazaar/Bazaar_LunarTable.prefab").WaitForCompletion();
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/bazaar/Bazaar_HangingLight.prefab").WaitForCompletion();
			GameObject val3 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/bazaar/Bazaar_CrystalLight.prefab").WaitForCompletion();
			GameObject val4 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/lemuriantemple/Assets/LTWok.prefab").WaitForCompletion();
			GameObject val5 = Object.Instantiate<GameObject>(val, tablePrefab.transform);
			val5.transform.localPosition = new Vector3(-97.28f, -25.3f, -48.88f);
			val5.transform.localRotation = Quaternion.Euler(270f, 0f, 0f);
			val5.transform.localScale = Vector3.one;
			GameObject val6 = Object.Instantiate<GameObject>(val2, tablePrefab.transform);
			val6.transform.localPosition = new Vector3(-97.3327f, -4.507f, -48.562f);
			val6.transform.localRotation = Quaternion.identity;
			GameObject val7 = Object.Instantiate<GameObject>(val3, tablePrefab.transform);
			val7.transform.localPosition = new Vector3(-95.1891f, -24.0915f, -48.829f);
			val7.transform.localRotation = Quaternion.Euler(270f, 0f, 0f);
			val7.transform.localScale = Vector3.one;
			GameObject val8 = Object.Instantiate<GameObject>(val4, tablePrefab.transform);
			val8.transform.localPosition = new Vector3(-99.0918f, -23.18367f, -47.74821f);
			val8.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
			PrefabAPI.RegisterNetworkPrefab(tablePrefab);
		}

		private void SceneDirector_onPostPopulateSceneServer(SceneDirector obj)
		{
			//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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0120: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "bazaar") && Run.instance.IsExpansionEnabled(expansionNeeded) && !(Random.Range(0f, 100f) >= chefChance))
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/MealPrep/MealPrep.prefab").WaitForCompletion();
				GameObject val2 = Object.Instantiate<GameObject>(val, new Vector3(-97.3184f, -24.2f, -49.48f), Quaternion.Euler(0f, 270f, 0f));
				NetworkServer.Spawn(val2);
				if (spawnScrapper)
				{
					GameObject val3 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Scrapper/Scrapper.prefab").WaitForCompletion();
					GameObject val4 = Object.Instantiate<GameObject>(val3, new Vector3(-93.5723f, -25.8374f, -47.0965f), Quaternion.Euler(2.21f, 1.35f, 345.91f));
					NetworkServer.Spawn(val4);
				}
				Object.Instantiate<GameObject>(tablePrefab);
				NetworkServer.Spawn(tablePrefab);
				Chat.SendBroadcastChat((ChatMessageBase)new NpcChatMessage
				{
					formatStringToken = "MEALPREP_DIALOGUE_FORMAT",
					baseToken = chefPhrases[Random.Range(0, chefPhrases.Count)],
					sender = null
				});
				Debug.Log((object)"Chef!");
			}
		}

		private void InitConfig()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			chefChance = ((BaseUnityPlugin)this).Config.Bind<float>("ChefBazaar", "Wandering CHEF Chance", 35f, new ConfigDescription("How likely is the Wandering CHEF to appear in the Bazaar?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())).Value;
			spawnScrapper = ((BaseUnityPlugin)this).Config.Bind<bool>("ChefBazaar", "Spawn Scrapper", false, "Spawn a Scrapper next to the Wandering CHEF?").Value;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}