Decompiled source of AHIT Plushies v0.5.5

BepInEx/plugins/AHIT Plushies.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AHIT_Plushies.Config;
using BepInEx;
using BepInEx.Configuration;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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("AHIT Plushies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a32cc2fe848e84ea4adf71356fdbd36052aee4b9")]
[assembly: AssemblyProduct("AHIT Plushies")]
[assembly: AssemblyTitle("AHIT Plushies")]
[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 AHIT_Plushies
{
	[BepInPlugin("Doomnik.AHITPlushies", "AHIT Plushies", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private const string ModGuid = "Doomnik.AHITPlushies";

		private const string ModName = "AHIT Plushies";

		private const string ModVersion = "1.0.0.0";

		private GeneralSettings _settings;

		private PlushieSpawnRates _plushieRates;

		private PlushieSellValues _plushieValues;

		private WeaponSettings _weaponSettings;

		private List<Item> _items;

		private readonly List<string> _weaponsList = new List<string>(3) { "Umbrella", "BaseballBat", "TimePiece" };

		private void Awake()
		{
			_settings = new GeneralSettings(((BaseUnityPlugin)this).Config);
			_plushieRates = new PlushieSpawnRates(((BaseUnityPlugin)this).Config);
			_plushieValues = new PlushieSellValues(((BaseUnityPlugin)this).Config);
			_weaponSettings = new WeaponSettings(((BaseUnityPlugin)this).Config);
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, "ahitplushscrap");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			_items = new List<Item>(17)
			{
				val.LoadAsset<Item>("Assets/AHIT Plushies/HatKidPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/ConductorPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/MustacheGirlPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/CAWPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/SnatcherPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/Umbrella.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/BaseballBat.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/BowKidPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/DJGroovesPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/EmpressPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/SealPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/FishDudePlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/FireSpiritPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/MadCrowPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/MafiaDudePlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/GrandkidPlushie.asset"),
				val.LoadAsset<Item>("Assets/AHIT Plushies/TimePiece.asset")
			};
			foreach (Item item in _items)
			{
				LoadConfigValues(item);
				NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
				Utilities.FixMixerGroups(item.spawnPrefab);
				item.spawnPrefab.GetComponent<GrabbableObject>().customGrabTooltip = "Grab " + item.itemName;
				if (((Object)item).name == "TimePiece")
				{
					item.spawnPrefab.AddComponent<TimePiece>();
				}
				if (_weaponsList.Contains(((Object)item).name))
				{
					SetupWeapon(item);
					Items.RegisterScrap(item, _weaponSettings.GetValue(((Object)item).name + "SpawnRate").Value, (LevelTypes)(-1));
					continue;
				}
				Items.RegisterScrap(item, _plushieRates.SpawnRateExperimentation.Value, (LevelTypes)4);
				Items.RegisterScrap(item, _plushieRates.SpawnRateAssurance.Value, (LevelTypes)8);
				Items.RegisterScrap(item, _plushieRates.SpawnRateVow.Value, (LevelTypes)16);
				Items.RegisterScrap(item, _plushieRates.SpawnRateOffense.Value, (LevelTypes)32);
				Items.RegisterScrap(item, _plushieRates.SpawnRateMarch.Value, (LevelTypes)64);
				Items.RegisterScrap(item, _plushieRates.SpawnRateRend.Value, (LevelTypes)128);
				Items.RegisterScrap(item, _plushieRates.SpawnRateDine.Value, (LevelTypes)256);
				Items.RegisterScrap(item, _plushieRates.SpawnRateTitan.Value, (LevelTypes)512);
				Items.RegisterScrap(item, _plushieRates.SpawnRateOther.Value, (LevelTypes)(-1));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"AHIT Plushies Patched Successfully");
		}

		private void SetupWeapon(Item item)
		{
			Shovel component = item.spawnPrefab.GetComponent<Shovel>();
			component.shovelHitForce = _weaponSettings.GetValue(((Object)item).name + "Damage").Value;
		}

		private void LoadConfigValues(Item item)
		{
			if (!_weaponsList.Contains(((Object)item).name))
			{
				item.requiresBattery = !item.twoHanded && _settings.PlushiesRequireBattery.Value;
				if (item.requiresBattery && _settings.PlushiesSpawnWithRandomCharge.Value)
				{
					item.spawnPrefab.GetComponent<GrabbableObject>().insertedBattery.charge = (float)Random.Range(_settings.PlushiesMinimumChargeOnSpawn.Value, 100) / 100f;
				}
			}
			item.minValue = (int)((double)_plushieValues.GetSellValue(((Object)item).name + "MinValue").Value * 2.5);
			item.maxValue = (int)((double)_plushieValues.GetSellValue(((Object)item).name + "MaxValue").Value * 2.5);
		}
	}
	public class TimePiece : MonoBehaviour
	{
		private Animator _animator;

		private Shovel _shovel;

		private void Start()
		{
			_animator = ((Component)this).GetComponentInChildren<Animator>();
			_shovel = ((Component)this).GetComponent<Shovel>();
		}

		private void LateUpdate()
		{
			bool flag = ((GrabbableObject)_shovel).isHeld || ((GrabbableObject)_shovel).isHeldByEnemy;
			_animator.SetBool("IsHeld", flag);
		}
	}
}
namespace AHIT_Plushies.Config
{
	public abstract class BaseConfig
	{
		internal abstract void SetBindings(ConfigFile cfg);

		internal virtual ConfigEntry<T> Bind<T>(ConfigFile cfg, string section, string key, T defaultValue, string description = "")
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			return cfg.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)((typeof(T) != typeof(bool)) ? new AcceptableValueRange<int>(0, 100) : null), Array.Empty<object>()));
		}
	}
	public class GeneralSettings : BaseConfig
	{
		public ConfigEntry<bool> PlushiesRequireBattery;

		public ConfigEntry<bool> PlushiesSpawnWithRandomCharge;

		public ConfigEntry<int> PlushiesMinimumChargeOnSpawn;

		public GeneralSettings(ConfigFile cfg)
		{
			SetBindings(cfg);
		}

		internal sealed override void SetBindings(ConfigFile cfg)
		{
			PlushiesRequireBattery = Bind(cfg, "General", "Should one handed plushies require battery power", defaultValue: true);
			PlushiesSpawnWithRandomCharge = Bind(cfg, "General", "Should plushies spawn with random battery charge", defaultValue: true);
			PlushiesMinimumChargeOnSpawn = Bind(cfg, "General", "Minimum random spawn charge", 20);
		}
	}
	public class PlushieSellValues : BaseConfig
	{
		private readonly Dictionary<string, ConfigEntry<int>> _sellValueList = new Dictionary<string, ConfigEntry<int>>();

		private const string SectionPlushies = "Plushie Sell Prices";

		private const string SectionBigPlushies = "Big Plushie Sell Prices";

		private const string SectionSmallPlushies = "Small Plushie Sell Prices";

		private const string SectionWeapons = "Weapon Sell Prices";

		private const int DefaultMin = 40;

		private const int DefaultMax = 80;

		private const int DefaultBigMin = 60;

		private const int DefaultBigMax = 110;

		private const int DefaultSmallMin = 30;

		private const int DefaultSmallMax = 70;

		public PlushieSellValues(ConfigFile cfg)
		{
			SetBindings(cfg);
		}

		internal sealed override void SetBindings(ConfigFile cfg)
		{
			_sellValueList["BowKidPlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "Bow Kid Min Value", 40);
			_sellValueList["BowKidPlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "Bow Kid Max Value", 80);
			_sellValueList["CAWPlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "CAW Agent Min Value", 40);
			_sellValueList["CAWPlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "CAW Agent Max Value", 80);
			_sellValueList["ConductorPlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "Conductor Min Value", 40);
			_sellValueList["ConductorPlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "Conductor Max Value", 80);
			_sellValueList["FireSpiritPlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "Fire Spirit Min Value", 40);
			_sellValueList["FireSpiritPlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "Fire Spirit Max Value", 80);
			_sellValueList["FishDudePlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "Fish Dude Min Value", 40);
			_sellValueList["FishDudePlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "Fish Dude Max Value", 80);
			_sellValueList["HatKidPlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "Hat Kid Min Value", 40);
			_sellValueList["HatKidPlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "Hat Kid Max Value", 80);
			_sellValueList["MustacheGirlPlushieMinValue"] = Bind(cfg, "Plushie Sell Prices", "Mustache Girl Min Value", 40);
			_sellValueList["MustacheGirlPlushieMaxValue"] = Bind(cfg, "Plushie Sell Prices", "Mustache Girl Max Value", 80);
			_sellValueList["GrandkidPlushieMinValue"] = Bind(cfg, "Small Plushie Sell Prices", "Grandkid Min Value", 30);
			_sellValueList["GrandkidPlushieMaxValue"] = Bind(cfg, "Small Plushie Sell Prices", "Grandkid Max Value", 70);
			_sellValueList["MadCrowPlushieMinValue"] = Bind(cfg, "Small Plushie Sell Prices", "Mad Crow Min Value", 30);
			_sellValueList["MadCrowPlushieMaxValue"] = Bind(cfg, "Small Plushie Sell Prices", "Mad Crow Max Value", 70);
			_sellValueList["SealPlushieMinValue"] = Bind(cfg, "Small Plushie Sell Prices", "Seal Min Value", 30);
			_sellValueList["SealPlushieMaxValue"] = Bind(cfg, "Small Plushie Sell Prices", "Seal Max Value", 70);
			_sellValueList["DJGroovesPlushieMinValue"] = Bind(cfg, "Big Plushie Sell Prices", "DJ Grooves Min Value", 60);
			_sellValueList["DJGroovesPlushieMaxValue"] = Bind(cfg, "Big Plushie Sell Prices", "DJ Grooves Max Value", 110);
			_sellValueList["EmpressPlushieMinValue"] = Bind(cfg, "Big Plushie Sell Prices", "Empress Min Value", 60);
			_sellValueList["EmpressPlushieMaxValue"] = Bind(cfg, "Big Plushie Sell Prices", "Empress Max Value", 110);
			_sellValueList["MafiaDudePlushieMinValue"] = Bind(cfg, "Big Plushie Sell Prices", "Mafia Dude Min Value", 60);
			_sellValueList["MafiaDudePlushieMaxValue"] = Bind(cfg, "Big Plushie Sell Prices", "Mafia Dude Max Value", 110);
			_sellValueList["SnatcherPlushieMinValue"] = Bind(cfg, "Big Plushie Sell Prices", "Snatcher Min Value", 60);
			_sellValueList["SnatcherPlushieMaxValue"] = Bind(cfg, "Big Plushie Sell Prices", "Snatcher Max Value", 110);
			_sellValueList["UmbrellaMinValue"] = Bind(cfg, "Weapon Sell Prices", "Umbrella Min Value", 40);
			_sellValueList["UmbrellaMaxValue"] = Bind(cfg, "Weapon Sell Prices", "Umbrella Max Value", 80);
			_sellValueList["BaseballBatMinValue"] = Bind(cfg, "Weapon Sell Prices", "Baseball Bat Min Value", 40);
			_sellValueList["BaseballBatMaxValue"] = Bind(cfg, "Weapon Sell Prices", "Baseball Bat Max Value", 80);
			_sellValueList["TimePieceMinValue"] = Bind(cfg, "Weapon Sell Prices", "Time Piece Bat Min Value", 60);
			_sellValueList["TimePieceMaxValue"] = Bind(cfg, "Weapon Sell Prices", "Time Piece Bat Max Value", 110);
		}

		internal ConfigEntry<int> GetSellValue(string propertyName)
		{
			return _sellValueList.GetValueOrDefault(propertyName);
		}

		internal override ConfigEntry<T> Bind<T>(ConfigFile cfg, string section, string key, T defaultValue, string description = "")
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			bool flag = key.Contains("Min");
			return cfg.Bind<T>(section, key, defaultValue, new ConfigDescription("Set the " + (flag ? "minimum" : "maximum") + " sell value of this plushie.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
		}
	}
	public class PlushieSpawnRates : BaseConfig
	{
		public ConfigEntry<int> SpawnRateExperimentation;

		public ConfigEntry<int> SpawnRateAssurance;

		public ConfigEntry<int> SpawnRateVow;

		public ConfigEntry<int> SpawnRateOffense;

		public ConfigEntry<int> SpawnRateMarch;

		public ConfigEntry<int> SpawnRateRend;

		public ConfigEntry<int> SpawnRateDine;

		public ConfigEntry<int> SpawnRateTitan;

		public ConfigEntry<int> SpawnRateOther;

		public PlushieSpawnRates(ConfigFile cfg)
		{
			SetBindings(cfg);
		}

		internal sealed override void SetBindings(ConfigFile cfg)
		{
			SpawnRateExperimentation = Bind(cfg, "Spawn Rates", "Experimentation", 10, "Set the spawn rate on this moon");
			SpawnRateAssurance = Bind(cfg, "Spawn Rates", "Assurance", 10, "Set the spawn rate on this moon");
			SpawnRateVow = Bind(cfg, "Spawn Rates", "Vow", 10, "Set the spawn rate on this moon");
			SpawnRateOffense = Bind(cfg, "Spawn Rates", "Offense", 20, "Set the spawn rate on this moon");
			SpawnRateMarch = Bind(cfg, "Spawn Rates", "March", 20, "Set the spawn rate on this moon");
			SpawnRateRend = Bind(cfg, "Spawn Rates", "Rend", 30, "Set the spawn rate on this moon");
			SpawnRateDine = Bind(cfg, "Spawn Rates", "Dine", 30, "Set the spawn rate on this moon");
			SpawnRateTitan = Bind(cfg, "Spawn Rates", "Titan", 30, "Set the spawn rate on this moon");
			SpawnRateOther = Bind(cfg, "Spawn Rates", "Other Moons", 30, "Set the spawn rate on any other moon");
		}
	}
	public class WeaponSettings : BaseConfig
	{
		private readonly Dictionary<string, ConfigEntry<int>> _weaponsList = new Dictionary<string, ConfigEntry<int>>();

		public WeaponSettings(ConfigFile cfg)
		{
			SetBindings(cfg);
		}

		internal sealed override void SetBindings(ConfigFile cfg)
		{
			_weaponsList["UmbrellaDamage"] = Bind(cfg, "Weapon Settings", "Umbrella Damage", 1, "Set the damage value of this weapon");
			_weaponsList["BaseballBatDamage"] = Bind(cfg, "Weapon Settings", "Baseball Bat Damage", 1, "Set the damage value of this weapon");
			_weaponsList["TimePieceDamage"] = Bind(cfg, "Weapon Settings", "Time Piece Damage", 2, "Set the damage value of this weapon");
			_weaponsList["UmbrellaSpawnRate"] = Bind(cfg, "Weapon Settings", "Umbrella Spawn Rate", 15, "Set the spawn rate of this weapon");
			_weaponsList["BaseballBatSpawnRate"] = Bind(cfg, "Weapon Settings", "Baseball Bat Spawn Rate", 15, "Set the spawn rate of this weapon");
			_weaponsList["TimePieceSpawnRate"] = Bind(cfg, "Weapon Settings", "Time Piece Spawn Rate", 10, "Set the spawn rate of this weapon");
		}

		internal ConfigEntry<int> GetValue(string weapon)
		{
			return _weaponsList.GetValueOrDefault(weapon);
		}
	}
}