Decompiled source of Durstloescher v1.1.0

Durstlöscher.dll

Decompiled 2 weeks ago
using System;
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 Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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 = "")]
[assembly: AssemblyCompany("Durstlöscher")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Durstlöscher")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Durstlöscher")]
[assembly: AssemblyTitle("Durstlöscher")]
[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 Durstlöscher
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Durstlöscher";

		public const string PLUGIN_NAME = "Durstlöscher";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Durstloescher
{
	[BepInPlugin("ErrorJan.REPO.Durstloescher", "Durstlöscher", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string PluginGUID = "ErrorJan.REPO.Durstloescher";

		internal const string PluginName = "Durstlöscher";

		internal const string PluginVersion = "1.1.0";

		private void Awake()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "durstloescher"));
			GameObject val2 = val.LoadAsset<GameObject>("Valuable Durstlöscher");
			val2.AddComponent<DurstLoescherTrap>();
			Valuables.RegisterValuable(val2);
		}
	}
	public class DurstLoescherTrap : MonoBehaviour
	{
		public Sound? sndFx;

		public PhysGrabObject? physGrabObject;

		public bool prevGrabbed = false;

		public AudioSource? currAudioSource;

		public float timerNext = 0f;

		private void Start()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			GameObject gameObject = ((Component)((Component)this).transform.Find("AudioSource")).gameObject;
			AudioSource component = gameObject.GetComponent<AudioSource>();
			PhysGrabObjectImpactDetector component2 = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			sndFx = new Sound();
			sndFx.Sounds = (AudioClip[])(object)new AudioClip[1];
			sndFx.Sounds[0] = component.clip;
			sndFx.Type = (AudioType)0;
			sndFx.Volume = 0.3f;
			sndFx.VolumeRandom = 0.02f;
			sndFx.Pitch = 1f;
			sndFx.PitchRandom = 0f;
			sndFx.SpatialBlend = 1f;
			sndFx.Doppler = 1f;
			sndFx.ReverbMix = 1f;
			sndFx.FalloffMultiplier = 1f;
			sndFx.OffscreenVolume = 1f;
			sndFx.OffscreenFalloff = 1f;
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			prevGrabbed = false;
			component2.onBreakHeavy.AddListener(new UnityAction(ReactOnBreakHeavy));
		}

		private void Update()
		{
			if (!((Object)(object)physGrabObject == (Object)null) && sndFx != null && prevGrabbed != physGrabObject.grabbed)
			{
				prevGrabbed = physGrabObject.grabbed;
				if (timerNext < Time.time && prevGrabbed && Random.Range(0, 100) > 95)
				{
					PlaySound();
					timerNext = Time.time + 30f;
				}
			}
		}

		public void ReactOnBreakHeavy()
		{
			if (Random.Range(0, 100) >= 75)
			{
				PlaySound();
			}
		}

		public void PlaySound()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)currAudioSource != (Object)null) && sndFx != null && !((Object)(object)physGrabObject == (Object)null))
			{
				currAudioSource = sndFx.Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				((Component)currAudioSource).transform.SetParent(((Component)this).transform, true);
			}
		}
	}
}