Decompiled source of BlissScrap v0.5.1

BlissScrap.dll

Decompiled 6 months ago
using System;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
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("BlissScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BlissScrap")]
[assembly: AssemblyTitle("BlissScrap")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BlissScrap
{
	public class Config
	{
		public static ConfigEntry<int> vai5000SpawnWeight;

		public static ConfigEntry<int> eggSpraySpawnWeight;

		public static ConfigEntry<int> blissySpawnWeight;

		public static ConfigEntry<int> alemSpawnWeight;

		public static ConfigEntry<int> gbaSpawnWeight;

		public static ConfigEntry<int> swallowbugSpawnWeight;

		public static ConfigEntry<int> tennisBallSpawnWeight;

		public static ConfigFile VolumeConfig;

		public static void Load()
		{
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			vai5000SpawnWeight = Plugin.config.Bind<int>("Scrap", "vai5000", 10, "How much does vai5000 spawn, higher = more common");
			eggSpraySpawnWeight = Plugin.config.Bind<int>("Scrap", "eggspray", 10, "How much does egg spray spawn, higher = more common");
			blissySpawnWeight = Plugin.config.Bind<int>("Scrap", "blissy", 10, "How much does blissy spawn higher = more common");
			alemSpawnWeight = Plugin.config.Bind<int>("Scrap", "alem", 10, "How much does alem spawn higher = more common");
			gbaSpawnWeight = Plugin.config.Bind<int>("Scrap", "gba", 10, "How much does GBA spawn higher = more common");
			swallowbugSpawnWeight = Plugin.config.Bind<int>("Scrap", "swallowbug", 10, "How much does swallowbug spawn higher = more common");
			tennisBallSpawnWeight = Plugin.config.Bind<int>("Scrap", "tennisball", 10, "How much does tennis ball spawn higher = more common");
			VolumeConfig = new ConfigFile(Paths.ConfigPath + "\\BlissCorp.AudioVolume.cfg", true);
		}
	}
	[BepInPlugin("faejr.blissscrap", "BlissScrap", "0.5.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "faejr.blissscrap";

		public const string ModName = "BlissScrap";

		public const string ModVersion = "0.5.0";

		public static ManualLogSource logger;

		public static ConfigFile config;

		public static AssetBundle BlissScrapAssets;

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			Config.Load();
			BlissScrapAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "blissscrap"));
			Item val = SetupAsset("assets/custom/scrap/vai5000/vai5000.asset", Config.vai5000SpawnWeight.Value);
			if (Object.op_Implicit((Object)(object)val))
			{
				logger.LogInfo((object)"Vai5000 has infiltrated your facilities...");
			}
			SetupAsset("assets/custom/scrap/eggspray/eggspray.asset", Config.eggSpraySpawnWeight.Value);
			SetupAsset("assets/custom/scrap/blissy/blissy.asset", Config.blissySpawnWeight.Value);
			SetupAsset("assets/custom/scrap/alem/alem.asset", Config.alemSpawnWeight.Value);
			SetupAsset("assets/custom/scrap/gba/gba.asset", Config.gbaSpawnWeight.Value);
			SetupAsset("assets/custom/scrap/swallowbug/swallowbug.asset", Config.swallowbugSpawnWeight.Value);
			if (Chainloader.PluginInfos.ContainsKey("evaisa.lethalthings"))
			{
				SetupAsset("assets/custom/scrap/dani ball/TennisBall.asset", Config.swallowbugSpawnWeight.Value);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BlissScrap is loaded!");
		}

		private Item SetupAsset(string assetName, int spawnWeight)
		{
			logger.LogInfo((object)("Loading " + assetName));
			Item val = BlissScrapAssets.LoadAsset<Item>(assetName);
			if ((Object)(object)val == (Object)null)
			{
				logger.LogError((object)("Failed to load " + assetName));
				return null;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, spawnWeight, (LevelTypes)(-1));
			AudioSource[] componentsInChildren = val.spawnPrefab.GetComponentsInChildren<AudioSource>();
			string name = ((Object)val.spawnPrefab).name;
			if (componentsInChildren.Length != 0)
			{
				ConfigEntry<float> val2 = Config.VolumeConfig.Bind<float>("Volume", name ?? "", 100f, "Audio volume for " + name + " (0 - 100)");
				AudioSource[] array = componentsInChildren;
				foreach (AudioSource val3 in array)
				{
					val3.volume *= val2.Value / 100f;
				}
			}
			return val;
		}
	}
}
namespace BlissScrap.MonoBehaviours
{
	public class GBA : GrabbableObject
	{
		private bool screenOn = false;

		private int emissiveIntensity = 1;

		private Color emissiveColor = Color.white;

		public AudioSource noiseAudio;

		public AudioClip startupSFX;

		public float loudness = 1f;

		[Space(3f)]
		public float noiseRange;

		private Material screenMaterial;

		private float screenOnTimer = 0f;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				if ((Object)(object)screenMaterial == (Object)null)
				{
					screenMaterial = ((Renderer)base.mainObjectRenderer).material;
				}
				if (!screenOn)
				{
					noiseAudio.PlayOneShot(startupSFX, loudness);
					WalkieTalkie.TransmitOneShotAudio(noiseAudio, startupSFX, loudness);
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, loudness, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
					screenOn = true;
					base.isBeingUsed = true;
				}
				else if (screenOn && !noiseAudio.isPlaying)
				{
					screenMaterial.SetColor("_EmissiveColor", emissiveColor * 0f);
					screenOn = false;
					base.isBeingUsed = false;
					screenOnTimer = 0f;
				}
			}
		}

		public override void Update()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (screenOn && screenOnTimer < 1f)
			{
				screenOnTimer += Time.deltaTime;
				screenMaterial.SetColor("_EmissiveColor", emissiveColor * Mathf.Lerp(0f, (float)emissiveIntensity, screenOnTimer));
			}
		}
	}
	public class Vai5000 : NoisemakerProp
	{
		private float mouthChanger = 0f;

		private Material mouthMaterial;

		public Texture[] mouthTextures;

		public Texture notTalkingTexture;

		private bool nonMovingSet = true;

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (base.noiseAudio.isPlaying)
			{
				mouthChanger += Time.deltaTime;
				if (!(mouthChanger > 0.5f))
				{
					return;
				}
				if ((Object)(object)mouthMaterial == (Object)null)
				{
					mouthMaterial = ((Renderer)((GrabbableObject)this).mainObjectRenderer).materials.Where((Material x) => ((Object)x).name == "mouth").FirstOrDefault();
				}
				if ((Object)(object)mouthMaterial != (Object)null)
				{
					mouthMaterial.SetTexture("_BaseMap", GetRandomMouthFrame());
					mouthChanger = 0f;
					nonMovingSet = false;
				}
				return;
			}
			if ((Object)(object)mouthMaterial == (Object)null)
			{
				mouthMaterial = ((Renderer)((GrabbableObject)this).mainObjectRenderer).materials.Where((Material x) => ((Object)x).name.StartsWith("mouth")).FirstOrDefault();
			}
			if ((Object)(object)mouthMaterial != (Object)null && !nonMovingSet)
			{
				mouthMaterial.SetTexture("_BaseMap", notTalkingTexture);
				nonMovingSet = true;
			}
		}

		private Texture GetRandomMouthFrame()
		{
			return mouthTextures[Random.Range(0, mouthTextures.Length)];
		}
	}
}