Decompiled source of NoUniqueBuildings v1.0.0

NoUniqueBuildings.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Colossal.Logging;
using Colossal.Serialization.Entities;
using Game;
using Game.Common;
using Game.Modding;
using Game.Objects;
using Game.Prefabs;
using Game.Tools;
using Game.UI.InGame;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NoUniqueBuildings.Jobs;
using NoUniqueBuildings.Systems;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Scripting;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoUniqueBuildings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b2431c6596d4df9730e5416499ef0c69fa256f7b")]
[assembly: AssemblyProduct("NoUniqueBuildings")]
[assembly: AssemblyTitle("NoUniqueBuildings")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NoUniqueBuildings
{
	public sealed class Mod : IMod
	{
		public const string Name = "NoUniqueBuildings";

		public static Mod Instance { get; set; }

		internal ILog Log { get; private set; }

		public void OnLoad()
		{
			Instance = this;
			Log = LogManager.GetLogger("NoUniqueBuildings");
			Log.Info((object)"Loading.");
		}

		public void OnDispose()
		{
			Debug.Log((object)"[NoUniqueBuildings]: Mod disposed.");
			Instance = null;
		}

		public void OnLoad(UpdateSystem updateSystem)
		{
			Debug.Log((object)"[NoUniqueBuildings]: Add system to world.");
			updateSystem.UpdateAt<NoUniqueBuildingsSystem>((SystemUpdatePhase)9);
		}
	}
	[BepInPlugin("NoUniqueBuildings", "NoUniqueBuildings", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Mod Mod;

		private void Awake()
		{
			Mod = new Mod();
			Mod.OnLoad();
			Debug.Log((object)"[NoUniqueBuildings]: Loading Harmony patches.");
			MethodBase[] array = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "NoUniqueBuildings_Cities2Harmony").GetPatchedMethods().ToArray();
			Debug.Log((object)("[NoUniqueBuildings]: Plugin NoUniqueBuildings is loaded! Patched methods " + array.Length));
			MethodBase[] array2 = array;
			foreach (MethodBase methodBase in array2)
			{
				Debug.Log((object)("[NoUniqueBuildings]: Patched method: " + methodBase.Module.Name + ":" + methodBase.Name));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoUniqueBuildings";

		public const string PLUGIN_NAME = "NoUniqueBuildings";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace NoUniqueBuildings.Systems
{
	public class NoUniqueBuildingsSystem : GameSystemBase
	{
		private UpdateSignatureBuildingsTypeHandle m_UpdateSignatureBuildingsTypeHandle;

		private EntityQuery m_UpdateSignatureBuildingsJobQuery;

		[Preserve]
		protected override void OnCreate()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			((GameSystemBase)this).OnCreate();
			m_UpdateSignatureBuildingsJobQuery = ((ComponentSystemBase)this).GetEntityQuery(new UpdateSignatureBuildingsQuery().Query);
			Debug.Log((object)"[NoUniqueBuildings]: System created.");
		}

		protected override void OnGameLoadingComplete(Purpose purpose, GameMode mode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_004e: 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_006a: 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)
			((GameSystemBase)this).OnGameLoadingComplete(purpose, mode);
			if (GameModeExtensions.IsGameOrEditor(mode) && !((EntityQuery)(ref m_UpdateSignatureBuildingsJobQuery)).IsEmptyIgnoreFilter)
			{
				Debug.Log((object)"[NoUniqueBuildingsSystem]: Update NoUniqueBuildingsSystem.");
				m_UpdateSignatureBuildingsTypeHandle.AssignHandles(ref ((SystemBase)this).CheckedStateRef);
				UpdateSignatureBuildingsJob updateSignatureBuildingsJob = default(UpdateSignatureBuildingsJob);
				updateSignatureBuildingsJob.EntityHandle = m_UpdateSignatureBuildingsTypeHandle.EntityTypeHandle;
				updateSignatureBuildingsJob.PlaceableObjectDataLookup = m_UpdateSignatureBuildingsTypeHandle.PlaceableObjectDataLookup;
				UpdateSignatureBuildingsJob updateSignatureBuildingsJob2 = updateSignatureBuildingsJob;
				((SystemBase)this).Dependency = JobChunkExtensions.Schedule<UpdateSignatureBuildingsJob>(updateSignatureBuildingsJob2, m_UpdateSignatureBuildingsJobQuery, ((SystemBase)this).Dependency);
			}
		}

		[Preserve]
		protected override void OnUpdate()
		{
		}

		protected override void OnDestroy()
		{
			((GameSystemBase)this).OnDestroy();
		}
	}
}
namespace NoUniqueBuildings.Patches
{
	[HarmonyPatch(typeof(UniqueAssetTrackingSystem), "OnUpdate")]
	internal class UniqueAssetTrackingSystemPatches
	{
		[HarmonyPrefix]
		public static bool Prefix(UniqueAssetTrackingSystem __instance)
		{
			return false;
		}
	}
}
namespace NoUniqueBuildings.Jobs
{
	internal struct ResetSignatureBuildingsQuery
	{
		public EntityQueryDesc[] Query;

		public ResetSignatureBuildingsQuery()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<BuildingData>(),
				ComponentType.ReadWrite<PlaceableObjectData>(),
				ComponentType.ReadOnly<SignatureBuildingData>()
			};
			val.None = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.Exclude<Updated>(),
				ComponentType.Exclude<Deleted>(),
				ComponentType.Exclude<Temp>()
			};
			array[0] = val;
			Query = (EntityQueryDesc[])(object)array;
		}
	}
	public struct ResetSignatureBuildingsTypeHandle
	{
		[ReadOnly]
		public EntityTypeHandle EntityTypeHandle;

		public ComponentLookup<PlaceableObjectData> PlaceableObjectDataLookup;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AssignHandles(ref SystemState state)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			EntityTypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle();
			PlaceableObjectDataLookup = ((SystemState)(ref state)).GetComponentLookup<PlaceableObjectData>(false);
		}
	}
	public struct ResetSignatureBuildingsJob : IJobChunk
	{
		public EntityTypeHandle EntityHandle;

		public ComponentLookup<PlaceableObjectData> PlaceableObjectDataLookup;

		public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(EntityHandle);
			ChunkEntityEnumerator val = default(ChunkEntityEnumerator);
			((ChunkEntityEnumerator)(ref val))..ctor(useEnabledMask, chunkEnabledMask, ((ArchetypeChunk)(ref chunk)).Count);
			int num = default(int);
			while (((ChunkEntityEnumerator)(ref val)).NextEntityIndex(ref num))
			{
				Entity val2 = nativeArray[num];
				PlaceableObjectData val3 = PlaceableObjectDataLookup[val2];
				ref PlacementFlags flags = ref val3.m_Flags;
				flags = (PlacementFlags)((uint)flags | 0x200u);
				PlaceableObjectDataLookup[val2] = val3;
			}
		}

		void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask);
		}
	}
	internal struct UpdateSignatureBuildingsQuery
	{
		public EntityQueryDesc[] Query;

		public UpdateSignatureBuildingsQuery()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0065: 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)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<BuildingData>(),
				ComponentType.ReadWrite<PlaceableObjectData>()
			};
			val.Any = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<SignatureBuildingData>(),
				ComponentType.ReadOnly<UniqueObjectData>()
			};
			val.None = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.Exclude<Updated>(),
				ComponentType.Exclude<Deleted>(),
				ComponentType.Exclude<Temp>()
			};
			array[0] = val;
			Query = (EntityQueryDesc[])(object)array;
		}
	}
	public struct UpdateSignatureBuildingsTypeHandle
	{
		[ReadOnly]
		public EntityTypeHandle EntityTypeHandle;

		public ComponentLookup<PlaceableObjectData> PlaceableObjectDataLookup;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AssignHandles(ref SystemState state)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			EntityTypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle();
			PlaceableObjectDataLookup = ((SystemState)(ref state)).GetComponentLookup<PlaceableObjectData>(false);
		}
	}
	public struct UpdateSignatureBuildingsJob : IJobChunk
	{
		public EntityTypeHandle EntityHandle;

		public ComponentLookup<PlaceableObjectData> PlaceableObjectDataLookup;

		public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(EntityHandle);
			ChunkEntityEnumerator val = default(ChunkEntityEnumerator);
			((ChunkEntityEnumerator)(ref val))..ctor(useEnabledMask, chunkEnabledMask, ((ArchetypeChunk)(ref chunk)).Count);
			int num = default(int);
			while (((ChunkEntityEnumerator)(ref val)).NextEntityIndex(ref num))
			{
				Entity val2 = nativeArray[num];
				PlaceableObjectData val3 = PlaceableObjectDataLookup[val2];
				ref PlacementFlags flags = ref val3.m_Flags;
				flags = (PlacementFlags)((uint)flags & 0xFFFFFDFFu);
				PlaceableObjectDataLookup[val2] = val3;
			}
		}

		void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask);
		}
	}
}