Decompiled source of SigurdsScrap v1.0.1

SigurdsScrap.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using SigurdsScrap.NetcodePatcher;
using Unity.Netcode;
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 = "")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.github.teamxiaolan.dawnlib")]
[assembly: IgnoresAccessChecksTo("com.github.teamxiaolan.dawnlib.dusk")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("SigurdsScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("[]")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("SigurdsScrap")]
[assembly: AssemblyTitle("SigurdsScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
namespace volatileEmployees
{
	[BepInPlugin("cookiecaker.SigurdsScrap", "SigurdsScrap", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "cookiecaker.SigurdsScrap";

		public const string modName = "SigurdsScrap";

		public const string modVersion = "1.0.0";

		private void Awake()
		{
			NetcodePatcher();
		}

		private void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace SigurdsScrap
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SigurdsScrap";

		public const string PLUGIN_NAME = "SigurdsScrap";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace SigurdsScrap.Content.Items.BoxOfStamps
{
	public class BoxOfStamps : GrabbableObject
	{
		[Header("Stamps visuals")]
		[SerializeField]
		private Animator anim;

		[SerializeField]
		private ParticleSystem particles;

		[Header("Stamps audio")]
		[SerializeField]
		private AudioClip[] fallAudios;

		[Header("Stamps tuning")]
		[SerializeField]
		[Tooltip("What is the chance that stamps will be shaken out each time the box is jiggled while sprinting?")]
		private float jiggleChance = 100f;

		[SerializeField]
		[Tooltip("How much horizontal distance between drops reduces stability?")]
		private float juggleDistance;

		[SerializeField]
		[Tooltip("How much stability is lost from a juggle? At 0% stability, some item value is lost.")]
		private float instability = 0.3f;

		[SerializeField]
		[Tooltip("How much stability is restored per second?")]
		private float stability = 0.05f;

		private int baseValue;

		private int animProgress;

		private float juggleProgress;

		private Vector2 lastDropPos;

		private AudioSource itemAudio;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			itemAudio = ((Component)this).GetComponent<AudioSource>();
		}

		public override void JiggleItemEffect(float audioVolume)
		{
			((GrabbableObject)this).JiggleItemEffect(audioVolume);
			if (AreStampsLoose() && (Object)(object)base.playerHeldBy != (Object)null && base.playerHeldBy.isSprinting && Random.Range(0f, 100f) <= jiggleChance)
			{
				ShakeOutStamps();
			}
		}

		private bool AreStampsLoose()
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				if (StartOfRound.Instance.inShipPhase)
				{
					return false;
				}
				if (StartOfRound.Instance.currentLevelID == 3)
				{
					return false;
				}
			}
			return true;
		}

		private void ShakeOutStamps()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (baseValue == 0 && base.scrapValue > 0)
				{
					baseValue = (int)((float)base.scrapValue * 0.1f);
				}
				if (baseValue > 0 && animProgress < 6)
				{
					SyncStampBoxRpc(baseValue, animProgress + 1);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SyncStampBoxRpc(int syncValue, int syncAnim)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			//IL_0064: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1383430845u, val3, val, (SendTo)6, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, syncValue);
					BytePacker.WriteValueBitPacked(val2, syncAnim);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 1383430845u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					int scrapValue = syncValue * (10 - syncAnim);
					((GrabbableObject)this).SetScrapValue(scrapValue);
					baseValue = syncValue;
					UpdateAnimation(syncAnim);
				}
			}
		}

		private void UpdateAnimation(int progress, bool fresh = true)
		{
			if (fresh)
			{
				RoundManager.PlayRandomClip(itemAudio, fallAudios, true, 0.75f, -1, 1000);
			}
			animProgress = progress;
			anim.SetInteger("Progress", animProgress);
			anim.SetTrigger("Jiggle");
		}

		public override void PlayDropSFX()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).PlayDropSFX();
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.z);
			if (AreStampsLoose())
			{
				float num = Vector2.Distance(val, lastDropPos);
				if (num >= juggleDistance)
				{
					juggleProgress += instability;
					if (juggleProgress >= 1f)
					{
						juggleProgress = 0f;
						ShakeOutStamps();
					}
				}
			}
			lastDropPos = val;
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (juggleProgress > 0f)
			{
				juggleProgress = Mathf.Max(juggleProgress - stability * Time.deltaTime, 0f);
			}
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			return baseValue;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			baseValue = saveData;
			if (baseValue != 0)
			{
				((MonoBehaviour)this).StartCoroutine(SetAnimationAfterDelay((baseValue * 10 - base.scrapValue) / 10, fresh: false));
			}
		}

		private IEnumerator SetAnimationAfterDelay(int progress, bool fresh = true)
		{
			yield return (object)new WaitForFixedUpdate();
			yield return (object)new WaitForEndOfFrame();
			UpdateAnimation(progress, fresh);
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1383430845u, new RpcReceiveHandler(__rpc_handler_1383430845), "SyncStampBoxRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_1383430845(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int syncValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref syncValue);
				int syncAnim = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref syncAnim);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BoxOfStamps)(object)target).SyncStampBoxRpc(syncValue, syncAnim);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "BoxOfStamps";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace SigurdsScrap.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}