Decompiled source of CounterFix4Bat v0.1.0

CounterFix4Bat.dll

Decompiled 7 hours 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CounterFix4Bat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("CounterFix4Bat")]
[assembly: AssemblyTitle("CounterFix4Bat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CounterFix4Bat
{
	public static class PersistRules
	{
		public static bool ShouldMark(bool despawnAllItems, bool isDestroyedOrNull, bool deactivated, bool isHeld, bool isInShipRoom, bool isInElevator)
		{
			if (despawnAllItems || isDestroyedOrNull || deactivated)
			{
				return false;
			}
			return isHeld || isInShipRoom || isInElevator;
		}
	}
	[BepInPlugin("chonkzilla.counterfix4bat", "CounterFix4Bat", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("chonkzilla.counterfix4bat");

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony.PatchAll();
			Log.LogInfo((object)"CounterFix4Bat 0.1.0 loaded. Restores the persist flag after DespawnPropsAtEndOfRound so the results screen counts only today's haul.");
		}
	}
	public static class PluginInfo
	{
		public const string Guid = "chonkzilla.counterfix4bat";

		public const string Name = "CounterFix4Bat";

		public const string Version = "0.1.0";

		public const string QuotaOverhaulGuid = "luciusoflegend.lethalcompany.quotaoverhaul";
	}
}
namespace CounterFix4Bat.Patches
{
	[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
	internal static class DespawnPropsAtEndOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(bool despawnAllItems)
		{
			if (despawnAllItems)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogDebug((object)"Skipping persist mark because despawnAllItems is true.");
				}
				return;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			foreach (GrabbableObject val in array)
			{
				bool flag = (Object)(object)val == (Object)null;
				if (!PersistRules.ShouldMark(despawnAllItems: false, flag, !flag && val.deactivated, !flag && val.isHeld, !flag && val.isInShipRoom, !flag && val.isInElevator))
				{
					num3++;
					continue;
				}
				if (val.scrapPersistedThroughRounds)
				{
					num2++;
					continue;
				}
				val.scrapPersistedThroughRounds = true;
				num++;
			}
			ManualLogSource log2 = Plugin.Log;
			if (log2 != null)
			{
				log2.LogInfo((object)$"Marked {num} remaining ship item(s) as persisted through rounds ({num2} already marked, {num3} skipped).");
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}