Decompiled source of WorkforceRealismEnhancement v0.0.1

RealisticDensity.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using Colossal.Logging;
using Colossal.Serialization.Entities;
using Game;
using Game.Common;
using Game.Companies;
using Game.Modding;
using Game.Prefabs;
using Game.SceneFlow;
using Game.Tools;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using RealisticDensity.Common;
using RealisticDensity.Helper;
using RealisticDensity.Jobs;
using RealisticDensity.Prefabs;
using RealisticDensity.Settings;
using RealisticDensity.Systems;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Scripting;

[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("RealisticDensity")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.6")]
[assembly: AssemblyInformationalVersion("0.0.6+9d84064518ca9f62b88896385295912c0ae7794a")]
[assembly: AssemblyProduct("RealisticDensity")]
[assembly: AssemblyTitle("RealisticDensity")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.6.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 RealisticDensity
{
	public sealed class Mod : IMod
	{
		public const string Name = "RealisticDensity";

		public static Mod Instance { get; set; }

		internal ILog Log { get; private set; }

		public void OnLoad()
		{
			Instance = this;
			Log = LogManager.GetLogger("RealisticDensity", true);
			Log.effectivenessLevel = Level.Debug;
			Log.Info((object)"Loading.");
		}

		public void OnCreateWorld(UpdateSystem updateSystem)
		{
			Log.Info((object)"Add system to world.");
			Debug.Log((object)"Add system to world.");
			updateSystem.UpdateAt<RealisticDensitySystem>((SystemUpdatePhase)12);
		}

		public void OnDispose()
		{
			Log.Info((object)"Mod disposed.");
			Instance = null;
		}
	}
	[BepInPlugin("RealisticDensity", "RealisticDensity", "0.0.6")]
	public class Plugin : BaseUnityPlugin
	{
		private Mod Mod;

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

		public const string PLUGIN_NAME = "RealisticDensity";

		public const string PLUGIN_VERSION = "0.0.6";
	}
}
namespace RealisticDensity.Systems
{
	public class RealisticDensitySystem : GameSystemBase
	{
		public static readonly int kComponentVersion = 1;

		public static readonly int kProductionFactor = 3;

		private EndFrameBarrier Barrier;

		public LocalSettings m_LocalSettings;

		public static LocalSettingsItem Settings;

		public bool m_LocalSettingsLoaded = false;

		private UpdateSpawnablesTypeHandle m_UpdateSpawnablesJobTypeHandle;

		private EntityQuery m_UpdateSpawnablesJobQuery;

		private UpdateCityServicesTypeHandle m_UpdateCityServicesJobTypeHandle;

		private EntityQuery m_UpdateCityServicesJobQuery;

		[Preserve]
		protected override void OnCreate()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			((GameSystemBase)this).OnCreate();
			LoadSettings();
			Settings = m_LocalSettings.Settings;
			Barrier = ((ComponentSystemBase)this).World.GetOrCreateSystemManaged<EndFrameBarrier>();
			m_UpdateCityServicesJobQuery = ((ComponentSystemBase)this).GetEntityQuery(new UpdateCityServicesQuery().Query);
			m_UpdateSpawnablesJobQuery = ((ComponentSystemBase)this).GetEntityQuery(new UpdateSpawnablesQuery().Query);
			((ComponentSystemBase)this).RequireAnyForUpdate((EntityQuery[])(object)new EntityQuery[2] { m_UpdateCityServicesJobQuery, m_UpdateSpawnablesJobQuery });
			Mod.Instance.Log.Info((object)"System created.");
		}

		[Preserve]
		protected override void OnUpdate()
		{
			//IL_001f: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.DisableMod && !((Object)(object)GameManager.instance == (Object)null) && GameModeExtensions.IsGameOrEditor(GameManager.instance.gameMode))
			{
				EntityCommandBuffer val;
				if (!((EntityQuery)(ref m_UpdateCityServicesJobQuery)).IsEmptyIgnoreFilter)
				{
					m_UpdateCityServicesJobTypeHandle.AssignHandles(ref ((SystemBase)this).CheckedStateRef);
					UpdateCityServicesJob updateCityServicesJob = default(UpdateCityServicesJob);
					val = ((SafeCommandBufferSystem)Barrier).CreateCommandBuffer();
					updateCityServicesJob.Ecb = ((EntityCommandBuffer)(ref val)).AsParallelWriter();
					updateCityServicesJob.EntityTypeHandle = m_UpdateCityServicesJobTypeHandle.EntityTypeHandle;
					updateCityServicesJob.WorkplaceDataLookup = m_UpdateCityServicesJobTypeHandle.WorkplaceDataLookup;
					updateCityServicesJob.PowerPlantDataLookup = m_UpdateCityServicesJobTypeHandle.PowerPlantDataLookup;
					updateCityServicesJob.SchoolDataLookup = m_UpdateCityServicesJobTypeHandle.SchoolDataLookup;
					updateCityServicesJob.HospitalDataLookup = m_UpdateCityServicesJobTypeHandle.HospitalDataLookup;
					updateCityServicesJob.PoliceStationDataLookup = m_UpdateCityServicesJobTypeHandle.PoliceStationDataLookup;
					updateCityServicesJob.FireStationDataLookup = m_UpdateCityServicesJobTypeHandle.FireStationDataLookup;
					updateCityServicesJob.CargoTransportStationDataLookup = m_UpdateCityServicesJobTypeHandle.CargoTransportStationDataLookup;
					UpdateCityServicesJob updateCityServicesJob2 = updateCityServicesJob;
					((SystemBase)this).Dependency = JobChunkExtensions.Schedule<UpdateCityServicesJob>(updateCityServicesJob2, m_UpdateCityServicesJobQuery, ((SystemBase)this).Dependency);
					Barrier.AddJobHandleForProducer(((SystemBase)this).Dependency);
				}
				if (!((EntityQuery)(ref m_UpdateSpawnablesJobQuery)).IsEmptyIgnoreFilter)
				{
					m_UpdateSpawnablesJobTypeHandle.AssignHandles(ref ((SystemBase)this).CheckedStateRef);
					UpdateSpawnablesJob updateSpawnablesJob = default(UpdateSpawnablesJob);
					val = ((SafeCommandBufferSystem)Barrier).CreateCommandBuffer();
					updateSpawnablesJob.Ecb = ((EntityCommandBuffer)(ref val)).AsParallelWriter();
					updateSpawnablesJob.EntityHandle = m_UpdateSpawnablesJobTypeHandle.EntityTypeHandle;
					updateSpawnablesJob.WorkplaceDataLookup = m_UpdateSpawnablesJobTypeHandle.WorkplaceDataLookup;
					updateSpawnablesJob.IndustrialProcessDataLookup = m_UpdateSpawnablesJobTypeHandle.IndustrialProcessDataLookup;
					updateSpawnablesJob.IndustrialCompanyDataLookup = m_UpdateSpawnablesJobTypeHandle.IndustrialCompanyDataLookup;
					updateSpawnablesJob.ExtractorCompanyDataLookup = m_UpdateSpawnablesJobTypeHandle.ExtractorCompanyDataLookup;
					updateSpawnablesJob.CommercialCompanyDataLookup = m_UpdateSpawnablesJobTypeHandle.CommercialCompanyDataLookup;
					updateSpawnablesJob.ServiceCompanyDataLookup = m_UpdateSpawnablesJobTypeHandle.ServiceCompanyDataLookup;
					updateSpawnablesJob.StorageLimitDataLookup = m_UpdateSpawnablesJobTypeHandle.StorageLimitDataLookup;
					updateSpawnablesJob.TransportCompanyDataLookup = m_UpdateSpawnablesJobTypeHandle.TransportCompanyDataLookup;
					UpdateSpawnablesJob updateSpawnablesJob2 = updateSpawnablesJob;
					((SystemBase)this).Dependency = JobChunkExtensions.Schedule<UpdateSpawnablesJob>(updateSpawnablesJob2, m_UpdateSpawnablesJobQuery, ((SystemBase)this).Dependency);
					Barrier.AddJobHandleForProducer(((SystemBase)this).Dependency);
				}
			}
		}

		private void LoadSettings()
		{
			try
			{
				m_LocalSettings = new LocalSettings();
				m_LocalSettings.Init();
				m_LocalSettingsLoaded = true;
			}
			catch (Exception ex)
			{
				Mod.Instance.Log.Error((object)("Error loading settings: " + ex.Message));
			}
		}
	}
	public static class WorkforceFactors
	{
		public static Factor4 Commercial = new Factor4(1f, 1.4f, 1.7f, 2f);

		public static Factor4 Office = new Factor4(1f, 1.5f, 2f, 3f);

		public static Factor4 IndustryExtractor = new Factor4(1f, 1.3f, 1.5f, 1.7f);

		public static Factor4 IndustrySelling = new Factor4(1f, 1.4f, 1.7f, 2f);

		public static Factor4 IndustryProcessing = new Factor4(1f, 1.4f, 1.7f, 2f);

		public static Factor4 PowerPlant = new Factor4(1f, 4f, 8f, 10f);

		public static Factor4 School = new Factor4(1f, 3f, 5f, 7f);

		public static Factor4 Hospital = new Factor4(1f, 2f, 4f, 6f);

		public static Factor4 PoliceStation = new Factor4(1f, 1.5f, 2f, 4f);

		public static Factor4 FireStation = new Factor4(1f, 1.5f, 2f, 4f);

		public static Factor4 CargoTransportStation = new Factor4(1f, 2f, 3f, 4f);
	}
}
namespace RealisticDensity.Settings
{
	public class LocalSettings
	{
		private LocalSettingsItem m_Settings;

		public LocalSettingsItem Settings => m_Settings;

		public void Init()
		{
			Load();
		}

		public void Reload()
		{
			Load();
		}

		public async Task Save()
		{
			string assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string filename = "UserSettings.json";
			string fullFilePath = Path.Combine(assemblyDirectory, filename);
			try
			{
				string updatedSettingsJson = JsonConvert.SerializeObject((object)m_Settings);
				using StreamWriter writer = new StreamWriter(fullFilePath, append: false, Encoding.UTF8);
				await writer.WriteAsync(updatedSettingsJson);
			}
			catch (Exception ex)
			{
				Exception e = ex;
				Mod.Instance.Log.Critical((object)("Error saving settings: " + e.Message));
			}
		}

		private void Load()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string path = "UserSettings.json";
			string text = Path.Combine(directoryName, path);
			if (!File.Exists(text))
			{
				Mod.Instance.Log.Info((object)"No user settings found. Use default settings.");
				text = Path.Combine(directoryName, "DefaultSettings.json");
				if (!File.Exists(text))
				{
					Mod.Instance.Log.Critical((object)("Error loading settings: " + text + " does not exist."));
					return;
				}
			}
			else
			{
				Mod.Instance.Log.Critical((object)"User settings successfully loaded.");
			}
			try
			{
				string text2 = File.ReadAllText(text);
				LocalSettingsItem localSettingsItem = JsonConvert.DeserializeObject<LocalSettingsItem>(text2);
				if (localSettingsItem != null)
				{
					m_Settings = localSettingsItem;
				}
			}
			catch (Exception ex)
			{
				Mod.Instance.Log.Critical((object)("Error loading settings: " + ex.Message));
			}
		}
	}
	public class LocalSettingsItem
	{
		public string Version { get; } = "0.0.6";


		public bool DisableMod { get; set; } = false;


		public bool SpawnablesEnabled { get; set; } = true;


		public bool CommercialsEnabled { get; set; } = true;


		public float CommercialsFactor { get; set; } = WorkforceFactors.Commercial.Medium;


		public bool OfficesEnabled { get; set; } = true;


		public float OfficesFactor { get; set; } = WorkforceFactors.Office.Medium;


		public bool IndustriesEnabled { get; set; } = true;


		public float IndustryExtractorFactor { get; set; } = WorkforceFactors.IndustryExtractor.Medium;


		public float IndustryProcessingFactor { get; set; } = WorkforceFactors.IndustryProcessing.Medium;


		public float IndustrySellingFactor { get; set; } = WorkforceFactors.IndustrySelling.Medium;


		public bool IndustryIncreaseStorageCapacity { get; set; } = false;


		public bool IndustryIncreaseMaxTransports { get; set; } = true;


		public bool CityServicesEnabled { get; set; } = true;

	}
	public enum SettingKey
	{
		Version = 0,
		SpawnablesEnabled = 1,
		CommercialsEnabled = 2,
		CommercialsFactor = 3,
		OfficesEnabled = 4,
		OfficesFactor = 5,
		IndustriesEnabled = 6,
		IndustryExtractorFactor = 7,
		IndustryProcessingFactor = 8,
		IndustrySellingFactor = 9,
		IndustryIncreasedStorageCapacity = 10,
		IndustryIncreasedMaxTransporters = 11,
		CityServicesEnabled = 12,
		DisableMod = 90
	}
}
namespace RealisticDensity.Prefabs
{
	public struct RealisticDensityData : IComponentData, IQueryTypeParameter, ISerializable
	{
		public int version;

