Decompiled source of Snowbound v1.1.1

Snowbound/Snowbound.dll

Decompiled 5 days 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
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("Snowbound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+722e96ad088f5c21a61f89e6bc14e3219edf7ab3")]
[assembly: AssemblyProduct("Snowbound")]
[assembly: AssemblyTitle("Snowbound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Snowbound
{
	[BepInPlugin("Snowlance.Snowbound", "Snowbound", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "Snowlance.Snowbound";

		public const string modName = "Snowbound";

		public const string modVersion = "1.1.1";

		public static Plugin PluginInstance;

		public static ManualLogSource LoggerInstance;

		public static AssetBundle ModAssets;

		public static ConfigEntry<bool> configEnableGlitchStatue;

		public static ConfigEntry<bool> configEnableDiceMimicPlush;

		public static ConfigEntry<bool> configEnableFuMolaniePlush;

		public static ConfigEntry<bool> configEnableSCP956;

		public static ConfigEntry<bool> configEnableNuke;

		public static ConfigEntry<bool> configEnableSCP999Plush;

		public static ConfigEntry<bool> configEnableFunoPlush;

		public static ConfigEntry<int> configSCP956MinCandy;

		public static ConfigEntry<int> configSCP956MaxCandy;

		public static ConfigEntry<float> configSCP999PlushHealInterval;

		public static ConfigEntry<int> configSCP999PlushHealAmount;

		private readonly Harmony harmony = new Harmony("Snowlance.Snowbound");

		public void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
			harmony.PatchAll();
			configEnableGlitchStatue = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable Glitch Statue", true, "Enable or disable the Glitch Statue.");
			configEnableDiceMimicPlush = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable Dice Mimic Plush", true, "Enable or disable the Dice Mimic Plush.");
			configEnableFuMolaniePlush = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable Fu Molanie Plush", true, "Enable or disable the Fu Molanie Plush.");
			configEnableSCP956 = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable SCP-956", true, "Enable or disable SCP-956.");
			configEnableNuke = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable Nuke", true, "Enable or disable the Nuke.");
			configEnableSCP999Plush = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable SCP-999 Plush", true, "Enable or disable SCP-999 Plush.");
			configEnableFunoPlush = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", "Enable Funo Plush", true, "Enable or disable Funo Plush.");
			configSCP956MinCandy = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-956", "Min Candy", 5, "The min amount of candy to spawn when SCP-956 gets destroyed.");
			configSCP956MaxCandy = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-956", "Max Candy", 15, "The max amount of candy to spawn when SCP-956 gets destroyed.");
			configSCP999PlushHealInterval = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-999 Plush", "Heal Interval", 5f, "The amount of time between heals.");
			configSCP999PlushHealAmount = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-999 Plush", "Heal Amount", 5, "The amount of health healed per x(Heal Interval) seconds.");
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "snowbound_assets"));
			List<string> list = new List<string>();
			list.Add("Valuables - Generic");
			RegisterValuable("Assets/ModAssets/Snowbound/GlitchStatue/GlitchStatue.prefab", list, configEnableGlitchStatue.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/DiceMimicPlush/DiceMimic.prefab", list, configEnableDiceMimicPlush.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/FuMolaniePlush/FuMolaniePlush.prefab", list, configEnableFuMolaniePlush.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/SCP999Plush/SCP999Plush.prefab", list, configEnableSCP999Plush.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/FunoPlush/FunoPlush.prefab", list, configEnableFunoPlush.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/SCP956/SCP956.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyBlue.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyGreen.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyPink.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyPurple.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyRainbow.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyRed.prefab", list, configEnableSCP956.Value);
			RegisterValuable("Assets/ModAssets/Snowbound/Candy/CandyYellow.prefab", list, configEnableSCP956.Value);
			List<string> list2 = new List<string>();
			list2.Add("Valuables - Arctic");
			RegisterValuable("Assets/ModAssets/Snowbound/Nuke/Nuke.prefab", list2, configEnableNuke.Value);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.Snowbound v1.1.1 has loaded!");
		}

		public void RegisterValuable(string path, List<string> levelsList, bool enable = true)
		{
			if (enable)
			{
				GameObject val = ModAssets.LoadAsset<GameObject>(path);
				Valuables.RegisterValuable(val, levelsList);
			}
		}

		public void RegisterItem(string path, bool enable = true)
		{
			if (enable)
			{
				ItemContent val = ModAssets.LoadAsset<ItemContent>(path);
				Items.RegisterItem(val.Prefab.item);
			}
		}
	}
}
namespace Snowbound.Valuables
{
	internal class GlitchStatueBehavior : MonoBehaviour
	{
		public Material BaldMaterial;

		public SkinnedMeshRenderer renderer;

		public void Baldify()
		{
			((Renderer)renderer).material = BaldMaterial;
		}
	}
	internal class NukeBehavior : MonoBehaviour
	{
		private static ManualLogSource logger = Plugin.LoggerInstance;

		public ParticleScriptExplosion particleScriptExplosion;

		public void Explode()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"Explode() called");
			particleScriptExplosion.Spawn(((Component)this).transform.position, 100f, 500, 500, 100f, false, false, 10f);
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				player.playerHealth.health = 0;
				player.PlayerDeath(-1);
			}
		}
	}
	internal class SCP956Behavior : MonoBehaviour
	{
		public ValuableObject[] Candies;

		private int minCandy = 5;

		private int maxCandy = 15;

		public void Start()
		{
			minCandy = Plugin.configSCP956MinCandy.Value;
			maxCandy = Plugin.configSCP956MaxCandy.Value;
		}

		public void SpawnCandy()
		{
			//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)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				int num = Random.Range(minCandy, maxCandy);
				for (int i = 0; i < num; i++)
				{
					int num2 = Random.Range(0, Candies.Length);
					Valuables.SpawnValuable(Candies[num2], ((Component)this).transform.position, Quaternion.identity);
				}
			}
		}
	}
	internal class SCP999PlushBehavior : MonoBehaviour
	{
		public AudioSource ItemAudio;

		public AudioClip[] HugSFX;

		public PhysGrabObject grabObject;

		public Animator ItemAnimator;

		private float timeSinceHeal;

		private float healInterval = 5f;

		private int healAmount = 5;

		public void Start()
		{
			healInterval = Plugin.configSCP999PlushHealInterval.Value;
			healAmount = Plugin.configSCP999PlushHealAmount.Value;
		}

		public void Update()
		{
			if (grabObject.playerGrabbing.Count > 0)
			{
				ItemAnimator.SetBool("hug", true);
				timeSinceHeal += Time.deltaTime;
				if (!(timeSinceHeal > healInterval))
				{
					return;
				}
				timeSinceHeal = 0f;
				foreach (PhysGrabber item in grabObject.playerGrabbing)
				{
					item.playerAvatar.playerHealth.Heal(healAmount, true);
				}
				int num = Random.Range(0, HugSFX.Length);
				ItemAudio.PlayOneShot(HugSFX[num]);
			}
			else
			{
				ItemAnimator.SetBool("hug", false);
			}
		}
	}
}