Decompiled source of Plushie v1.0.3

LC_RaccoonPlushie.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
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("LC_RaccoonPlushie")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC_RaccoonPlushie")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("76135b93-cb35-4447-9cf9-10c67b57c972")]
[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")]
public class Raccoon : GrabbableObject
{
	private Animator animator;

	public AudioClip[] sounds;

	private AudioSource audio;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		audio = ((Component)this).GetComponent<AudioSource>();
		animator = ((Component)this).GetComponent<Animator>();
	}

	public override void Update()
	{
		((GrabbableObject)this).Update();
		animator.SetBool("IsHeld", base.isHeld);
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		animator.SetTrigger("Squish");
		audio.PlayOneShot(sounds[Random.Range(0, sounds.Length)]);
		RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 5f, 0.4f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
	}
}
[BepInPlugin("Mellowdy.RaccoonPlushie", "RaccoonPlushie", "0.0.1")]
public class RaccoonPlushieMod : BaseUnityPlugin
{
	private const string modGUID = "Mellowdy.RaccoonPlushie";

	private const string modName = "RaccoonPlushie";

	private const string modVersion = "0.0.1";

	private readonly Harmony harmony = new Harmony("Mellowdy.RaccoonPlushie");

	public static ManualLogSource mls;

	private static RaccoonPlushieMod instance;

	public static AssetBundle assets;

	public static string assetName = "raccoon.plush";

	public static string itemName = "RaccoonPlush.asset";

	public static GameObject PlushiePrefab;

	public static int rarity = 30;

	private void Awake()
	{
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
		}
		mls = Logger.CreateLogSource("Mellowdy.RaccoonPlushie");
		harmony.PatchAll();
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, assetName).Replace("\\", "/");
		assets = AssetBundle.LoadFromFile(text);
		Item val = assets.LoadAsset<Item>(itemName);
		val.weight = ((BaseUnityPlugin)this).Config.Bind<float>("Raccoon Properties", "Weight", val.weight, "5 lb = 1.05, 100 lb = 2").Value;
		val.minValue = ((BaseUnityPlugin)this).Config.Bind<int>("Raccoon Properties", "Min Value", val.minValue, "").Value;
		val.maxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Raccoon Properties", "Max Value", val.maxValue, "").Value;
		Raccoon raccoon = val.spawnPrefab.AddComponent<Raccoon>();
		((GrabbableObject)raccoon).grabbable = true;
		((GrabbableObject)raccoon).grabbableToEnemies = true;
		((GrabbableObject)raccoon).useCooldown = 0.25f;
		raccoon.sounds = (AudioClip[])(object)new AudioClip[2]
		{
			assets.LoadAsset<AudioClip>("Squeak1.mp3"),
			assets.LoadAsset<AudioClip>("Squeak2.mp3")
		};
		((GrabbableObject)raccoon).itemProperties = val;
		NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
		LevelTypes[] array = new LevelTypes[8];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		LevelTypes[] array2 = (LevelTypes[])(object)array;
		float[] array3 = new float[8] { 0.2f, 0f, 0f, 0f, 0.1f, 1f, 2f, 2f };
		rarity = ((BaseUnityPlugin)this).Config.Bind<int>("Rarity", "Base Rarity", 10, "Base rarity for the plushie between 1 - 100(for context, on march: bottles / large axel / engine: 80 - 100.gold bar / robot / lazer pointer: 1 - 6)").Value;
		for (int i = 0; i < array2.Length; i++)
		{
			string text2 = ((object)(LevelTypes)(ref array2[i])).ToString().Replace("Level", "");
			array3[i] = ((BaseUnityPlugin)this).Config.Bind<float>("Rarity", text2 ?? "", array3[i], "Rarity multiplier for " + text2).Value;
			Items.RegisterScrap(val, Mathf.FloorToInt((float)rarity * array3[i]), array2[i]);
		}
		Items.RegisterScrap(val, rarity, (LevelTypes)1024);
		mls.LogInfo((object)"RaccoonPlushie has been loaded");
	}
}