		public int workplaceData_MaxWorkers;

		public float industrialProcessData_MaxWorkersPerCell;

		public int industrialProcessData_WorkPerUnit;

		public int industrialProcessData_Output_Amount;

		public int storageLimitData_limit;

		public int transportCompanyData_MaxTransports;

		public float serviceCompanyData_MaxWorkersPerCell;

		public int serviceCompanyData_WorkPerUnit;

		public RealisticDensityData()
		{
			version = RealisticDensitySystem.kProductionFactor;
			workplaceData_MaxWorkers = 0;
			industrialProcessData_MaxWorkersPerCell = 0f;
			industrialProcessData_WorkPerUnit = 0;
			industrialProcessData_Output_Amount = 0;
			storageLimitData_limit = 0;
			transportCompanyData_MaxTransports = 0;
			serviceCompanyData_MaxWorkersPerCell = 0f;
			serviceCompanyData_WorkPerUnit = 0;
		}

		public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
		{
			((IWriter)writer).Write(version);
			((IWriter)writer).Write(workplaceData_MaxWorkers);
			((IWriter)writer).Write(industrialProcessData_MaxWorkersPerCell);
			((IWriter)writer).Write(industrialProcessData_WorkPerUnit);
			((IWriter)writer).Write(industrialProcessData_Output_Amount);
			((IWriter)writer).Write(storageLimitData_limit);
			((IWriter)writer).Write(transportCompanyData_MaxTransports);
			((IWriter)writer).Write(serviceCompanyData_MaxWorkersPerCell);
			((IWriter)writer).Write(serviceCompanyData_WorkPerUnit);
		}

