Decompiled source of ELTOMod v1.1.1

ELTOModScripts.dll

Decompiled a month ago
using System;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
using Photon.Pun;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Krumpli")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ELTOModScripts")]
[assembly: AssemblyTitle("ELTOModScripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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;
		}
	}
}
public class ValuableSlimeBlock : MonoBehaviour
{
	public Sound? bounceSound;

	private Vector2 smallForceRange = new Vector2(1f, 1.5f);

	private Vector2 mediumForceRange = new Vector2(1f, 2f);

	private Vector2 bigForceRange = new Vector2(2f, 4f);

	private Vector2 smallTorqueRange = new Vector2(0f, 0.1f);

	private Vector2 mediumTorqueRange = new Vector2(0.05f, 0.1f);

	private Vector2 bigTorqueRange = new Vector2(0.1f, 0.5f);

	private float torqueMultiplier;

	private int bounceAmount;

	private int bounces;

	private Rigidbody? rigidbody;

	private PhotonView? photonView;

	private PhysGrabObject? physGrabObject;

	private void Start()
	{
		rigidbody = ((Component)this).GetComponent<Rigidbody>();
		photonView = ((Component)this).GetComponent<PhotonView>();
		physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
		bounceAmount = Random.Range(2, 6);
	}

	private void Bounce(Vector2 torqueRange, Vector2 forceRange)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rigidbody == (Object)null || (Object)(object)physGrabObject == (Object)null)
		{
			return;
		}
		Sound? obj = bounceSound;
		if (obj != null)
		{
			obj.Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
		}
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		torqueMultiplier = Random.Range(torqueRange.x, torqueRange.y);
		if (bounces < bounceAmount && !physGrabObject.grabbed)
		{
			bounces++;
			rigidbody.AddForce(Vector3.up * Random.Range(forceRange.x, forceRange.y), (ForceMode)1);
			rigidbody.AddTorque(Random.insideUnitSphere * torqueMultiplier, (ForceMode)1);
			return;
		}
		Vector3 velocity = rigidbody.velocity;
		if (((Vector3)(ref velocity)).magnitude < 0.1f || physGrabObject.grabbed)
		{
			bounces = 0;
			bounceAmount = Random.Range(2, 6);
		}
	}

	public void SmallBounce()
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		Bounce(smallTorqueRange, smallForceRange);
	}

	public void MediumBounce()
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		Bounce(mediumTorqueRange, mediumForceRange);
	}

	public void BigBounce()
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		Bounce(bigTorqueRange, bigForceRange);
	}
}
namespace ELTOModScripts
{
	[BepInPlugin("Krumpli.ELTOModScripts", "ELTOModScripts", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ELTOModScripts : BaseUnityPlugin
	{
		internal static ELTOModScripts Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
	public class ValuableMeridiasBeacon : MonoBehaviour
	{
		private PhysGrabObject? physGrabObject;

		private AudioSource? audioSource;

		public AudioClip? audioClip;

		private int previousGrabberCount = 0;

		private void Start()
		{
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.clip = audioClip;
			audioSource.playOnAwake = false;
		}

		private void Update()
		{
			if (!((Object)(object)physGrabObject == (Object)null) && !((Object)(object)audioSource == (Object)null) && !((Object)(object)audioClip == (Object)null))
			{
				int count = physGrabObject.playerGrabbing.Count;
				if (count > 0 && count > previousGrabberCount)
				{
					audioSource.Stop();
					audioSource.Play();
				}
				previousGrabberCount = count;
			}
		}
	}
	public class ValuableRedstoneOre : MonoBehaviour
	{
		private PhysGrabObject? physGrabObject;

		private ParticleSystem? particleSystem;

		private Light? light;

		private MeshRenderer? meshRenderer;

		public Material? activeMaterial;

		public Material? inactiveMaterial;

		private bool isActive = false;

		private float lastGrabTime = 0f;

		private float lifeTime = 15f;

		private void Start()
		{
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			particleSystem = ((Component)this).GetComponentInChildren<ParticleSystem>();
			light = ((Component)this).GetComponentInChildren<Light>();
			meshRenderer = ((Component)this).GetComponentInChildren<MeshRenderer>();
		}

		private void Update()
		{
			if (!((Object)(object)physGrabObject == (Object)null) && !((Object)(object)particleSystem == (Object)null) && !((Object)(object)light == (Object)null) && !((Object)(object)meshRenderer == (Object)null) && !((Object)(object)activeMaterial == (Object)null) && !((Object)(object)inactiveMaterial == (Object)null))
			{
				if (physGrabObject.grabbed)
				{
					lifeTime = Random.Range(5f, 15f);
					lastGrabTime = Time.time;
				}
				bool flag = lastGrabTime + lifeTime > Time.time;
				if (flag != isActive)
				{
					UpdateState(flag);
				}
			}
		}

		private void UpdateState(bool active)
		{
			isActive = active;
			if (isActive)
			{
				particleSystem.Play();
				((Behaviour)light).enabled = true;
				if ((Object)(object)meshRenderer != (Object)null)
				{
					((Renderer)meshRenderer).material = activeMaterial;
				}
			}
			else
			{
				particleSystem.Stop();
				((Behaviour)light).enabled = false;
				if ((Object)(object)meshRenderer != (Object)null)
				{
					((Renderer)meshRenderer).material = inactiveMaterial;
				}
			}
		}
	}
}