Decompiled source of WoolCompany v1.0.2

WoolCompany/WoolCompany.dll

Decompiled 9 months ago
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using UnityEngine;
using WoolCompany.Behaviors;
using WoolCompany.Config;
using WoolCompany.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WoolCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WoolCompany")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0e91d429-b3f7-45e6-b963-da092a45c342")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WoolCompany
{
	[BepInPlugin("Crystal.WoolCompany", "WoolCompany", "1.0.1.0")]
	public class WoolCompanyPlugin : BaseUnityPlugin
	{
		private const string GUID = "Crystal.WoolCompany";

		private const string NAME = "WoolCompany";

		private const string VERSION = "1.0.1.0";

		private readonly Harmony harmony = new Harmony("Crystal.WoolCompany");

		public static WoolCompanyPlugin instance;

		public static ManualLogSource mls;

		internal static AssetBundle bundle;

		public bool useNameGame = true;

		private void Awake()
		{
			instance = this;
			mls = Logger.CreateLogSource("Crystal.WoolCompany");
			mls.LogInfo((object)"Loading WoolCompany..");
			ConfigSettings.BindConfigSettings();
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "woolcompany");
			bundle = AssetBundle.LoadFromFile(text);
			Item val = bundle.LoadAsset<Item>("Assets/Prefabs/CandiceItem.asset");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load item from asset bundle.");
				return;
			}
			DamagePlayerItem damagePlayerItem = val.spawnPrefab.AddComponent<DamagePlayerItem>();
			((GrabbableObject)damagePlayerItem).grabbable = true;
			((GrabbableObject)damagePlayerItem).grabbableToEnemies = true;
			((GrabbableObject)damagePlayerItem).itemProperties = val;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterScrap(val, 1000, (LevelTypes)(-1));
			TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
			if ((Object)(object)val2 == (Object)null)
			{
				mls.LogError((object)"Failed to create TerminalNode.");
				return;
			}
			val2.clearPreviousText = true;
			val2.displayText = "This is info about Candice\n\n";
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, 0);
			Items.UpdateShopItemPrice(val, 30);
			mls.LogInfo((object)"Loading WoolCompany Phase 2..");
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(CompanyMoodPatch));
			harmony.PatchAll(typeof(SpringManPatch));
			harmony.PatchAll(typeof(StunGrenadePatch));
			harmony.PatchAll(typeof(PullAlarmCordPatch));
			harmony.PatchAll(typeof(SprayPaintItemPatch));
			mls.LogInfo((object)"Loaded WoolCompany Successfully");
		}
	}
}
namespace WoolCompany.Patches
{
	[HarmonyPatch(typeof(SprayPaintItem))]
	internal class SprayPaintItemPatch
	{
		[HarmonyPatch("__initializeVariables")]
		[HarmonyPostfix]
		private static void SprayPaintItemPatchFunc(SprayPaintItem __instance)
		{
			__instance.sprayNeedsShakingSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/SprayNeedsShaking.ogg");
			__instance.spraySFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/SpraySprayCan.ogg");
		}
	}
	[HarmonyPatch(typeof(ShipAlarmCord))]
	internal class PullAlarmCordPatch
	{
		[HarmonyPatch("__initializeVariables")]
		[HarmonyPostfix]
		private static void PullAlarmCordPatchFunc(ShipAlarmCord __instance)
		{
			__instance.cordPullSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/PullLever2.ogg");
		}
	}
	[HarmonyPatch(typeof(StunGrenadeItem))]
	internal class StunGrenadePatch
	{
		[HarmonyPatch("__initializeVariables")]
		[HarmonyPostfix]
		private static void StunGrenadePatchFunc(StunGrenadeItem __instance)
		{
			__instance.pullPinSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/PullLever2.ogg");
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class SpringManPatch
	{
		[HarmonyPatch("__initializeVariables")]
		[HarmonyPostfix]
		private static void SpringManPatchFunc(SpringManAI __instance)
		{
			AudioClip[] springNoises = __instance.springNoises;
			WoolCompanyPlugin.mls.LogInfo((object)"SpringManInit!");
			AudioClip[] array = springNoises;
			foreach (AudioClip val in array)
			{
				WoolCompanyPlugin.mls.LogInfo((object)("Audio Clip Name: " + ((object)val).ToString() + " - " + ((Object)val).name + "\n"));
			}
			__instance.springNoises[0] = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Coilhead/Spring1.ogg");
			__instance.springNoises[1] = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Coilhead/Spring2.ogg");
			__instance.springNoises[2] = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Coilhead/Spring3.ogg");
			__instance.springNoises[3] = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Coilhead/SpringWobble1.ogg");
			__instance.springNoises[4] = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Coilhead/SpringWobble2.ogg");
		}
	}
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class CompanyMoodPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void SetCompanySoundPatch(DepositItemsDesk __instance)
		{
			if (WoolCompanyPlugin.instance.useNameGame)
			{
				__instance.currentMood.behindWallSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/name_game.ogg");
			}
			CollectionExtensions.AddItem<AudioClip>((IEnumerable<AudioClip>)__instance.currentMood.attackSFX, WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/TentaclesAttack.ogg"));
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			__instance.suckedIntoSpaceSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/SuckedIntoSpace.ogg");
			__instance.firedVoiceSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/FiredVoiceline.ogg");
			__instance.firedVoiceSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/FiredVoiceline.ogg");
			CollectionExtensions.AddItem<AudioClip>((IEnumerable<AudioClip>)__instance.shipCreakSFX, WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/baaa.ogg"));
			__instance.HUDSystemAlertSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Candice/oh-no.ogg");
			__instance.fallDamageSFX = WoolCompanyPlugin.bundle.LoadAsset<AudioClip>("Assets/AudoClip/Candice/whooaa.ogg");
		}
	}
}
namespace WoolCompany.Config
{
	public static class ConfigSettings
	{
		public static ConfigEntry<bool> name_game;

		public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>();

		public static void BindConfigSettings()
		{
			name_game = AddConfigEntry("WoolCompany Audio", "Enable Name-Game", defaultValue: true, "If true, will enable the \"Name game\" music at the company. Played by the one and only Jeb.");
			((BaseUnityPlugin)WoolCompanyPlugin.instance).Config.Save();
			UseSettings();
		}

		public static void UseSettings()
		{
			WoolCompanyPlugin.instance.useNameGame = name_game.Value;
		}

		public static ConfigEntry<T> AddConfigEntry<T>(string section, string name, T defaultValue, string description)
		{
			ConfigEntry<T> val = ((BaseUnityPlugin)WoolCompanyPlugin.instance).Config.Bind<T>(section, name, defaultValue, description);
			currentConfigEntries.Add(((ConfigEntryBase)val).Definition.Key, (ConfigEntryBase)(object)val);
			return val;
		}
	}
}
namespace WoolCompany.Behaviors
{
	internal class LaunchPlayerItem : PhysicsProp
	{
		public RaycastHit hitLocation;

		private ManualLogSource Logger;

		public override void DiscardItem()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Vector3 throwDestination = GetThrowDestination();
			ManualLogSource logger = Logger;
			Vector3 val = throwDestination;
			logger.LogInfo((object)("Throwing Item1: " + ((object)(Vector3)(ref val)).ToString()));
			((GrabbableObject)this).DiscardItem();
			ManualLogSource logger2 = Logger;
			val = throwDestination;
			logger2.LogInfo((object)("Throwing Item: " + ((object)(Vector3)(ref val)).ToString()));
		}

		public Vector3 GetThrowDestination()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_00b6: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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)
			Vector3 position = ((Component)this).transform.position;
			Debug.DrawRay(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward, Color.yellow, 15f);
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward);
			position = ((!Physics.Raycast(val, ref hitLocation, 12f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) ? ((Ray)(ref val)).GetPoint(10f) : ((Ray)(ref val)).GetPoint(((RaycastHit)(ref hitLocation)).distance - 0.05f));
			Debug.DrawRay(position, Vector3.down, Color.blue, 15f);
			((Ray)(ref val))..ctor(position, Vector3.down);
			if (Physics.Raycast(val, ref hitLocation, 30f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				return ((RaycastHit)(ref hitLocation)).point + Vector3.up * 0.05f;
			}
			return ((Ray)(ref val)).GetPoint(30f);
		}
	}
	internal class DamagePlayerItem : PhysicsProp
	{
		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_002e: 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)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					((GrabbableObject)this).playerHeldBy.DamagePlayer(5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
				else
				{
					Debug.Log((object)"Could not damage player!");
				}
			}
		}
	}
}