Decompiled source of Satisfactory Items v1.0.5

SatisfactoryItems.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
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;
using UnityEngine.Animations;
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 = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("Bene")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SatisfactoryItems")]
[assembly: AssemblyTitle("SatisfactoryItems")]
[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;
		}
	}
}
namespace SatisfactoryItems
{
	public class Nobelisk : MonoBehaviour
	{
		private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");

		public Color blinkColor;

		public GameObject meshObject;

		public UnityEvent onDetonate;

		private ItemToggle _itemToggle;

		private ItemAttributes _itemAttributes;

		private bool _isActive;

		private float _nobeliskTimer;

		public float tickTime = 3f;

		private PhotonView _photonView;

		private PhysGrabObjectImpactDetector _physGrabObjectImpactDetector;

		public Sound soundTick;

		private Material _nobeliskEmissionMaterial;

		private ItemEquippable _itemEquippable;

		private Vector3 _nobeliskStartPosition;

		private Quaternion _nobeliskStartRotation;

		private PhysGrabObject _physGrabObject;

		private Vector3 _prevPosition;

		[HideInInspector]
		public bool isSpawnedGrenade;

		public GameObject throwLine;

		private Rigidbody _rb;

		private float _throwLineTimer;

		private TrailRenderer _throwLineTrail;

		private PositionConstraint _positionConstraint;

		private void Start()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			_itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
			_itemToggle = ((Component)this).GetComponent<ItemToggle>();
			_itemAttributes = ((Component)this).GetComponent<ItemAttributes>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_physGrabObjectImpactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			_nobeliskStartPosition = ((Component)this).transform.position;
			_nobeliskStartRotation = ((Component)this).transform.rotation;
			_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			_rb = ((Component)this).GetComponent<Rigidbody>();
			_throwLineTrail = throwLine.GetComponent<TrailRenderer>();
			_positionConstraint = ((Component)this).GetComponent<PositionConstraint>();
			_nobeliskEmissionMaterial = meshObject.GetComponent<Renderer>().material;
		}

