Decompiled source of CHIERNA YAMA v1.0.0

CHIERNA_YAMA.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Configuration;
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("m1r0")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CHIERNA_YAMA")]
[assembly: AssemblyTitle("CHIERNA_YAMA")]
[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;
		}
	}
}
public class ChiernaYamaConfig
{
	public ConfigEntry<int> GlassDurability { get; private set; }

	public ConfigEntry<int> GlassBreakadgeMultiplier { get; private set; }

	public ConfigEntry<float> ContainedYamaJitterIncrement { get; private set; }

	public ConfigEntry<int> MinSpawnValue { get; private set; }

	public ConfigEntry<int> MaxSpawnValue { get; private set; }

	public ConfigEntry<int> MinReleasedValue { get; private set; }

	public ConfigEntry<int> MaxReleasedValue { get; private set; }

	public ConfigEntry<float> Mass { get; private set; }

	public ConfigEntry<float> SizeMultiplier { get; private set; }

	public ConfigEntry<float> PriceMultiplier { get; private set; }

	public ConfigEntry<float> MassMultiplier { get; private set; }

	public ConfigEntry<float> PullStrength { get; private set; }

	public ConfigEntry<float> PullStrengthIncrement { get; private set; }

	public ConfigEntry<float> PullStrengthRadius { get; private set; }

	public ConfigEntry<int> AmountOfConsumes { get; private set; }

	public ConfigEntry<float> ImplodeSpeed { get; private set; }

	public ConfigEntry<float> ExplodeSpeed { get; private set; }

	public ConfigEntry<float> ExplodeRadiusMultiplier { get; private set; }

	public ConfigEntry<float> MaxSizeLimit { get; private set; }

	public ConfigEntry<float> MaxPriceLimit { get; private set; }

	public ConfigEntry<float> MaxMassLimit { get; private set; }

	public ConfigEntry<float> MaxPullStrengthLimit { get; private set; }

