Decompiled source of AstolfoPlushie v1.1.2

AstolfoPlushie/AstolfoPlushie.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AstolfoPlushie.MonoBehaviours;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AstolfoPlushie")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Particular")]
[assembly: AssemblyProduct("AstolfoPlushie")]
[assembly: AssemblyCopyright("Copyright © Particular 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ad767335-6fbc-4d6f-a638-9b41e4e7ebe9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AstolfoPlushie
{
	public class Config
	{
		public static ConfigEntry<bool> devMode;

		public static ConfigEntry<bool> extraAstolfos;

		public static ConfigEntry<int> int_astolfoPlushie_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_gold_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_red_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_green_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_blue_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_yellow_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_diamond_spawnChance;

		public static ConfigEntry<int> int_astolfoPlushie_emerald_spawnChance;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_experimentation;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_assurance;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_vow;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_offense;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_march;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_rend;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_dine;

		public static ConfigEntry<float> int_astolfoPlushie_spawnMultiplier_titan;

		public static void Load()
		{
			extraAstolfos = AstolfoPlushieMod.config.Bind<bool>("Extras", "TooManyAstolfos", true, "This option enables every Astolfo Plushie variation avaliable in the mod, Example: Red Astolfo Plushie");
			devMode = AstolfoPlushieMod.config.Bind<bool>("Extras", "Developer Mode", false, "This option adds every Astolfo Plushie variation avaliable to the Shop");
			int_astolfoPlushie_spawnChance = AstolfoPlushieMod.config.Bind<int>("Astolfo Rarity", "Common Astolfo", 10, "How much Astolfo Plushie spawns, higher = more");
			int_astolfoPlushie_gold_spawnChance = AstolfoPlushieMod.config.Bind<int>("Astolfo Rarity", "Gold Astolfo", 1, "How much Gold Astolfo Plushie spawns, higher = more (Not affected by Multipliers)");
			int_astolfoPlushie_red_spawnChance = AstolfoPlushieMod.config.Bind<int>("TooManyAstolfos Rarity", "Red Astolfo", 20, "How much Red Astolfo Plushie spawns, higher = more");
			int_astolfoPlushie_green_spawnChance = AstolfoPlushieMod.config.Bind<int>("TooManyAstolfos Rarity", "Green Astolfo", 20, "How much Green Astolfo Plushie spawns, higher = more");
			int_astolfoPlushie_blue_spawnChance = AstolfoPlushieMod.config.Bind<int>("TooManyAstolfos Rarity", "Blue Astolfo", 20, "How much Blue Astolfo Plushie spawns, higher = more");
			int_astolfoPlushie_yellow_spawnChance = AstolfoPlushieMod.config.Bind<int>("TooManyAstolfos Rarity", "Yellow Astolfo", 20, "How much Yellow Astolfo Plushie spawns, higher = more");
			int_astolfoPlushie_emerald_spawnChance = AstolfoPlushieMod.config.Bind<int>("TooManyAstolfos Rarity", "Emerald Astolfo", 1, "How much Emerald Astolfo Plushie spawns, higher = more (Not affected by Multipliers)");
			int_astolfoPlushie_diamond_spawnChance = AstolfoPlushieMod.config.Bind<int>("TooManyAstolfos Rarity", "Diamond Astolfo", 1, "How much Diamond Astolfo Plushie spawns, higher = more (Not affected by Multipliers)");
			int_astolfoPlushie_spawnMultiplier_experimentation = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Experimentation", 0.3f, "Rarity multiplier for Experimentation");
			int_astolfoPlushie_spawnMultiplier_assurance = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Assurance", 0.5f, "Rarity multiplier for Assurance");
			int_astolfoPlushie_spawnMultiplier_vow = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Vow", 1f, "Rarity multiplier for Vow");
			int_astolfoPlushie_spawnMultiplier_offense = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Offense", 1f, "Rarity multiplier for Offense");
			int_astolfoPlushie_spawnMultiplier_march = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "March", 1f, "Rarity multiplier for March");
			int_astolfoPlushie_spawnMultiplier_rend = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Rend", 2f, "Rarity multiplier for Rend");
			int_astolfoPlushie_spawnMultiplier_dine = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Dine", 1.5f, "Rarity multiplier for Dine");
			int_astolfoPlushie_spawnMultiplier_titan = AstolfoPlushieMod.config.Bind<float>("Rarity Multiplier", "Titan", 1.5f, "Rarity multiplier for Titan");
		}
	}
	internal class Content
	{
		public class CustomItem
		{
			public string name = "";

			public string itemPath = "";

			public string infoPath = "";

			public Action<Item> itemAction = delegate
			{
			};

			public bool enabled = true;

			public CustomItem(string name, string itemPath, string infoPath, Action<Item> action = null)
			{
				this.name = name;
				this.itemPath = itemPath;
				this.infoPath = infoPath;
				if (action != null)
				{
					itemAction = action;
				}
			}

			public static CustomItem Add(string name, string itemPath, string infoPath = null, Action<Item> action = null)
			{
				return new CustomItem(name, itemPath, infoPath, action);
			}
		}

		public class CustomScrap : CustomItem
		{
			public LevelTypes levelType = (LevelTypes)(-1);

			public int rarity = 0;

			public CustomScrap(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null)
				: base(name, itemPath, null, action)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				this.levelType = levelType;
				this.rarity = rarity;
			}

			public static CustomScrap Add(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				return new CustomScrap(name, itemPath, levelType, rarity, action);
			}

			public static CustomScrap AddWithVerification(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null, bool enabled = true)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				CustomScrap customScrap = new CustomScrap(name, itemPath, levelType, rarity, action);
				customScrap.enabled = enabled;
				return customScrap;
			}
		}

		public static AssetBundle MainAssets;

		public static Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();

		private const string assetName = "astolfomod";

		public static List<CustomItem> customItems;

		public static void TryLoadAssets()
		{
			if ((Object)(object)MainAssets == (Object)null)
			{
				MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "astolfomod"));
				AstolfoPlushieMod.logger.LogInfo((object)"Loaded asset bundle");
			}
		}

		public static void Load()
		{
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Invalid comparison between Unknown and I4
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			TryLoadAssets();
			customItems = new List<CustomItem>
			{
				CustomScrap.Add("AstolfoPlushie", "Assets/Astolfo/AstolfoPlushie_Item.asset", (LevelTypes)1, Config.int_astolfoPlushie_spawnChance.Value),
				CustomScrap.Add("AstolfoPlushie_Gold", "Assets/Astolfo/AstolfoGold/AstolfoPlushieGold_Item.asset", (LevelTypes)(-1), Config.int_astolfoPlushie_gold_spawnChance.Value),
				CustomScrap.AddWithVerification("AstolfoPlushie_Red", "Assets/Astolfo/AstolfoRed/AstolfoPlushieRed_Item.asset", (LevelTypes)1, Config.int_astolfoPlushie_red_spawnChance.Value, null, Config.extraAstolfos.Value),
				CustomScrap.AddWithVerification("AstolfoPlushie_Green", "Assets/Astolfo/AstolfoGreen/AstolfoPlushieGreen_Item.asset", (LevelTypes)1, Config.int_astolfoPlushie_green_spawnChance.Value, null, Config.extraAstolfos.Value),
				CustomScrap.AddWithVerification("AstolfoPlushie_Blue", "Assets/Astolfo/AstolfoBlue/AstolfoPlushieBlue_Item.asset", (LevelTypes)1, Config.int_astolfoPlushie_blue_spawnChance.Value, null, Config.extraAstolfos.Value),
				CustomScrap.AddWithVerification("AstolfoPlushie_Yellow", "Assets/Astolfo/AstolfoYellow/AstolfoPlushieYellow_Item.asset", (LevelTypes)1, Config.int_astolfoPlushie_yellow_spawnChance.Value, null, Config.extraAstolfos.Value),
				CustomScrap.AddWithVerification("AstolfoPlushie_Emerald", "Assets/Astolfo/AstolfoEmerald/AstolfoPlushieEmerald_Item.asset", (LevelTypes)(-1), Config.int_astolfoPlushie_emerald_spawnChance.Value, null, Config.extraAstolfos.Value),
				CustomScrap.AddWithVerification("AstolfoPlushie_Diamond", "Assets/Astolfo/AstolfoDiamond/AstolfoPlushieDiamond_Item.asset", (LevelTypes)(-1), Config.int_astolfoPlushie_diamond_spawnChance.Value, null, Config.extraAstolfos.Value)
			};
			foreach (CustomItem customItem in customItems)
			{
				if (!customItem.enabled)
				{
					continue;
				}
				Item val = MainAssets.LoadAsset<Item>(customItem.itemPath);
				if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null && (Object)(object)val.spawnPrefab.GetComponent<CustomNetworkTransform>() == (Object)null)
				{
					NetworkTransform val2 = val.spawnPrefab.AddComponent<NetworkTransform>();
					val2.SlerpPosition = false;
					val2.Interpolate = false;
					val2.SyncPositionX = false;
					val2.SyncPositionY = false;
					val2.SyncPositionZ = false;
					val2.SyncScaleX = false;
					val2.SyncScaleY = false;
					val2.SyncScaleZ = false;
					val2.UseHalfFloatPrecision = true;
				}
				Prefabs.Add(customItem.name, val.spawnPrefab);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Utilities.FixMixerGroups(val.spawnPrefab);
				customItem.itemAction(val);
				if (customItem is CustomScrap && Config.devMode.Value)
				{
					TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
					val3.clearPreviousText = true;
					val3.displayText = "This is a dangerous Plushie\n\n";
					Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val3, 0);
				}
				if (customItem is CustomScrap)
				{
					AstolfoPlushieMod.logger.LogInfo((object)("Registering scrap item " + customItem.name));
					if ((int)((CustomScrap)customItem).levelType == -1)
					{
						Items.RegisterScrap(val, ((CustomScrap)customItem).rarity, ((CustomScrap)customItem).levelType);
						continue;
					}
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_experimentation.Value), (LevelTypes)4);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_assurance.Value), (LevelTypes)8);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_vow.Value), (LevelTypes)16);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_offense.Value), (LevelTypes)32);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_march.Value), (LevelTypes)64);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_rend.Value), (LevelTypes)128);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_dine.Value), (LevelTypes)256);
					Items.RegisterScrap(val, (int)((float)((CustomScrap)customItem).rarity * Config.int_astolfoPlushie_spawnMultiplier_titan.Value), (LevelTypes)512);
				}
			}
			AstolfoPlushieMod.logger.LogInfo((object)"Loaded all Astolfo Plushies!");
		}
	}
	[BepInPlugin("Lugom.AstolfoPlushie", "Astolfo Plushie", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AstolfoPlushieMod : BaseUnityPlugin
	{
		private const string modGUID = "Lugom.AstolfoPlushie";

		private const string modName = "Astolfo Plushie";

		private const string modVersion = "1.1.2";

		private readonly Harmony harmony = new Harmony("Lugom.AstolfoPlushie");

		private static AstolfoPlushieMod instance;

		public static ManualLogSource logger;

		public static ConfigFile config;

		private void Awake()
		{
			instance = this;
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			Config.Load();
			Content.Load();
			logger.LogMessage((object)"\n                                                      %%                        \n                           ,/@@@@@@@@@@@@@@&(,            @/\n                     *@ @/ ....@/@@(, ..&@                      @.                \n                  @@......................**         @           %#             \n              *@........,% &..................*/  /* @@@@@&          @           \n          @@@@........@..........,..............(@@@@@@@             #          \n           @.......(...............@........   ....@@@@                @        \n          %......@..................@........     ...@                  /       \n        @......@......................*.......      ...(                /       \n       @.....,.........................@......        ..(                @      \n      @.....@..................................         ..&               /     \n     @........,....@......................@.....      .....@              @     \n    (....@...@     . #...%,   @.%* @.*@.@...#...   .. ......%             .     \n    @...&.., @,@##&/ .        . , (@####@@/@.*.. ............,             @    \n   #...,..*   %######           @#########   @.@...............*           #    \n   @..@...@   @ ..,#@          @ @/./......   @..@.........@#/,*,           *   \n   #....../    @*.*@              @.....@    @.....@........                @   \n  @..*...@@*          &,,,,,,,,,@             @......@....#                 (   \n   @.@...&  @           @*,,,,,*%             @..(.....%..@                 /&  \n      @... #                                 @.../.......*       ,              \n       @..@ %@@  @@.                         @...#......(      ,(               \n         @              @@*                 @...,@......@ @#    @               \n                                  ,@@@@,   @....*@..,#,                         \n                                           @..*@@@@,(                           \n                                           &.@@@@@@@@%                          \n                                          /.*@.,@@@@@@@@.                       \n                                         @.......@   @                          \n                                          @.....@                               \n                                            @/@                                 ");
			harmony.PatchAll(typeof(AstolfoPlushieMod));
		}
	}
}
namespace AstolfoPlushie.MonoBehaviours
{
	public class CustomNetworkTransform : NetworkBehaviour
	{
		public bool syncPosition = true;

		public bool syncRotation = true;

		public bool syncScale = true;

		public float positionDiffLimit = 0.1f;

		public float rotationDiffLimit = 0.1f;

		public float scaleDiffLimit = 0.1f;

		public bool lerpPosition = true;

		public bool lerpRotation = true;

		public bool lerpScale = true;

		public float positionLerpSpeed = 10f;

		public float rotationLerpSpeed = 10f;

		public float scaleLerpSpeed = 10f;

		private Vector3 _lastPosition;

		private Vector3 _lastRotation;

		private Vector3 _lastScale;

		private Vector3 _targetPosition;

		private Quaternion _targetRotation;

		private Vector3 _targetScale;

		public void FixedUpdate()
		{
			//IL_0138: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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)
			if (((NetworkBehaviour)this).IsServer)
			{
				if (syncPosition && Vector3.Distance(((Component)this).transform.position, _lastPosition) > positionDiffLimit)
				{
					_lastPosition = ((Component)this).transform.position;
					UpdatePositionClientRpc(((Component)this).transform.position);
				}
				if (syncRotation && Quaternion.Angle(Quaternion.Euler(((Component)this).transform.eulerAngles), Quaternion.Euler(_lastRotation)) > rotationDiffLimit)
				{
					_lastRotation = ((Component)this).transform.eulerAngles;
					UpdateRotationClientRpc(((Component)this).transform.eulerAngles);
				}
				if (syncScale && Vector3.Distance(((Component)this).transform.localScale, _lastScale) > scaleDiffLimit)
				{
					_lastScale = ((Component)this).transform.localScale;
					UpdateScaleClientRpc(((Component)this).transform.localScale);
				}
			}
			else
			{
				if (lerpPosition)
				{
					((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, _targetPosition, Time.fixedDeltaTime * positionLerpSpeed);
				}
				if (lerpRotation)
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _targetRotation, Time.fixedDeltaTime * rotationLerpSpeed);
				}
				if (lerpScale)
				{
					((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, _targetScale, Time.fixedDeltaTime * scaleLerpSpeed);
				}
			}
		}

		[ClientRpc]
		public void UpdatePositionClientRpc(Vector3 position)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			if (!((NetworkBehaviour)this).IsServer && syncPosition)
			{
				if (lerpPosition)
				{
					_targetPosition = position;
				}
				else
				{
					((Component)this).transform.position = position;
				}
			}
		}

		[ClientRpc]
		public void UpdateRotationClientRpc(Vector3 rotation)
		{
			//IL_0038: 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_0023: 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)
			if (!((NetworkBehaviour)this).IsServer && syncRotation)
			{
				if (lerpRotation)
				{
					_targetRotation = Quaternion.Euler(rotation);
				}
				else
				{
					((Component)this).transform.rotation = Quaternion.Euler(rotation);
				}
			}
		}

		[ClientRpc]
		public void UpdateScaleClientRpc(Vector3 scale)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			if (!((NetworkBehaviour)this).IsServer && syncScale)
			{
				if (lerpScale)
				{
					_targetScale = scale;
				}
				else
				{
					((Component)this).transform.localScale = scale;
				}
			}
		}
	}
}