Decompiled source of FastExtraction v1.0.0

FastExtraction.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FastExtraction")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FastExtraction")]
[assembly: AssemblyTitle("FastExtraction")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
namespace FastExtraction
{
	[BepInPlugin("local.fastextraction", "Fast Extraction", "1.0.0")]
	public class FastExtractionPlugin : BaseUnityPlugin
	{
		private const string PluginGuid = "local.fastextraction";

		private const string PluginName = "Fast Extraction";

		private const string PluginVersion = "1.0.0";

		private const int StateWarning = 4;

		private const int StateComplete = 7;

		private static ConfigEntry<float> _delaySeconds;

		private FieldInfo _currentStateField;

		private FieldInfo _stateTimerField;

		private ExtractionPoint[] _points = Array.Empty<ExtractionPoint>();

		private float _rescanTimer;

		private void Awake()
		{
			_delaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DelaySeconds", 0.1f, "Wie viele Sekunden die 'Übergabe-Pause' des Extraction Points statt der normalen 3 Sekunden dauern soll. 0 = sofort.");
			Type typeFromHandle = typeof(ExtractionPoint);
			_currentStateField = typeFromHandle.GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic);
			_stateTimerField = typeFromHandle.GetField("stateTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (_currentStateField == null || _stateTimerField == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"FastExtraction: Erwartete Felder an ExtractionPoint wurden nicht gefunden. Vermutlich hat sich die Spielversion geändert und der Mod muss angepasst werden.");
			}
		}

		private void Update()
		{
			if (_currentStateField == null || _stateTimerField == null)
			{
				return;
			}
			_rescanTimer -= Time.unscaledDeltaTime;
			if (_rescanTimer <= 0f)
			{
				_points = Object.FindObjectsOfType<ExtractionPoint>();
				_rescanTimer = 2f;
			}
			float value = _delaySeconds.Value;
			ExtractionPoint[] points = _points;
			foreach (ExtractionPoint val in points)
			{
				if (!((Object)(object)val == (Object)null))
				{
					int num = Convert.ToInt32(_currentStateField.GetValue(val));
					if ((num == 7 || num == 4) && (float)_stateTimerField.GetValue(val) > value)
					{
						_stateTimerField.SetValue(val, value);
					}
				}
			}
		}
	}
}