	public void Init(ConfigFile config)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Expected O, but got Unknown
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Expected O, but got Unknown
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Expected O, but got Unknown
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Expected O, but got Unknown
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Expected O, but got Unknown
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Expected O, but got Unknown
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Expected O, but got Unknown
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Expected O, but got Unknown
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Expected O, but got Unknown
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Expected O, but got Unknown
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Expected O, but got Unknown
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Expected O, but got Unknown
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Expected O, but got Unknown
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Expected O, but got Unknown
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Expected O, but got Unknown
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Expected O, but got Unknown
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Expected O, but got Unknown
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Expected O, but got Unknown
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Expected O, but got Unknown
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Expected O, but got Unknown
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Expected O, but got Unknown
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Expected O, but got Unknown
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f5: Expected O, but got Unknown
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fa: Expected O, but got Unknown
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Expected O, but got Unknown
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0439: Expected O, but got Unknown
		//IL_045b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Expected O, but got Unknown
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0491: Expected O, but got Unknown
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bd: Expected O, but got Unknown
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e9: Expected O, but got Unknown
		GlassDurability = config.Bind<int>("Case", "Glass Durability", 3, new ConfigDescription("amount of hits it takes for the glass to break. \nDefault: 3", (AcceptableValueBase)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
		GlassBreakadgeMultiplier = config.Bind<int>("Case", "Glass Breakadge Multiplier", 2, new ConfigDescription("multiplies the visual effect scale of a broken glass.\n (its only visual) \nDefault: 2", (AcceptableValueBase)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		ContainedYamaJitterIncrement = config.Bind<float>("Case", "jitter Increment", 0.33f, new ConfigDescription("increments the jitter of an Yama while its contained.\n (its only visual and its max sum is capped at 2) \nDefault: 0.33", (AcceptableValueBase)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
		MinSpawnValue = config.Bind<int>("Spawned Value", "Min Spawned Sell Price", 1000, new ConfigDescription("Minimum value of Chierna Yama when spawned. \nDefault: 1000", (AcceptableValueBase)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>()));
		MaxSpawnValue = config.Bind<int>("Spawned Value", "Max Spawned Sell Price", 3000, new ConfigDescription("Maximum value ofChierna Yama when spawned. \nDefault: 3000", (AcceptableValueBase)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>()));
		MinReleasedValue = config.Bind<int>("Released Value", "Min Sell Price After Releasing", 1000, new ConfigDescription("Minimum value of Chierna Yama when released from its protective container. \nAfter releasing it will reroll a new value from this range. \nIf set to `-1` it will retain its value from its previouse state.\nDefault: 1000", (AcceptableValueBase)new AcceptableValueRange<int>(-1, 100000), Array.Empty<object>()));
		MaxReleasedValue = config.Bind<int>("Released Value", "Max Sell Price After Releasing", 4000, new ConfigDescription("Maximum value of Chierna Yama when released from its protective container. \nDefault: 4000", (AcceptableValueBase)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>()));
		Mass = config.Bind<float>("Physics", "Weight", 1f, new ConfigDescription("Weight of Chierna Yama in its smallest state \n(glass box adds +1 weight while present) \nDefault: 1", (AcceptableValueBase)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
		SizeMultiplier = config.Bind<float>("GrowthMultiplier", "Size Multiplier", 1.12f, new ConfigDescription("Whenever it consumes an object, its current size will be multiplied by this value. \nSet To 1 to disable \nDefault: 1.12", (AcceptableValueBase)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
		PriceMultiplier = config.Bind<float>("GrowthMultiplier", "Price Multiplier", 1.175f, new ConfigDescription("Whenever it consumes an object, its current price will be multiplied by this value. \nSet To 1 to disable \nDefault: 1.175", (AcceptableValueBase)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
		MassMultiplier = config.Bind<float>("GrowthMultiplier", "Weight Multiplier", 1.1f, new ConfigDescription("Whenever it consumes an object, its current weight will be multiplied by this value. \nSet To 1 to disable \nDefault: 1.1", (AcceptableValueBase)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
		PullStrength = config.Bind<float>("Suction", "Pull Srength", 15f, new ConfigDescription("Strength by which are objects pulled towards the Chierna Yama\n calculated as: <Pull Strength>/<distance> \nSet To 0 to disable \nDefault: 15", (AcceptableValueBase)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		PullStrengthIncrement = config.Bind<float>("Suction", "Pull Srength Increment", 4f, new ConfigDescription("Value by which is the Pull Strength incremented after it consumes an object \nSet To 0 to disable \nDefault: 4", (AcceptableValueBase)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		PullStrengthRadius = config.Bind<float>("Suction", "Pull Srength Radius Limit", 20f, new ConfigDescription("Disables the pull of objects at this distance for performace \nDefault: 20", (AcceptableValueBase)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		AmountOfConsumes = config.Bind<int>("Suction", "Amount of consumes to reach its climax", 25, new ConfigDescription("amount of items it needs to consume in order to reach its climax \nDefault: 25", (AcceptableValueBase)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		ImplodeSpeed = config.Bind<float>("Implosion and After", "Implode Speed", 10f, new ConfigDescription("Speed in seconds it takes for the Chierna Yama to Implode after reaching its climax \nDefault: 10", (AcceptableValueBase)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>()));
		ExplodeSpeed = config.Bind<float>("Implosion and After", "Explode Speed", 5f, new ConfigDescription("Speed in seconds it takes for the Chierna Yama to grow and destroy after imploding \nDefault: 5", (AcceptableValueBase)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>()));
		ExplodeRadiusMultiplier = config.Bind<float>("Implosion and After", "Explode Radius Multiplier", 1f, new ConfigDescription("Explode maximum size multiplayer. Takes the climax size and multiplies it by this value \nDefault: 1", (AcceptableValueBase)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		MaxSizeLimit = config.Bind<float>("Limits", "Max Size Limt", 17f, new ConfigDescription("objects size will be capped at this value \n Disable with: -1 \nDefault: 17", (AcceptableValueBase)null, Array.Empty<object>()));
		MaxPriceLimit = config.Bind<float>("Limits", "Max Price Limt", -1f, new ConfigDescription("objects price will be capped at this value \n Disable with: -1 \nDefault: -1", (AcceptableValueBase)null, Array.Empty<object>()));
		MaxMassLimit = config.Bind<float>("Limits", "Max Weight Limt", 10f, new ConfigDescription("objects weight will be capped at this value \n Disable with: -1 \nDefault: 10", (AcceptableValueBase)null, Array.Empty<object>()));
		MaxPullStrengthLimit = config.Bind<float>("Limits", "Max Pull Strength Limt", -1f, new ConfigDescription("objects pull strength will be capped at this value \n Disable with: -1 \nDefault: -1", (AcceptableValueBase)null, Array.Empty<object>()));
	}
}
namespace CHIERNA_YAMA
{
	internal class ChiernaYamaController : Trap
	{
		private enum DieraState
		{
			Contained,
			Released,
			Collapsing,
			Expanding
		}

		private DieraState currentState = DieraState.Contained;

		private int caseDurability;

		private int dieraRemainingConsumes;

		private float mass;

		[Header("GameObjects")]
		public GameObject containedDiera;

		public GameObject releasedDiera;

		public GameObject collapsedDiera;

		private float absorptionStrength;

		private Rigidbody rb;

		private ValuableObject valuableObject;

		private float glassBreakadge = 3f;

		private float holeJitter = 0f;

		private float releasedHoleScale = 1f;

		private float collapse = 0f;

		private float collapseSpeed = 0f;

		public void Damaged()
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != 0 || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (caseDurability <= 0)
			{
				float num = valuableObject.dollarValueCurrent;
				if (CHIERNA_YAMA.CONFIG.MinReleasedValue.Value != -1)
				{
					float num2 = CHIERNA_YAMA.CONFIG.MinReleasedValue.Value;
					float num3 = CHIERNA_YAMA.CONFIG.MaxReleasedValue.Value;
					num = Math.Max(Random.value * (num3 - num2) + num2, 0f);
				}
				if (GameManager.Multiplayer())
				{
					base.photonView.RPC("BreakTheCaseRPC", (RpcTarget)0, new object[1] { num });
				}
				else
				{
					BreakTheCaseRPC(num);
				}
			}
			else
			{
				glassBreakadge *= CHIERNA_YAMA.CONFIG.GlassBreakadgeMultiplier.Value;
				holeJitter = Math.Min(2f, holeJitter + CHIERNA_YAMA.CONFIG.ContainedYamaJitterIncrement.Value);
				if (GameManager.Multiplayer())
				{
					base.photonView.RPC("CrackGlassRPC", (RpcTarget)0, new object[2] { glassBreakadge, holeJitter });
				}
				else
				{
					CrackGlassRPC(glassBreakadge, holeJitter);
				}
				caseDurability--;
			}
		}

		private void Start()
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			((Trap)this).Start();
			caseDurability = CHIERNA_YAMA.CONFIG.GlassDurability.Value;
			dieraRemainingConsumes = CHIERNA_YAMA.CONFIG.AmountOfConsumes.Value;
			absorptionStrength = CHIERNA_YAMA.CONFIG.PullStrength.Value;
			mass = CHIERNA_YAMA.CONFIG.Mass.Value + 1f;
			rb = ((Component)this).GetComponent<Rigidbody>();
			valuableObject = ((Component)this).GetComponent<ValuableObject>();
			base.physGrabObject.OverrideMass(mass, 0.1f);
			base.physGrabObject.massOriginal = mass;
			float num = CHIERNA_YAMA.CONFIG.MinSpawnValue.Value;
			float num2 = CHIERNA_YAMA.CONFIG.MaxSpawnValue.Value;
			float num3 = Math.Max(Random.value * (num2 - num) + num, 0f);
			valuableObject.dollarValueCurrent = num3;
			valuableObject.dollarValueOriginal = num3;
			if (GameManager.Multiplayer())
			{
				base.photonView.RPC("CrackGlassRPC", (RpcTarget)0, new object[2] { 0f, 0f });
			}
			else
			{
				CrackGlassRPC(0f, 0f);
			}
		}

		private void FixedUpdate()
		{
			if (currentState == DieraState.Released && SemiFunc.IsMasterClientOrSingleplayer())
			{
				Suction();
			}
			else if (currentState == DieraState.Collapsing)
			{
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					Suction();
				}
				CollapseTransformation();
			}
			else if (currentState == DieraState.Expanding)
			{
				ExpandingTransformation();
			}
		}

		private void Suction()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			float distanceOfEffect = Math.Min(absorptionStrength / 10f * (1f - collapse), CHIERNA_YAMA.CONFIG.PullStrengthRadius.Value);
			List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(distanceOfEffect, ((Component)this).transform.position, false, default(LayerMask));
			List<PhysGrabObject> source = SemiFunc.PhysGrabObjectGetAllWithinRange(distanceOfEffect, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
			List<Enemy> source2 = (from e in ((Component)LevelGenerator.Instance).GetComponentsInChildren<Enemy>()
				where Vector3.Distance(((Component)e).transform.position, ((Component)this).transform.position) < distanceOfEffect
				select e).ToList();
			HashSet<Rigidbody> hashSet = new HashSet<Rigidbody>();
			hashSet.UnionWith(source.Select((PhysGrabObject p) => p.rb));
			hashSet.UnionWith(source2.Select((Enemy p) => p.Rigidbody.rb));
			hashSet.Remove(rb);
			foreach (Rigidbody item in hashSet)
			{
				Vector3 val = rb.position - item.position;
				Vector3 val2 = absorptionStrength * val / ((Vector3)(ref val)).sqrMagnitude * (1f - collapse);
				item.AddForce(val2, (ForceMode)5);
			}
			foreach (PlayerAvatar item2 in list)
			{
				Vector3 val3 = (item2.isTumbling ? ((Component)item2.tumble.physGrabObject).transform.position : item2.rb.position);
				Vector3 val4 = rb.position - val3;
				Vector3 val5 = absorptionStrength * val4 / ((Vector3)(ref val4)).sqrMagnitude * (1f - collapse);
				if (!item2.isTumbling)
				{
					item2.ForceImpulse(val5 * Time.fixedDeltaTime);
				}
			}
		}

		private void grow(int n = 1)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || currentState != DieraState.Released)
			{
				return;
			}
			if (dieraRemainingConsumes <= 0)
			{
				if (GameManager.Multiplayer())
				{
					base.photonView.RPC("StartCollapseRPC", (RpcTarget)0, new object[1] { 1f / CHIERNA_YAMA.CONFIG.ImplodeSpeed.Value });
				}
				else
				{
					StartCollapseRPC(1f / CHIERNA_YAMA.CONFIG.ImplodeSpeed.Value);
				}
				return;
			}
			releasedHoleScale *= MathF.Pow(CHIERNA_YAMA.CONFIG.SizeMultiplier.Value, n);
			ValuableObject obj = valuableObject;
			obj.dollarValueCurrent *= MathF.Pow(CHIERNA_YAMA.CONFIG.PriceMultiplier.Value, n);
			mass *= MathF.Pow(CHIERNA_YAMA.CONFIG.MassMultiplier.Value, n);
			if (CHIERNA_YAMA.CONFIG.MaxSizeLimit.Value != -1f)
			{
				releasedHoleScale = Math.Min(releasedHoleScale, CHIERNA_YAMA.CONFIG.MaxSizeLimit.Value);
			}
			if (CHIERNA_YAMA.CONFIG.MaxPriceLimit.Value != -1f)
			{
				valuableObject.dollarValueCurrent = Math.Min(valuableObject.dollarValueCurrent, CHIERNA_YAMA.CONFIG.MaxSizeLimit.Value);
			}
			if (CHIERNA_YAMA.CONFIG.MaxMassLimit.Value != -1f)
			{
				mass = Math.Min(mass, CHIERNA_YAMA.CONFIG.MaxMassLimit.Value);
			}
			if (GameManager.Multiplayer())
			{
				base.photonView.RPC("DieraGrowthRPC", (RpcTarget)0, new object[3] { releasedHoleScale, valuableObject.dollarValueCurrent, mass });
			}
			else
			{
				DieraGrowthRPC(releasedHoleScale, valuableObject.dollarValueCurrent, mass);
			}
			dieraRemainingConsumes -= n;
			absorptionStrength += CHIERNA_YAMA.CONFIG.PullStrengthIncrement.Value * (float)n;
			if (CHIERNA_YAMA.CONFIG.MaxPullStrengthLimit.Value != -1f)
			{
				absorptionStrength = Math.Min(absorptionStrength, CHIERNA_YAMA.CONFIG.MaxPullStrengthLimit.Value);
			}
		}

		public void OnPlayerSucked()
		{
			PlayerAvatar onImpactPlayerAvatar = releasedDiera.GetComponentInChildren<HurtCollider>().onImpactPlayerAvatar;
			if (!onImpactPlayerAvatar.deadSet)
			{
				grow(2);
			}
		}

		public void OnObjectSucked()
		{
			grow();
		}

		public void OnEnemySucked()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			Enemy onImpactEnemyEnemy = releasedDiera.GetComponentInChildren<HurtCollider>().onImpactEnemyEnemy;
			grow(onImpactEnemyEnemy.Type + 1);
		}

		private void CollapseTransformation()
		{
			//IL_00f6: 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)
			MeshRenderer componentInChildren = releasedDiera.GetComponentInChildren<MeshRenderer>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			((Renderer)componentInChildren).material.SetFloat("_HoleCollapse", collapse);
			collapse += collapseSpeed * Time.fixedDeltaTime;
			if (collapse > 1f && SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (GameManager.Multiplayer())
				{
					base.photonView.RPC("StartExpandingRPC", (RpcTarget)0, new object[2]
					{
						1f / CHIERNA_YAMA.CONFIG.ExplodeSpeed.Value,
						releasedHoleScale * CHIERNA_YAMA.CONFIG.ExplodeRadiusMultiplier.Value
					});
				}
				else
				{
					StartExpandingRPC(1f / CHIERNA_YAMA.CONFIG.ExplodeSpeed.Value, releasedHoleScale * CHIERNA_YAMA.CONFIG.ExplodeRadiusMultiplier.Value);
				}
			}
		}

		private void ExpandingTransformation()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			collapse += collapseSpeed * Time.fixedDeltaTime;
			MeshRenderer componentInChildren = collapsedDiera.GetComponentInChildren<MeshRenderer>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			((Renderer)componentInChildren).material.SetFloat("_MyTimer", collapse);
			Light componentInChildren2 = collapsedDiera.GetComponentInChildren<Light>();
			if ((Object)(object)componentInChildren2 == (Object)null)
			{
				return;
			}
			componentInChildren2.range = 20f * collapse;
			componentInChildren2.intensity = 15f * collapse;
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			HurtCollider componentInChildren3 = collapsedDiera.GetComponentInChildren<HurtCollider>();
			if (collapse > 1f)
			{
				if (GameManager.Multiplayer())
				{
					base.photonView.RPC("DobruNocRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					DobruNocRPC();
				}
			}
			else if (collapse > 0.8f && !((Behaviour)componentInChildren3).enabled)
			{
				((Behaviour)componentInChildren3).enabled = true;
			}
		}

		[PunRPC]
		private void CrackGlassRPC(float glassDamage, float holeMoveSpeed, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterAndOwnerOnlyRPC(_info, base.photonView))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)containedDiera))
			{
				Debug.LogError((object)"CONTAINED DIERA IS NOT INITIALIZED!!!!!!!!!");
				return;
			}
			MeshRenderer componentInChildren = containedDiera.GetComponentInChildren<MeshRenderer>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				((Renderer)componentInChildren).material.SetFloat("_Damage", glassDamage);
				((Renderer)componentInChildren).material.SetFloat("_Jitter", holeMoveSpeed);
			}
		}

		[PunRPC]
		private void BreakTheCaseRPC(float newValue, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterAndOwnerOnlyRPC(_info, base.photonView))
			{
				return;
			}
			PhysGrabObjectImpactDetector component = ((Component)this).gameObject.GetComponent<PhysGrabObjectImpactDetector>();
			component.ChangePhysAudio((PhysAudio)null);
			currentState = DieraState.Released;
			containedDiera.SetActive(false);
			PhysObjectParticles particles = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>().particles;
			particles.DestroyParticles();
			releasedDiera.SetActive(true);
			foreach (PhysGrabber item in base.physGrabObject.playerGrabbing)
			{
				item.OverrideGrabRelease();
			}
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().destroyDisable = true;
			valuableObject.dollarValueCurrent = newValue;
			mass -= 1f;
			base.physGrabObject.OverrideMass(mass, 0.1f);
			base.physGrabObject.massOriginal = mass;
		}

		[PunRPC]
		private void DieraGrowthRPC(float newScale, float newValue, float newMass, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterAndOwnerOnlyRPC(_info, base.photonView))
			{
				MeshRenderer componentInChildren = releasedDiera.GetComponentInChildren<MeshRenderer>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					((Renderer)componentInChildren).material.SetFloat("_SphereScale", newScale);
					releasedDiera.transform.localScale = new Vector3(newScale, newScale, newScale);
					valuableObject.dollarValueCurrent = newValue;
					base.physGrabObject.OverrideMass(newMass, 0.1f);
					base.physGrabObject.massOriginal = mass;
				}
			}
		}

		[PunRPC]
		private void StartCollapseRPC(float speed, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterAndOwnerOnlyRPC(_info, base.photonView))
			{
				currentState = DieraState.Collapsing;
				collapseSpeed = speed;
				collapse = 0f;
				((Behaviour)releasedDiera.GetComponentInChildren<HurtCollider>()).enabled = false;
			}
		}

		[PunRPC]
		private void StartExpandingRPC(float speed, float holeScale, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: 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)
			if (SemiFunc.MasterAndOwnerOnlyRPC(_info, base.photonView))
			{
				currentState = DieraState.Expanding;
				releasedDiera.SetActive(false);
				collapsedDiera.transform.localScale = new Vector3(holeScale, holeScale, holeScale);
				SphereCollider component = collapsedDiera.GetComponent<SphereCollider>();
				component.radius /= CHIERNA_YAMA.CONFIG.ExplodeRadiusMultiplier.Value;
				MeshRenderer componentInChildren = collapsedDiera.GetComponentInChildren<MeshRenderer>();
				((Renderer)componentInChildren).material.SetFloat("_MyTimer", 0f);
				collapsedDiera.SetActive(true);
				collapseSpeed = speed;
				collapse = 0f;
			}
		}

		[PunRPC]
		private void DobruNocRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterAndOwnerOnlyRPC(_info, base.photonView))
			{
				base.physGrabObject.dead = true;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	[BepInPlugin("m1r0.CHIERNA_YAMA", "CHIERNA_YAMA", "1.0")]
	public class CHIERNA_YAMA : BaseUnityPlugin
	{
		internal static CHIERNA_YAMA Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

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

		internal Harmony? Harmony { get; set; }

		public static ChiernaYamaConfig CONFIG { get; private set; }

		private void Awake()
		{
			Instance = this;
			CONFIG = new ChiernaYamaConfig();
			CONFIG.Init(((BaseUnityPlugin)this).Config);
			((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()
		{
		}
	}
	[HarmonyPatch(typeof(PlayerController))]
	internal static class ExamplePlayerControllerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void Start_Prefix(PlayerController __instance)
		{
			CHIERNA_YAMA.Logger.LogDebug((object)$"{__instance} Start Prefix");
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(PlayerController __instance)
		{
			CHIERNA_YAMA.Logger.LogDebug((object)$"{__instance} Start Postfix");
		}
	}
}