		private void FixedUpdate()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (_itemEquippable.isEquipped || _itemEquippable.wasEquippedTimer > 0f)
			{
				_prevPosition = _rb.position;
				return;
			}
			Vector3 val = (_rb.position - _prevPosition) / Time.fixedDeltaTime;
			Vector3 val2 = _rb.position - _prevPosition;
			_ = ((Vector3)(ref val2)).normalized;
			_prevPosition = _rb.position;
			if (!_physGrabObject.grabbed && ((Vector3)(ref val)).magnitude > 2f)
			{
				_throwLineTimer = 0.2f;
			}
			if (_throwLineTimer > 0f)
			{
				_throwLineTrail.emitting = true;
				_throwLineTimer -= Time.fixedDeltaTime;
			}
			else
			{
				_throwLineTrail.emitting = false;
			}
		}

		private void Update()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			soundTick.PlayLoop(_isActive, 2f, 2f, 1f);
			if (_itemEquippable.isEquipped)
			{
				if (_isActive)
				{
					_isActive = false;
					_nobeliskTimer = 0f;
					_itemToggle.ToggleItem(false, -1);
					_nobeliskEmissionMaterial.SetColor(EmissionColor, Color.black);
				}
				return;
			}
			if (_isActive)
			{
				float num = Mathf.PingPong(Time.time * 8f, 1f);
				Color val = blinkColor * Mathf.LinearToGammaSpace(num);
				_nobeliskEmissionMaterial.SetColor(EmissionColor, val);
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (_itemToggle.toggleState && !_isActive)
			{
				_isActive = true;
				TickStart();
			}
			if (_isActive)
			{
				_nobeliskTimer += Time.deltaTime;
				if (_nobeliskTimer >= tickTime)
				{
					_nobeliskTimer = 0f;
					TickEnd();
				}
			}
		}

		private void NobeliskReset()
		{
			//IL_0039: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			_isActive = false;
			_nobeliskTimer = 0f;
			throwLine.SetActive(false);
			_itemToggle.ToggleItem(false, -1);
			_nobeliskEmissionMaterial.SetColor(EmissionColor, Color.black);
			_positionConstraint.SetSources(new List<ConstraintSource>());
			_positionConstraint.translationOffset = Vector3.zero;
			_positionConstraint.constraintActive = false;
			_rb.useGravity = true;
			_rb.constraints = (RigidbodyConstraints)0;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_rb.velocity = Vector3.zero;
				_rb.angularVelocity = Vector3.zero;
			}
		}

		private void TickStart()
		{
			if (SemiFunc.IsMasterClient())
			{
				_photonView.RPC("TickStartRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				TickStartRPC();
			}
		}

		private void TickEnd()
		{
			if (SemiFunc.IsMasterClient())
			{
				_photonView.RPC("TickEndRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				TickEndRPC();
			}
		}

		[PunRPC]
		private void TickStartRPC()
		{
			_isActive = true;
		}

		[PunRPC]
		private void TickEndRPC()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (_itemEquippable.isEquipped)
			{
				return;
			}
			onDetonate.Invoke();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (!SemiFunc.RunIsShop() || isSpawnedGrenade)
				{
					if (!isSpawnedGrenade)
					{
						StatsManager.instance.ItemRemove(_itemAttributes.instanceName);
					}
					_physGrabObjectImpactDetector.destroyDisable = false;
					_physGrabObjectImpactDetector.DestroyObject(true);
				}
				else
				{
					_physGrabObject.Teleport(_nobeliskStartPosition, _nobeliskStartRotation);
				}
			}
			if (SemiFunc.RunIsShop() && !isSpawnedGrenade)
			{
				NobeliskReset();
			}
		}

		public void Attach()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			if (!_isActive || _positionConstraint.constraintActive)
			{
				return;
			}
			Collider[] array = (Collider[])(object)new Collider[10];
			int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 1f, array);
			if (num <= 0)
			{
				return;
			}
			Collider val = null;
			for (int i = 0; i < num; i++)
			{
				if (!((Component)array[i]).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)array[i]).transform == (Object)(object)((Component)this).transform))
				{
					val = array[i];
					break;
				}
			}
			if (!((Object)(object)val == (Object)null))
			{
				_positionConstraint.SetSources(new List<ConstraintSource>());
				_positionConstraint.translationOffset = ((Component)this).transform.position - ((Component)val).transform.position;
				PositionConstraint positionConstraint = _positionConstraint;
				ConstraintSource val2 = default(ConstraintSource);
				((ConstraintSource)(ref val2)).sourceTransform = ((Component)array[0]).transform;
				((ConstraintSource)(ref val2)).weight = 1f;
				positionConstraint.AddSource(val2);
				_positionConstraint.constraintActive = true;
				_rb.useGravity = false;
				_rb.constraints = (RigidbodyConstraints)112;
			}
		}
	}
	public class NobeliskExplosive : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <ThiefLaunch>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NobeliskExplosive <>4__this;

			private Rigidbody <component>5__1;

			private Vector3 <forward>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ThiefLaunch>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<component>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<component>5__1 = ((Component)<>4__this).GetComponent<Rigidbody>();
					<forward>5__2 = ShopManager.instance.extractionPoint.forward;
					<forward>5__2 += Vector3.up * Random.Range(0.1f, 0.5f);
					<forward>5__2 += ShopManager.instance.extractionPoint.right * Random.Range(-0.5f, 0.5f);
					<component>5__1.AddForce(<forward>5__2 * (float)Random.Range(3, 7), (ForceMode)1);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private ParticleScriptExplosion _particleScriptExplosion;

		private void Start()
		{
			_particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			if (SemiFunc.RunIsShop() && SemiFunc.IsMasterClientOrSingleplayer())
			{
				ItemToggle component = ((Component)this).GetComponent<ItemToggle>();
				if (ShopManager.instance.isThief)
				{
					((MonoBehaviour)this).StartCoroutine(ThiefLaunch());
					component.ToggleItem(true, -1);
					((Component)this).GetComponent<ItemGrenade>().isSpawnedGrenade = true;
				}
			}
		}

		[IteratorStateMachine(typeof(<ThiefLaunch>d__2))]
		private IEnumerator ThiefLaunch()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ThiefLaunch>d__2(0)
			{
				<>4__this = this
			};
		}

		public void Explosion()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			_particleScriptExplosion.Spawn(((Component)this).transform.position, 1.2f, 75, 160, 4f, false, false, 1f);
		}
	}
	[BepInPlugin("Bene.SatisfactoryItems", "SatisfactoryItems", "1.0")]
	public class SatisfactoryItems : BaseUnityPlugin
	{
		internal static SatisfactoryItems 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()
		{
		}
	}
}