Decompiled source of Zevent2024scraps v1.1.2

BepInEx/plugins/ZEvent2024ScrapsMod.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using LobbyCompatibility.Attributes;
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("ZEvent2024ScrapsMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ZEvent2024ScrapsMod")]
[assembly: AssemblyTitle("ZEvent2024ScrapsMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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.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;
		}
	}
	[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;
		}
	}
}
internal class Megaphone : NoisemakerProp
{
	[Space(3f)]
	public string[] hurtingPlayerNames;

	public int[] killChance;

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		((NoisemakerProp)this).ItemActivate(used, buttonDown);
		if (hurtingPlayerNames.Contains(((GrabbableObject)this).playerHeldBy.playerUsername) && Random.Range(0f, 100f) <= (float)killChance[Array.IndexOf(hurtingPlayerNames, ((GrabbableObject)this).playerHeldBy.playerUsername)])
		{
			((GrabbableObject)this).playerHeldBy.DamagePlayer(100, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
		}
	}
}
public class PSonic : PhysicsProp
{
	public AudioSource prefabAudioSource;

	public AssetBundle bundle;

	public override void GrabItem()
	{
		((GrabbableObject)this).GrabItem();
		if (((GrabbableObject)this).playerHeldBy.playerUsername == "JDG")
		{
			AudioClip val = bundle.LoadAsset<AudioClip>("Assets/ZEvent Scraps/Sounds/JDGTheme.mp3");
			prefabAudioSource.PlayOneShot(val);
		}
	}

	public override void DiscardItem()
	{
		if (((GrabbableObject)this).playerHeldBy.playerUsername == "JDG")
		{
			prefabAudioSource.Stop();
		}
		((GrabbableObject)this).DiscardItem();
	}
}
namespace ZEvent2024ScrapsMod
{
	[BepInPlugin("ZEvent2024ScrapsMod", "ZEvent2024ScrapsMod", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class ZEvent2024ScrapsMod : BaseUnityPlugin
	{
		private Dictionary<string, Dictionary<LevelTypes, int>> ItemsScrap = new Dictionary<string, Dictionary<LevelTypes, int>>
		{
			{
				"Pregnant Sonic Painting",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"Soumikachu Painting",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"Flangle Painting",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"Bagz Painting",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"Soumikachu",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"Tapis Champi",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"Megaphone",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"EmptyJuiceBarrell",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						40
					},
					{
						(LevelTypes)1024,
						40
					}
				}
			},
			{
				"FullJuiceBarrell",
				new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)(-1),
						25
					},
					{
						(LevelTypes)1024,
						25
					}
				}
			}
		};

		private Dictionary<string, int> ItemsShop = new Dictionary<string, int>();

		private string assetbundlename = "zevent2024modasset";

		private string assetspath = "Assets/ZEvent Scraps/Items/";

		private string soundspath = "Assets/ZEvent Scraps/Sounds/";

		private AssetBundle bundle;

		public static ZEvent2024ScrapsMod Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetbundlename);
			bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)bundle == (Object)null)
			{
				Logger.LogError((object)("Failed to load asset bundle: " + text));
				return;
			}
			Logger.LogInfo((object)"Loading Scrap items from asset bundle : ");
			if (ItemsScrap.Count == 0)
			{
				Logger.LogInfo((object)"\tNo Scrap items found.");
			}
			else
			{
				foreach (KeyValuePair<string, Dictionary<LevelTypes, int>> item in ItemsScrap)
				{
					Item val = bundle.LoadAsset<Item>(assetspath + item.Key + ".asset");
					if ((Object)(object)val == (Object)null)
					{
						Logger.LogError((object)("\tFailed to load item: " + item.Key));
						continue;
					}
					if (item.Key == "Megaphone")
					{
						RegisterMegaphoneScript(val);
					}
					if (item.Key == "Pregnant Sonic Painting")
					{
						RegisterPSonicScript(val, bundle);
					}
					RegisterScrapItem(val, item.Value);
				}
			}
			Logger.LogInfo((object)"Loading Shop items from asset bundle : ");
			if (ItemsShop.Count == 0)
			{
				Logger.LogInfo((object)"\t No shop items found.");
			}
			else
			{
				foreach (KeyValuePair<string, int> item2 in ItemsShop)
				{
					Item val2 = bundle.LoadAsset<Item>(assetspath + item2.Key + ".asset");
					if ((Object)(object)val2 == (Object)null)
					{
						Logger.LogError((object)("\tFailed to load item: " + item2.Key));
					}
					else
					{
						RegisterShopItem(val2, item2.Value);
					}
				}
			}
			Logger.LogInfo((object)"ZEvent2024ScrapsMod v1.0.0 has loaded!");
		}

		private void RegisterScrapItem(Item item, Dictionary<LevelTypes, int> rarityDictionary)
		{
			Utilities.FixMixerGroups(item.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
			Items.RegisterScrap(item, rarityDictionary, (Dictionary<string, int>)null);
			Logger.LogInfo((object)("\tLoaded scrap item : " + item.itemName));
		}

		private void RegisterShopItem(Item item, int price)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			val.displayText = "Placehodler : Here should be informations about " + ((Object)item).name + " \n\n";
			Utilities.FixMixerGroups(item.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
			Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, val, price);
			Logger.LogInfo((object)("\tLoaded shop item : " + item.itemName));
		}

		private void RegisterMegaphoneScript(Item item)
		{
			Megaphone megaphone = item.spawnPrefab.AddComponent<Megaphone>();
			((GrabbableObject)megaphone).grabbable = true;
			((GrabbableObject)megaphone).isInFactory = true;
			((GrabbableObject)megaphone).itemProperties = item;
			((GrabbableObject)megaphone).useCooldown = 2f;
			((NoisemakerProp)megaphone).noiseAudio = item.spawnPrefab.GetComponent<AudioSource>();
			((NoisemakerProp)megaphone).noiseAudioFar = item.spawnPrefab.GetComponentsInChildren<AudioSource>()[1];
			((NoisemakerProp)megaphone).noiseSFX = (AudioClip[])(object)new AudioClip[1] { bundle.LoadAsset<AudioClip>(soundspath + "Megaphone.mp3") };
			((NoisemakerProp)megaphone).noiseSFXFar = (AudioClip[])(object)new AudioClip[1] { bundle.LoadAsset<AudioClip>(soundspath + "MegaphoneFar.mp3") };
			((NoisemakerProp)megaphone).noiseRange = 900f;
			((NoisemakerProp)megaphone).maxLoudness = 7f;
			((NoisemakerProp)megaphone).minLoudness = 6f;
			((NoisemakerProp)megaphone).minPitch = 0.8f;
			((NoisemakerProp)megaphone).maxPitch = 1f;
			megaphone.hurtingPlayerNames = new string[5] { "Pikach", "Parks", "ZeratoR", "Mynthos", "Zhir" };
			megaphone.killChance = new int[5] { 25, 100, 7, 7, 7 };
		}

		private void RegisterPSonicScript(Item item, AssetBundle bundle)
		{
			PSonic pSonic = item.spawnPrefab.AddComponent<PSonic>();
			((GrabbableObject)pSonic).grabbable = true;
			((GrabbableObject)pSonic).isInFactory = true;
			((GrabbableObject)pSonic).itemProperties = item;
			((GrabbableObject)pSonic).grabbableToEnemies = true;
			pSonic.bundle = bundle;
			pSonic.prefabAudioSource = item.spawnPrefab.GetComponent<AudioSource>();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ZEvent2024ScrapsMod";

		public const string PLUGIN_NAME = "ZEvent2024ScrapsMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}