Decompiled source of AbandonedBuildingRemover v0.0.1

AbandonedBuildingRemover/AbandonedBuildingRemover.dll

Decompiled 11 months 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 BepInEx;
using BepInEx.Logging;
using Game;
using Game.Buildings;
using Game.Common;
using Game.Simulation;
using Game.Tools;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Entities;

[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: AssemblyCompany("AbandonedBuildingRemover")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+71fe7362a1062431155c410e2f6345d38ee528ee")]
[assembly: AssemblyProduct("AbandonedBuildingRemover")]
[assembly: AssemblyTitle("AbandonedBuildingRemover")]
[assembly: AssemblyVersion("0.0.1.0")]
[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 Wayz.CS2.AbandonedBuildingRemover
{
	[BepInPlugin("Wayz.CS2.AbandonedBuildingRemover", "Abandoned Building Remover", "0.0.1")]
	public class AbandonedBuildingRemoverMod : BaseUnityPlugin
	{
		public static ManualLogSource GameLogger;

		private void Awake()
		{
			GameLogger = ((BaseUnityPlugin)this).Logger;
			Harmony val = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "AbandonedBuildingRemover_Cities2Harmony");
			IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin AbandonedBuildingRemover 0.0.1 is loaded! Patched methods: " + patchedMethods.Count()));
			foreach (MethodBase item in patchedMethods)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched method: " + item.Module.Name + ":" + item.Name));
			}
		}
	}
	public class AbandonedBuildingRemoverSystem : GameSystemBase
	{
		private EntityCommandBuffer _commandBuffer;

		private EntityQuery _abandonedBuildingQuery;

		protected override void OnCreate()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0037: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			((GameSystemBase)this).OnCreate();
			_commandBuffer = ((SafeCommandBufferSystem)((ComponentSystemBase)this).World.GetOrCreateSystemManaged<EndFrameBarrier>()).CreateCommandBuffer();
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<Abandoned>() };
			val.None = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<Deleted>(),
				ComponentType.ReadOnly<Temp>()
			};
			array[0] = val;
			_abandonedBuildingQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(_abandonedBuildingQuery);
		}

		protected override void OnUpdate()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<Entity> enumerator = ((EntityQuery)(ref _abandonedBuildingQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					((EntityCommandBuffer)(ref _commandBuffer)).AddComponent<Deleted>(current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AbandonedBuildingRemover";

		public const string PLUGIN_NAME = "AbandonedBuildingRemover";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace Wayz.CS2.AbandonedBuildingRemover.Patches
{
	[HarmonyPatch(typeof(DeathCheckSystem), "OnCreate")]
	public static class AbandonedBuildingRemoverSystemInjector
	{
		[HarmonyPrefix]
		public static bool OnCreate_Prefix(DeathCheckSystem __instance)
		{
			((ComponentSystemBase)__instance).World.GetOrCreateSystemManaged<AbandonedBuildingRemoverSystem>();
			((ComponentSystemBase)__instance).World.GetOrCreateSystemManaged<UpdateSystem>().UpdateAt<AbandonedBuildingRemoverSystem>((SystemUpdatePhase)12);
			return true;
		}
	}
}