		public void Deserialize<TReader>(TReader reader) where TReader : IReader
		{
			((IReader)reader).Read(ref version);
			((IReader)reader).Read(ref workplaceData_MaxWorkers);
			((IReader)reader).Read(ref industrialProcessData_MaxWorkersPerCell);
			((IReader)reader).Read(ref industrialProcessData_WorkPerUnit);
			((IReader)reader).Read(ref industrialProcessData_Output_Amount);
			((IReader)reader).Read(ref storageLimitData_limit);
			((IReader)reader).Read(ref transportCompanyData_MaxTransports);
			((IReader)reader).Read(ref serviceCompanyData_MaxWorkersPerCell);
			((IReader)reader).Read(ref serviceCompanyData_WorkPerUnit);
		}
	}
}
namespace RealisticDensity.Patches
{
	[HarmonyPatch(typeof(SystemOrder))]
	internal class SystemOrderPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(SystemOrder), "Initialize")]
		public static void GetSystemOrder(UpdateSystem updateSystem)
		{
			Mod.Instance.OnCreateWorld(updateSystem);
		}
	}
}
namespace RealisticDensity.Jobs
{
	public struct UpdateCityServicesQuery
	{
		public EntityQueryDesc[] Query;

		public UpdateCityServicesQuery()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_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_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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[1] { ComponentType.ReadOnly<WorkplaceData>() };
			val.Any = (ComponentType[])(object)new ComponentType[6]
			{
				ComponentType.ReadOnly<PowerPlantData>(),
				ComponentType.ReadOnly<SchoolData>(),
				ComponentType.ReadOnly<HospitalData>(),
				ComponentType.ReadOnly<PoliceStationData>(),
				ComponentType.ReadOnly<FireStationData>(),
				ComponentType.ReadOnly<CargoTransportStationData>()
			};
			val.None = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<RealisticDensityData>(),
				ComponentType.Exclude<Deleted>(),
				ComponentType.Exclude<Temp>()
			};
			array[0] = val;
			Query = (EntityQueryDesc[])(object)array;
		}
	}
	public struct UpdateCityServicesTypeHandle
	{
		[ReadOnly]
		public EntityTypeHandle EntityTypeHandle;

		public ComponentLookup<WorkplaceData> WorkplaceDataLookup;

		public ComponentLookup<PowerPlantData> PowerPlantDataLookup;

		public ComponentLookup<SchoolData> SchoolDataLookup;

		public ComponentLookup<HospitalData> HospitalDataLookup;

		public ComponentLookup<PoliceStationData> PoliceStationDataLookup;

		public ComponentLookup<FireStationData> FireStationDataLookup;

		public ComponentLookup<CargoTransportStationData> CargoTransportStationDataLookup;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AssignHandles(ref SystemState state)
		{
			//IL_0003: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//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_0044: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			EntityTypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle();
			WorkplaceDataLookup = ((SystemState)(ref state)).GetComponentLookup<WorkplaceData>(false);
			PowerPlantDataLookup = ((SystemState)(ref state)).GetComponentLookup<PowerPlantData>(false);
			SchoolDataLookup = ((SystemState)(ref state)).GetComponentLookup<SchoolData>(false);
			HospitalDataLookup = ((SystemState)(ref state)).GetComponentLookup<HospitalData>(false);
			PoliceStationDataLookup = ((SystemState)(ref state)).GetComponentLookup<PoliceStationData>(false);
			FireStationDataLookup = ((SystemState)(ref state)).GetComponentLookup<FireStationData>(false);
			CargoTransportStationDataLookup = ((SystemState)(ref state)).GetComponentLookup<CargoTransportStationData>(false);
		}
	}
	public struct UpdateCityServicesJob : IJobChunk
	{
		public ParallelWriter Ecb;

		public EntityTypeHandle EntityTypeHandle;

		public ComponentLookup<WorkplaceData> WorkplaceDataLookup;

		public ComponentLookup<PowerPlantData> PowerPlantDataLookup;

		public ComponentLookup<SchoolData> SchoolDataLookup;

		public ComponentLookup<HospitalData> HospitalDataLookup;

		public ComponentLookup<PoliceStationData> PoliceStationDataLookup;

		public ComponentLookup<FireStationData> FireStationDataLookup;

		public ComponentLookup<CargoTransportStationData> CargoTransportStationDataLookup;

		public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			//IL_0003: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(EntityTypeHandle);
			ChunkEntityEnumerator val = default(ChunkEntityEnumerator);
			((ChunkEntityEnumerator)(ref val))..ctor(useEnabledMask, chunkEnabledMask, ((ArchetypeChunk)(ref chunk)).Count);
			int num = default(int);
			WorkplaceData workplaceData = default(WorkplaceData);
			while (((ChunkEntityEnumerator)(ref val)).NextEntityIndex(ref num))
			{
				Entity val2 = nativeArray[num];
				RealisticDensityData realisticDensityData = default(RealisticDensityData);
				if (WorkplaceDataLookup.TryGetComponent(val2, ref workplaceData))
				{
					UpdateWorkplaceData(val2, workplaceData, ref realisticDensityData, num);
				}
			}
		}

		private void UpdateWorkplaceData(Entity entity, WorkplaceData workplaceData, ref RealisticDensityData realisticDensityData, int entityIndex)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (PowerPlantDataLookup.HasComponent(entity))
			{
				WorkplaceData val = CommonHelper.UpdateWorkplaceData(WorkforceFactors.PowerPlant.Medium, workplaceData, ref realisticDensityData);
				((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(entityIndex, entity, val);
			}
			else if (SchoolDataLookup.HasComponent(entity))
			{
				WorkplaceData val2 = CommonHelper.UpdateWorkplaceData(WorkforceFactors.School.Medium, workplaceData, ref realisticDensityData);
				((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(entityIndex, entity, val2);
			}
			else if (HospitalDataLookup.HasComponent(entity))
			{
				WorkplaceData val3 = CommonHelper.UpdateWorkplaceData(WorkforceFactors.Hospital.Medium, workplaceData, ref realisticDensityData);
				((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(entityIndex, entity, val3);
			}
			else if (PoliceStationDataLookup.HasComponent(entity))
			{
				WorkplaceData val4 = CommonHelper.UpdateWorkplaceData(WorkforceFactors.PoliceStation.Medium, workplaceData, ref realisticDensityData);
				((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(entityIndex, entity, val4);
			}
			else if (FireStationDataLookup.HasComponent(entity))
			{
				WorkplaceData val5 = CommonHelper.UpdateWorkplaceData(WorkforceFactors.FireStation.Medium, workplaceData, ref realisticDensityData);
				((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(entityIndex, entity, val5);
			}
			else if (CargoTransportStationDataLookup.HasComponent(entity))
			{
				WorkplaceData val6 = CommonHelper.UpdateWorkplaceData(WorkforceFactors.CargoTransportStation.Medium, workplaceData, ref realisticDensityData);
				((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(entityIndex, entity, val6);
			}
			((ParallelWriter)(ref Ecb)).AddComponent<RealisticDensityData>(entityIndex, entity, realisticDensityData);
		}

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

		public UpdateSpawnablesQuery()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_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_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0096: 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[1] { ComponentType.ReadOnly<WorkplaceData>() };
			val.Any = (ComponentType[])(object)new ComponentType[5]
			{
				ComponentType.ReadOnly<IndustrialProcessData>(),
				ComponentType.ReadOnly<IndustrialCompanyData>(),
				ComponentType.ReadOnly<ServiceCompanyData>(),
				ComponentType.ReadOnly<StorageLimitData>(),
				ComponentType.ReadOnly<TransportCompanyData>()
			};
			val.None = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<RealisticDensityData>(),
				ComponentType.Exclude<Deleted>(),
				ComponentType.Exclude<Temp>()
			};
			array[0] = val;
			Query = (EntityQueryDesc[])(object)array;
		}
	}
	public struct UpdateSpawnablesTypeHandle
	{
		[ReadOnly]
		public EntityTypeHandle EntityTypeHandle;

		public ComponentLookup<WorkplaceData> WorkplaceDataLookup;

		public ComponentLookup<IndustrialProcessData> IndustrialProcessDataLookup;

		public ComponentLookup<IndustrialCompanyData> IndustrialCompanyDataLookup;

		public ComponentLookup<ExtractorCompanyData> ExtractorCompanyDataLookup;

		public ComponentLookup<CommercialCompanyData> CommercialCompanyDataLookup;

		public ComponentLookup<ServiceCompanyData> ServiceCompanyDataLookup;

		public ComponentLookup<StorageLimitData> StorageLimitDataLookup;

		public ComponentLookup<TransportCompanyData> TransportCompanyDataLookup;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AssignHandles(ref SystemState state)
		{
			//IL_0003: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//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_0044: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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)
			EntityTypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle();
			WorkplaceDataLookup = ((SystemState)(ref state)).GetComponentLookup<WorkplaceData>(false);
			IndustrialProcessDataLookup = ((SystemState)(ref state)).GetComponentLookup<IndustrialProcessData>(false);
			IndustrialCompanyDataLookup = ((SystemState)(ref state)).GetComponentLookup<IndustrialCompanyData>(false);
			ExtractorCompanyDataLookup = ((SystemState)(ref state)).GetComponentLookup<ExtractorCompanyData>(false);
			CommercialCompanyDataLookup = ((SystemState)(ref state)).GetComponentLookup<CommercialCompanyData>(false);
			ServiceCompanyDataLookup = ((SystemState)(ref state)).GetComponentLookup<ServiceCompanyData>(false);
			StorageLimitDataLookup = ((SystemState)(ref state)).GetComponentLookup<StorageLimitData>(false);
			TransportCompanyDataLookup = ((SystemState)(ref state)).GetComponentLookup<TransportCompanyData>(false);
		}
	}
	public struct UpdateSpawnablesJob : IJobChunk
	{
		public ParallelWriter Ecb;

		public EntityTypeHandle EntityHandle;

		public ComponentLookup<WorkplaceData> WorkplaceDataLookup;

		public ComponentLookup<IndustrialProcessData> IndustrialProcessDataLookup;

		public ComponentLookup<IndustrialCompanyData> IndustrialCompanyDataLookup;

		public ComponentLookup<ExtractorCompanyData> ExtractorCompanyDataLookup;

		public ComponentLookup<CommercialCompanyData> CommercialCompanyDataLookup;

		public ComponentLookup<ServiceCompanyData> ServiceCompanyDataLookup;

		public ComponentLookup<StorageLimitData> StorageLimitDataLookup;

		public ComponentLookup<TransportCompanyData> TransportCompanyDataLookup;

		public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			LocalSettingsItem settings = RealisticDensitySystem.Settings;
			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);
			WorkplaceData workplaceData = default(WorkplaceData);
			StorageLimitData val5 = default(StorageLimitData);
			TransportCompanyData val7 = default(TransportCompanyData);
			while (((ChunkEntityEnumerator)(ref val)).NextEntityIndex(ref num))
			{
				Entity val2 = nativeArray[num];
				RealisticDensityData realisticDensityData = default(RealisticDensityData);
				if (!WorkplaceDataLookup.TryGetComponent(val2, ref workplaceData))
				{
					continue;
				}
				if (settings.IndustriesEnabled && IsIndustrialCompany(val2, out var industrialProcessData))
				{
					float factor = (ExtractorCompanyDataLookup.HasComponent(val2) ? settings.IndustryExtractorFactor : settings.IndustryProcessingFactor);
					WorkplaceData val3 = CommonHelper.UpdateWorkplaceData(factor, workplaceData, ref realisticDensityData);
					((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(num, val2, val3);
					IndustrialProcessData val4 = industrialProcessData;
					realisticDensityData.industrialProcessData_MaxWorkersPerCell = industrialProcessData.m_MaxWorkersPerCell;
					float value = CommonHelper.CalculateProductionFactor(factor, industrialProcessData.m_MaxWorkersPerCell);
					val4.m_MaxWorkersPerCell += Calc.DecimalFloat(value);
					realisticDensityData.industrialProcessData_WorkPerUnit = industrialProcessData.m_WorkPerUnit;
					float num2 = CommonHelper.CalculateProductionFactor(factor, industrialProcessData.m_WorkPerUnit);
					val4.m_WorkPerUnit += (int)math.round(num2);
					((ParallelWriter)(ref Ecb)).SetComponent<IndustrialProcessData>(num, val2, val4);
					if (settings.IndustryIncreaseStorageCapacity && StorageLimitDataLookup.TryGetComponent(val2, ref val5))
					{
						StorageLimitData val6 = val5;
						realisticDensityData.storageLimitData_limit = val5.m_Limit;
						float num3 = CommonHelper.CalculateProductionFactor(factor, val5.m_Limit);
						val6.m_Limit += (int)math.round(num3);
						((ParallelWriter)(ref Ecb)).SetComponent<StorageLimitData>(num, val2, val6);
					}
					if (TransportCompanyDataLookup.TryGetComponent(val2, ref val7))
					{
						TransportCompanyData val8 = val7;
						realisticDensityData.transportCompanyData_MaxTransports = val7.m_MaxTransports;
						float num4 = CommonHelper.CalculateProductionFactor(factor, val7.m_MaxTransports);
						val8.m_MaxTransports += (int)math.round(num4);
						((ParallelWriter)(ref Ecb)).SetComponent<TransportCompanyData>(num, val2, val8);
					}
					((ParallelWriter)(ref Ecb)).AddComponent<RealisticDensityData>(num, val2, realisticDensityData);
				}
				if (settings.CommercialsEnabled && IsCommercialCompany(val2, out var serviceCompanyData))
				{
					float high = WorkforceFactors.Commercial.High;
					WorkplaceData val9 = CommonHelper.UpdateWorkplaceData(high, workplaceData, ref realisticDensityData);
					((ParallelWriter)(ref Ecb)).SetComponent<WorkplaceData>(num, val2, val9);
					ServiceCompanyData val10 = serviceCompanyData;
					realisticDensityData.serviceCompanyData_MaxWorkersPerCell = serviceCompanyData.m_MaxWorkersPerCell;
					float value2 = CommonHelper.CalculateProductionFactor(high, serviceCompanyData.m_MaxWorkersPerCell);
					val10.m_MaxWorkersPerCell += Calc.DecimalFloat(value2);
					realisticDensityData.serviceCompanyData_WorkPerUnit = serviceCompanyData.m_WorkPerUnit;
					float num5 = CommonHelper.CalculateProductionFactor(high, serviceCompanyData.m_WorkPerUnit);
					val10.m_WorkPerUnit += (int)math.round(num5);
					((ParallelWriter)(ref Ecb)).SetComponent<ServiceCompanyData>(num, val2, val10);
					((ParallelWriter)(ref Ecb)).AddComponent<RealisticDensityData>(num, val2, realisticDensityData);
				}
			}
		}

		private bool IsIndustrialCompany(Entity entity, out IndustrialProcessData industrialProcessData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			if (IndustrialCompanyDataLookup.HasComponent(entity) && IndustrialProcessDataLookup.TryGetComponent(entity, ref industrialProcessData))
			{
				return true;
			}
			industrialProcessData = default(IndustrialProcessData);
			return false;
		}

		private bool IsCommercialCompany(Entity entity, out ServiceCompanyData serviceCompanyData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			if (CommercialCompanyDataLookup.HasComponent(entity) && ServiceCompanyDataLookup.TryGetComponent(entity, ref serviceCompanyData))
			{
				return true;
			}
			serviceCompanyData = default(ServiceCompanyData);
			return false;
		}

		void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
		{
			Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask);
		}
	}
}
namespace RealisticDensity.Helper
{
	internal static class CommonHelper
	{
		public static float CalculateProductionFactor(float factor, float of)
		{
			return (of * factor - of) / (float)RealisticDensitySystem.kProductionFactor;
		}

		public static WorkplaceData UpdateWorkplaceData(float factor, WorkplaceData workplaceData, ref RealisticDensityData realisticDensityData)
		{
			//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_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0026: 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)
			WorkplaceData val = workplaceData;
			realisticDensityData.workplaceData_MaxWorkers = workplaceData.m_MaxWorkers;
			val.m_MaxWorkers = (int)math.round((float)val.m_MaxWorkers * factor);
			return val;
		}
	}
}
namespace RealisticDensity.Common
{
	public static class Calc
	{
		public static float DecimalFloat(float value)
		{
			return (float)Math.Round(value, 2);
		}
	}
	public struct Factor4
	{
		public float Default;

		public float Low;

		public float Medium;

		public float High;

		public Factor4(float @default, float low, float medium, float high)
		{
			Default = @default;
			Low = low;
			Medium = medium;
			High = high;
		}
	}
}