Decompiled source of Ndrangheta v1.0.7

TheMob.Il2CPP.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using HarmonyLib;
using Il2CppFishNet.Connection;
using Il2CppFishNet.Object;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.Audio;
using Il2CppScheduleOne.AvatarFramework;
using Il2CppScheduleOne.AvatarFramework.Emotions;
using Il2CppScheduleOne.AvatarFramework.Equipping;
using Il2CppScheduleOne.Building;
using Il2CppScheduleOne.Cartel;
using Il2CppScheduleOne.Combat;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Dialogue;
using Il2CppScheduleOne.Doors;
using Il2CppScheduleOne.Dragging;
using Il2CppScheduleOne.Economy;
using Il2CppScheduleOne.EntityFramework;
using Il2CppScheduleOne.Equipping;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.Interaction;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.Messaging;
using Il2CppScheduleOne.Money;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.NPCs.Behaviour;
using Il2CppScheduleOne.NPCs.CharacterClasses;
using Il2CppScheduleOne.NPCs.Relation;
using Il2CppScheduleOne.NPCs.Responses;
using Il2CppScheduleOne.NPCs.Schedules;
using Il2CppScheduleOne.Noise;
using Il2CppScheduleOne.ObjectScripts;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.Persistence.Datas;
using Il2CppScheduleOne.Persistence.Loaders;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.PlayerScripts.Health;
using Il2CppScheduleOne.Police;
using Il2CppScheduleOne.Product;
using Il2CppScheduleOne.Product.Packaging;
using Il2CppScheduleOne.Property;
using Il2CppScheduleOne.Quests;
using Il2CppScheduleOne.Storage;
using Il2CppScheduleOne.Tiles;
using Il2CppScheduleOne.Tools;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Compass;
using Il2CppScheduleOne.UI.Phone;
using Il2CppScheduleOne.UI.Phone.Messages;
using Il2CppScheduleOne.Vehicles;
using Il2CppScheduleOne.Vehicles.Modification;
using Il2CppScheduleOne.Vision;
using Il2CppSteamworks;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Ndrangheta;
using Ndrangheta.Compat;
using Ndrangheta.Families;
using Ndrangheta.Framework;
using Ndrangheta.Helper;
using Ndrangheta.Messaging;
using Ndrangheta.NPCs;
using Ndrangheta.Quests;
using S1API.Entities;
using S1API.Entities.Appearances.AccessoryFields;
using S1API.Entities.Appearances.BodyLayerFields;
using S1API.Entities.Appearances.CustomizationFields;
using S1API.Entities.Appearances.FaceLayerFields;
using S1API.Internal.Abstraction;
using S1API.Quests;
using S1API.Quests.Constants;
using S1API.Quests.Identifiers;
using S1API.Saveables;
using S1API.Vehicles;
using SteamNetworkLib;
using SteamNetworkLib.Events;
using SteamNetworkLib.Sync;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonOptionalDependencies(new string[] { "SteamNetworkLib" })]
[assembly: AssemblyTitle("Ndrangheta")]
[assembly: AssemblyDescription("Schedule I MelonLoader Mod")]
[assembly: AssemblyCompany("Virtunerd")]
[assembly: AssemblyProduct("Ndrangheta")]
[assembly: AssemblyCopyright("Copyright (c) Virtunerd 2026")]
[assembly: ComVisible(false)]
[assembly: Guid("1197b5da-0218-4ec8-8548-e328bd9c8b5f")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: MelonInfo(typeof(NdranghetaMod), "Ndrangheta", "1.0.7", "Virtunerd", null)]
[assembly: MelonGame(null, "Schedule I")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: AssemblyInformationalVersion("1.0.7")]
[assembly: AssemblyVersion("1.0.7.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 Ndrangheta
{
	internal static class ImguiCompat
	{
		private static GUIStyle _style;

		internal static void DrawTexture(Rect position, Texture2D image)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Blit(position, image);
		}

		internal static void DrawTexture(Rect position, Texture2D image, ScaleMode scaleMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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)
			Blit(Fit(position, image, scaleMode), image);
		}

		private static Rect Fit(Rect position, Texture2D image, ScaleMode scaleMode)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0018: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_004d: 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_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)
			if ((Object)(object)image == (Object)null || (int)scaleMode == 0)
			{
				return position;
			}
			float num = ((Texture)image).width;
			float num2 = ((Texture)image).height;
			if (num <= 0f || num2 <= 0f)
			{
				return position;
			}
			float num3 = (((int)scaleMode == 2) ? Mathf.Min(((Rect)(ref position)).width / num, ((Rect)(ref position)).height / num2) : Mathf.Max(((Rect)(ref position)).width / num, ((Rect)(ref position)).height / num2));
			float num4 = num * num3;
			float num5 = num2 * num3;
			return new Rect(((Rect)(ref position)).x + (((Rect)(ref position)).width - num4) * 0.5f, ((Rect)(ref position)).y + (((Rect)(ref position)).height - num5) * 0.5f, num4, num5);
		}

		private static void Blit(Rect position, Texture2D image)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0059: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if ((Object)(object)image == (Object)null)
			{
				return;
			}
			Event current = Event.current;
			if (current != null && (int)current.type == 7)
			{
				if (_style == null)
				{
					_style = new GUIStyle();
				}
				_style.normal.background = image;
				Color backgroundColor = GUI.backgroundColor;
				GUI.backgroundColor = Color.white;
				_style.Draw(position, false, false, false, false);
				GUI.backgroundColor = backgroundColor;
			}
		}
	}
	public class NdranghetaMod : MelonMod
	{
		private const string MAIN_SCENE_NAME = "Main";

		private bool _inMainScene;

		private bool _npcSpawned;

		private float _startupTimer;

		private float _saveDataRefreshTimer;

		private float _clientPresenceTimer;

		private bool _netDiagDone;

		private float _netDiagTimer;

		private bool _wasAuthority;

		private bool _demotedToClient;

		private static bool _netLayerDown;

		private static bool _s1apiMissing;

		private static float _staleMarkerSweepAt;

		private static float _depositoRescueAt;

		private static float _depositoRescueUntil;

		private static bool _depositoReloadDetected;

		private static float _depositoForceDismissAt;

		private static bool _depositoForcedDismiss;

		private static float _depositoLastScreenUpAt;

		private static float _clientLoadStuckSince;

		private static float _clientLoadDiagAt;

		private static bool _clientLoadForced;

		private static float _clientLoadReqAt;

		private static int _clientLoadReqs;

		private static float _clientGatesOkSince;

		private const float CLIENT_LOAD_GATES_GRACE = 3f;

		private const float CLIENT_LOAD_FORCE_SECONDS = 18f;

		private static float _chatRestoreAt;

		private const float CHAT_INTERFACE_RESTORE_GRACE = 1.5f;

		private const float NPC_SPAWN_DELAY = 3f;

		private const float SAVE_DATA_REFRESH_INTERVAL = 1f;

		private bool _clientDonSeenLogged;

		private bool _clientDonMissingLogged;

		private bool _clientQuestStarted;

		private bool _clientMetSent;

		private bool _clientChatMenuBuilt;

		private int _clientChatMenuState = -1;

		private bool _clientConsentShown;

		private static bool _clientBattAnnounced;

		private static bool _clientBattAttackSent;

		private static int _coopPaySeqApplied = -1;

		private static string _clientDropoffSentFor;

		private static string _clientShortCashSmsFor;

		private static bool _s1apiRedirectLogged;

		private static GUIStyle _s1apiWarnStyle;

		private void DemoteToClient()
		{
			if (_demotedToClient)
			{
				return;
			}
			_demotedToClient = true;
			NDLog.Debug("Authority lost (became FishNet client) — switching to client mode, cleaning transient host state.");
			try
			{
				IntroController.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				TerritoryHandover.ForceReset();
			}
			catch
			{
			}
			try
			{
				PizzoJobManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				RankManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				DailyTribute.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				BattesimoController.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				ConsentController.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				LuckyTargetPicker.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				LuckyBrawlManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				LaBombaManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				RapimentoManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				TortureManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				GangBattleManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				GangWarManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				FearState.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				FaidaState.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				CarBombManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				InformantiManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				RealEstateManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				PropVisuals.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				MobTeleport.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				MirrorRenderer.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				VisualMirror.Reset();
			}
			catch
			{
			}
			try
			{
				TeleportMirror.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				FamigliaReskinSync.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				Sfx.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				MobFamilyRegistry.ResetAllForSceneReload();
			}
			catch
			{
			}
			try
			{
				LuckyCombatDriver.Reset();
			}
			catch
			{
			}
			_staleMarkerSweepAt = Time.time + 12f;
			ArmDepositoReloadRescue();
			_clientLoadStuckSince = 0f;
			_clientLoadDiagAt = 0f;
			_clientLoadForced = false;
			_clientLoadReqAt = 0f;
			_clientLoadReqs = 0;
			_clientGatesOkSince = 0f;
			_chatRestoreAt = 0f;
			try
			{
				ClientActionNet.Reset();
			}
			catch
			{
			}
			_clientDropoffSentFor = null;
			_clientShortCashSmsFor = null;
			_coopPaySeqApplied = -1;
			_clientBattAnnounced = false;
			_clientBattAttackSent = false;
			try
			{
				BattesimoQuest.ClearInstanceForNext();
			}
			catch
			{
			}
			_clientConsentShown = false;
			_clientMetSent = false;
			try
			{
				ClientIntroQuest.ResetForSceneReload();
			}
			catch
			{
			}
			_clientChatMenuBuilt = false;
			_clientChatMenuState = -1;
			try
			{
				DonSalvatoreNPC.ResetForDemotion();
			}
			catch
			{
			}
			try
			{
				LuckyNPC.ResetForDemotion();
			}
			catch
			{
			}
			try
			{
				NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
				NPCRelationData val = ((nPC != null) ? nPC.RelationData : null);
				if (val != null && val.Unlocked)
				{
					val.Unlocked = false;
					NDLog.Debug("Don contact re-locked (client demotion).");
				}
			}
			catch
			{
			}
			_npcSpawned = false;
			_startupTimer = 0f;
		}

		private static int GetCurrentJobCut()
		{
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return 0;
				}
				return (current.Type == PizzoJobManager.JobType.Pizzo || current.Type == PizzoJobManager.JobType.Trasporto) ? current.CutAmount : 0;
			}
			catch
			{
				return 0;
			}
		}

		private static int GetCurrentJobDropReward()
		{
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return 0;
				}
				return (current.Type == PizzoJobManager.JobType.Trasporto || current.Type == PizzoJobManager.JobType.Carico) ? current.RewardAmount : 0;
			}
			catch
			{
				return 0;
			}
		}

		private static void GetCurrentStepSync(out string entryText, out string entryPoi)
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			entryText = "";
			entryPoi = "";
			try
			{
				Quest val = null;
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return;
				}
				switch (current.Type)
				{
				case PizzoJobManager.JobType.Pizzo:
					val = (Quest)(object)PizzoQuest.Instance;
					break;
				case PizzoJobManager.JobType.Trasporto:
					val = (Quest)(object)TrasportoQuest.Instance;
					break;
				case PizzoJobManager.JobType.Contratto:
					val = (Quest)(object)ContrattoQuest.Instance;
					break;
				case PizzoJobManager.JobType.Carico:
					val = (Quest)(object)CaricoQuest.Instance;
					break;
				}
				if (val == null)
				{
					return;
				}
				List<QuestEntry> questEntries = val.QuestEntries;
				if (questEntries == null)
				{
					return;
				}
				for (int i = 0; i < questEntries.Count; i++)
				{
					QuestEntry val2 = questEntries[i];
					if (val2 == null)
					{
						continue;
					}
					bool flag = false;
					try
					{
						flag = (int)val2.State == 1;
					}
					catch
					{
					}
					if (!flag)
					{
						continue;
					}
					try
					{
						entryText = val2.Title ?? "";
					}
					catch
					{
					}
					try
					{
						Vector3 pOIPosition = val2.POIPosition;
						if (((Vector3)(ref pOIPosition)).sqrMagnitude > 1f)
						{
							entryPoi = string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", pOIPosition.x, pOIPosition.y, pOIPosition.z);
						}
						break;
					}
					catch
					{
						break;
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("GetCurrentStepSync: " + ex.Message);
			}
		}

		private static string GetCurrentJobCode()
		{
			try
			{
				PizzoJobManager.Phase currentPhase = PizzoJobManager.CurrentPhase;
				if (currentPhase == PizzoJobManager.Phase.Idle || currentPhase == PizzoJobManager.Phase.Cooldown)
				{
					return "";
				}
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return "";
				}
				return current.Type switch
				{
					PizzoJobManager.JobType.Contratto => current.LuckyDispatched ? "lc" : "c", 
					PizzoJobManager.JobType.Pizzo => "p", 
					PizzoJobManager.JobType.Trasporto => "t", 
					PizzoJobManager.JobType.Carico => "ca", 
					_ => "", 
				};
			}
			catch
			{
				return "";
			}
		}

		private static string GetCurrentJobTarget()
		{
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return "";
				}
				if (current.Type == PizzoJobManager.JobType.Contratto)
				{
					return current.LuckyDispatched ? (current.LuckyTargetName ?? "") : (current.ContrattoTargetName ?? "");
				}
				return "";
			}
			catch
			{
				return "";
			}
		}

		private static string GetCurrentJobTargetPos()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null || current.Type != PizzoJobManager.JobType.Contratto)
				{
					return "";
				}
				NPC activeContrattoTarget = PizzoJobManager.ActiveContrattoTarget;
				if ((Object)(object)activeContrattoTarget == (Object)null || (Object)(object)((Component)activeContrattoTarget).transform == (Object)null)
				{
					return "";
				}
				Vector3 position = ((Component)activeContrattoTarget).transform.position;
				return string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", position.x, position.y, position.z);
			}
			catch
			{
				return "";
			}
		}

		private static string GetBossMarkerPos()
		{
			//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_002c: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Vector3 pos = BossMarkerSync.Pos;
				if (((Vector3)(ref pos)).sqrMagnitude < 1f)
				{
					return "";
				}
				return string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", pos.x, pos.y, pos.z);
			}
			catch
			{
				return "";
			}
		}

		private static string FmtVec(Vector3 p)
		{
			//IL_0025: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref p)).sqrMagnitude < 1f)
			{
				return "";
			}
			return string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", p.x, p.y, p.z);
		}

		private static Vector3 ParseVec3(string s)
		{
			//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_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_0095: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (string.IsNullOrEmpty(s))
				{
					return Vector3.zero;
				}
				string[] array = s.Split(';');
				if (array.Length != 3)
				{
					return Vector3.zero;
				}
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				NumberStyles style = NumberStyles.Float;
				if (float.TryParse(array[0], style, invariantCulture, out var result) && float.TryParse(array[1], style, invariantCulture, out var result2) && float.TryParse(array[2], style, invariantCulture, out var result3))
				{
					return new Vector3(result, result2, result3);
				}
			}
			catch
			{
			}
			return Vector3.zero;
		}

		private void ClientPresenceTick()
		{
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			_clientPresenceTimer -= Time.deltaTime;
			if (_clientPresenceTimer > 0f)
			{
				return;
			}
			_clientPresenceTimer = 2f;
			try
			{
				RealEstateManager.ClientMirror(QuestNetSync.HasRemoteState ? QuestNetSync.RemoteEstate : 0);
			}
			catch
			{
			}
			bool flag = QuestNetSync.HasRemoteState && QuestNetSync.RemoteDonReady;
			bool flag2 = QuestNetSync.HasRemoteState && QuestNetSync.RemoteRecruited;
			Vector3 val2;
			try
			{
				NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
				if ((Object)(object)nPC != (Object)null && (Object)(object)((Component)nPC).transform != (Object)null)
				{
					if (!_clientDonSeenLogged)
					{
						Vector3 position = ((Component)nPC).transform.position;
						NDLog.Debug($"[CLIENTDON] host-Don replicated, found at ({position.x:F1},{position.y:F1},{position.z:F1})");
						_clientDonSeenLogged = true;
					}
					EnsureNpcStationaryOnClient(nPC);
					Vector3 pos;
					if (QuestNetSync.RemoteHandover)
					{
						Vector3 val = default(Vector3);
						((Vector3)(ref val))..ctor(0f, -2000f, 0f);
						val2 = ((Component)nPC).transform.position - val;
						if (((Vector3)(ref val2)).sqrMagnitude > 100f)
						{
							((Component)nPC).transform.position = val;
						}
					}
					else if (DonSalvatoreNPC.ResolveGazeboPosition(out pos))
					{
						val2 = ((Component)nPC).transform.position - pos;
						if (((Vector3)(ref val2)).sqrMagnitude > 1f)
						{
							((Component)nPC).transform.position = pos;
						}
					}
				}
				else if (!_clientDonMissingLogged)
				{
					NDLog.Debug("[CLIENTDON] no Don via NPCManager — host-Don NOT replicated to client yet.");
					_clientDonMissingLogged = true;
				}
			}
			catch
			{
			}
			try
			{
				if (!LuckyNetSync.ClientCombatActive)
				{
					NPC nPC2 = NPCManager.GetNPC("Ndrangheta_lucky");
					if ((Object)(object)nPC2 != (Object)null && (Object)(object)((Component)nPC2).transform != (Object)null)
					{
						Vector3 val3 = default(Vector3);
						((Vector3)(ref val3))..ctor(0f, -2000f, 0f);
						val2 = ((Component)nPC2).transform.position - val3;
						if (((Vector3)(ref val2)).sqrMagnitude > 100f)
						{
							((Component)nPC2).transform.position = val3;
						}
					}
				}
			}
			catch
			{
			}
			if (flag)
			{
				try
				{
					DonMessaging.TryUnlock();
				}
				catch
				{
				}
				try
				{
					DonMessaging.PatchAsSupplier();
				}
				catch
				{
				}
				try
				{
					DonMessaging.SendClientPresenceMessageIfNotYet();
				}
				catch
				{
				}
			}
			bool flag3 = false;
			try
			{
				flag3 = (Object)(object)PlayerSingleton<JournalApp>.Instance != (Object)null;
			}
			catch
			{
			}
			if (!flag)
			{
				_clientMetSent = false;
			}
			if (flag && !flag2)
			{
				if (flag3 && DonSalvatoreNPC.ResolveGazeboPosition(out var pos2))
				{
					if (ClientIntroQuest.Instance == null)
					{
						ClientIntroQuest.EnsureCreated(pos2);
					}
					else
					{
						ClientIntroQuest.RefreshPoi(pos2);
					}
					TryClientMeetDon(pos2);
				}
			}
			else if (flag2 && ClientIntroQuest.Instance != null)
			{
				try
				{
					ClientIntroQuest.CompleteAndClear();
				}
				catch
				{
				}
			}
			if (flag2 && QuestNetSync.RemoteHandover)
			{
				try
				{
					PersistentDonPresenceQuest.CompleteAndClear();
				}
				catch
				{
				}
			}
			else if (flag2)
			{
				if (flag3)
				{
					try
					{
						PersistentDonPresenceQuest.EnsureStarted();
					}
					catch
					{
					}
				}
				try
				{
					PersistentDonPresenceQuest.RefreshPoi();
				}
				catch
				{
				}
				if (PersistentDonPresenceQuest.Instance != null && !_clientQuestStarted)
				{
					NDLog.Debug("[QUESTSYNC] client started Don-presence quest from host state.");
					_clientQuestStarted = true;
				}
			}
			if (flag2 && QuestNetSync.HasRemoteState)
			{
				string text = QuestNetSync.RemoteJobCode ?? "";
				string target = QuestNetSync.RemoteJobTarget ?? "";
				bool flag4 = !string.IsNullOrEmpty(text);
				if (flag4 && flag3 && ClientJobMirrorQuest.Instance == null)
				{
					_clientDropoffSentFor = null;
					_clientShortCashSmsFor = null;
					Vector3 pos3 = ParseVec3(QuestNetSync.RemoteJobTargetPos);
					try
					{
						ClientJobMirrorQuest.EnsureCreated(text, target, pos3);
					}
					catch (Exception ex)
					{
						NDLog.DebugWarn("ClientJobMirrorQuest start: " + ex.Message);
					}
				}
				else if (!flag4 && ClientJobMirrorQuest.Instance != null)
				{
					try
					{
						ClientJobMirrorQuest.CompleteAndClear();
					}
					catch
					{
					}
				}
				if (flag4 && ClientJobMirrorQuest.Instance != null)
				{
					try
					{
						if (!DonSalvatoreNPC.ResolveGazeboPosition(out var pos4))
						{
							pos4 = Vector3.zero;
						}
						ClientJobMirrorQuest.UpdateStage(QuestNetSync.RemoteJobStage, text, pos4, QuestNetSync.RemoteEntryText, ParseVec3(QuestNetSync.RemoteEntryPoi));
					}
					catch (Exception ex2)
					{
						NDLog.DebugWarn("Client stage mirror: " + ex2.Message);
					}
					try
					{
						ClientJobDropoffTick(text);
					}
					catch (Exception ex3)
					{
						NDLog.DebugWarn("ClientJobDropoffTick: " + ex3.Message);
					}
				}
				try
				{
					ApplyCoopPayout();
				}
				catch (Exception ex4)
				{
					NDLog.DebugWarn("ApplyCoopPayout: " + ex4.Message);
				}
				try
				{
					ClientBattesimoTick(flag3);
				}
				catch (Exception ex5)
				{
					NDLog.DebugWarn("ClientBattesimoTick: " + ex5.Message);
				}
				try
				{
					ClientBossMarkerTick(flag3);
				}
				catch (Exception ex6)
				{
					NDLog.DebugWarn("ClientBossMarkerTick: " + ex6.Message);
				}
				try
				{
					ClientTortureQuestTick(flag3);
				}
				catch (Exception ex7)
				{
					NDLog.DebugWarn("ClientTortureQuestTick: " + ex7.Message);
				}
				try
				{
					ClientConsentTick();
				}
				catch (Exception ex8)
				{
					NDLog.DebugWarn("ClientConsentTick: " + ex8.Message);
				}
			}
			try
			{
				ClientChatMenuTick();
			}
			catch (Exception ex9)
			{
				NDLog.DebugWarn("ClientChatMenuTick: " + ex9.Message);
			}
		}

		private void ClientChatMenuTick()
		{
			if (!QuestNetSync.HasRemoteState || !QuestNetSync.RemoteRecruited || !QuestNetSync.RemoteHandover)
			{
				_clientChatMenuBuilt = false;
				_clientChatMenuState = -1;
			}
			else if (DonMessaging.ResolveConversation() != null && !_clientChatMenuBuilt && !DonMessaging.IsPhoneOpen())
			{
				LuckyChatController.OpenMainMenu();
				_clientChatMenuBuilt = true;
				_clientChatMenuState = 1;
				NDLog.Debug("[CLIENTCHAT] Don chat menu built on client (boss).");
			}
		}

		private void ClientConsentTick()
		{
			bool flag = QuestNetSync.HasRemoteState && QuestNetSync.RemoteConsentPending;
			if (flag && !_clientConsentShown)
			{
				DonMessaging.RegisterYesNoButtons("Yes, more contracts.", delegate
				{
					ClientActionNet.SendAction("consent", "yes");
				}, "Not for me. Ask later.", delegate
				{
					ClientActionNet.SendAction("consent", "no");
				});
				_clientConsentShown = true;
				NDLog.Debug("[CLIENTCONSENT] Yes/No buttons shown on client.");
			}
			else if (!flag && _clientConsentShown)
			{
				try
				{
					DonMessaging.RemoveYesNoButtons("Yes, more contracts.", "Not for me. Ask later.");
				}
				catch
				{
				}
				_clientConsentShown = false;
				NDLog.Debug("[CLIENTCONSENT] Yes/No buttons cleared on client.");
			}
		}

		private void ClientBossMarkerTick(bool journalReady)
		{
			//IL_001f: 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_004b: 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_0098: 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)
			string text = QuestNetSync.RemoteBossLabel ?? "";
			bool flag = !string.IsNullOrEmpty(text);
			Vector3 pos = ParseVec3(QuestNetSync.RemoteBossPos);
			if (flag && journalReady)
			{
				if (ClientBossMarkerQuest.Instance == null)
				{
					ClientBossMarkerQuest.EnsureCreated(text, pos, QuestNetSync.RemoteBossKind);
				}
				else
				{
					ClientBossMarkerQuest.UpdateLabelAndPoi(text, pos, QuestNetSync.RemoteBossKind);
				}
			}
			else if (!flag && ClientBossMarkerQuest.Instance != null)
			{
				ClientBossMarkerQuest.CompleteAndClear();
			}
			if (flag && QuestNetSync.RemoteBossKind == 1 && ((Vector3)(ref pos)).sqrMagnitude > 1f)
			{
				InformantiManager.ClientShowNote(pos);
			}
			else
			{
				InformantiManager.ClientHideNote();
			}
			if (flag && QuestNetSync.RemoteBossKind == 2 && ((Vector3)(ref pos)).sqrMagnitude > 1f)
			{
				LaBombaManager.ClientShowProp(pos, text != null && text.IndexOf("ARMED", StringComparison.OrdinalIgnoreCase) >= 0);
			}
			else
			{
				LaBombaManager.ClientHideProp();
			}
		}

		private void ClientTortureQuestTick(bool journalReady)
		{
			bool flag = QuestNetSync.RemoteSceneActive && TerritoryHandover.IsBossForLocalPeer;
			if (flag && journalReady)
			{
				if (TortureManager.ClientSceneText(QuestNetSync.RemoteOpVariant, QuestNetSync.RemoteSceneKoReached, out var title, out var objective))
				{
					if (TortureClientMirrorQuest.Instance == null)
					{
						TortureClientMirrorQuest.EnsureCreated(title, objective);
					}
					else
					{
						TortureClientMirrorQuest.UpdateLabel(objective);
					}
				}
			}
			else if (!flag && TortureClientMirrorQuest.Instance != null)
			{
				TortureClientMirrorQuest.CompleteAndClear();
			}
		}

		private void TryClientMeetDon(Vector3 donPos)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0055: 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_0064: 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)
			if (_clientMetSent)
			{
				return;
			}
			try
			{
				Player local = Player.Local;
				if (!((Object)(object)local == (Object)null) && !((Object)(object)((Component)local).transform == (Object)null))
				{
					Vector3 position = ((Component)local).transform.position;
					float num = position.x - donPos.x;
					float num2 = position.z - donPos.z;
					float num3 = position.y - donPos.y;
					float num4 = num * num + num2 * num2 + num3 * num3 * 0.25f;
					if (!(num4 > 16f) && ClientActionNet.SendAction("metdon", ""))
					{
						_clientMetSent = true;
						NDLog.Debug("[CLIENTINTRO] client reached the Don — sent 'metdon' to host.");
					}
				}
			}
			catch
			{
			}
		}

		private void ClientBattesimoTick(bool journalReady)
		{
			int remoteBattesimoStage = QuestNetSync.RemoteBattesimoStage;
			if ((remoteBattesimoStage == 1 || remoteBattesimoStage == 2) && journalReady)
			{
				BattesimoQuest.EnsureCreated();
				BattesimoQuest.EnsureFirstEntryActive();
				if (!_clientBattAnnounced && BattesimoQuest.Instance != null)
				{
					_clientBattAnnounced = true;
					try
					{
						DonMessaging.SendDon("Il battesimo — that goes for every one of you. Hit a cop, walk away clean, stay free for an hour. Check the journal.");
					}
					catch
					{
					}
				}
			}
			if (remoteBattesimoStage >= 2)
			{
				BattesimoQuest.OnAttackDetected();
			}
			if (remoteBattesimoStage >= 3 && BattesimoQuest.Instance != null)
			{
				BattesimoQuest.OnSurvived();
			}
			if (remoteBattesimoStage == 1 && !_clientBattAttackSent)
			{
				try
				{
					List<PoliceOfficer> officers = PoliceOfficer.Officers;
					if (officers != null)
					{
						for (int i = 0; i < officers.Count; i++)
						{
							PoliceOfficer val;
							try
							{
								val = officers[i];
							}
							catch
							{
								continue;
							}
							if (!((Object)(object)val == (Object)null))
							{
								float num;
								try
								{
									num = (((Object)(object)((NPC)val).Health != (Object)null) ? ((float)((NPC)val).Health.HoursSinceAttackedByPlayer) : (-1f));
								}
								catch
								{
									continue;
								}
								if (num >= 0f && num < 2f)
								{
									if (ClientActionNet.SendAction("battattack", ""))
									{
										_clientBattAttackSent = true;
										NDLog.Debug("[CLIENTACT] battesimo attack detected locally — reported to host.");
									}
									break;
								}
							}
						}
					}
					return;
				}
				catch
				{
					return;
				}
			}
			if (remoteBattesimoStage != 1)
			{
				_clientBattAttackSent = false;
			}
		}

		private void ApplyCoopPayout()
		{
			int remotePaySeq = QuestNetSync.RemotePaySeq;
			if (_coopPaySeqApplied < 0)
			{
				_coopPaySeqApplied = remotePaySeq;
			}
			else
			{
				if (remotePaySeq <= _coopPaySeqApplied)
				{
					return;
				}
				_coopPaySeqApplied = remotePaySeq;
				int remotePayAmount = QuestNetSync.RemotePayAmount;
				if (remotePayAmount <= 0)
				{
					return;
				}
				string text = QuestNetSync.RemotePayExclude ?? "";
				string localIdString = LuckyNetSync.LocalIdString;
				if (string.IsNullOrEmpty(text) || !(text == localIdString))
				{
					PayoutHelper.AddCash(remotePayAmount, "Famiglia coop share");
					try
					{
						ClientActionNet.SendAction("income", $"q|{remotePayAmount}");
					}
					catch
					{
					}
					try
					{
						DonMessaging.SendDon($"Your share of the famiglia's take: ${remotePayAmount}.");
					}
					catch
					{
					}
					NDLog.Info($"[COOPPAY] client credited ${remotePayAmount} (seq={remotePaySeq}).");
				}
			}
		}

		private static void EnsureNpcStationaryOnClient(NPC npc)
		{
			try
			{
				NPCMovement movement = npc.Movement;
				if ((Object)(object)movement != (Object)null && ((Behaviour)movement).enabled)
				{
					try
					{
						movement.PauseMovement();
					}
					catch
					{
					}
					try
					{
						movement.SetAgentEnabled(false);
					}
					catch
					{
					}
					try
					{
						((Behaviour)movement).enabled = false;
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			try
			{
				NavMeshAgent val = (((Object)(object)((Component)npc).gameObject != (Object)null) ? ((Component)npc).gameObject.GetComponent<NavMeshAgent>() : null);
				if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
				{
					((Behaviour)val).enabled = false;
				}
			}
			catch
			{
			}
			try
			{
				NPCBehaviour behaviour = npc.Behaviour;
				if ((Object)(object)behaviour != (Object)null && ((Behaviour)behaviour).enabled)
				{
					((Behaviour)behaviour).enabled = false;
				}
			}
			catch
			{
			}
		}

		private void ClientJobDropoffTick(string jCode)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			int remoteJobStage = QuestNetSync.RemoteJobStage;
			if (remoteJobStage != 6 || string.Equals(_clientDropoffSentFor, jCode, StringComparison.Ordinal))
			{
				return;
			}
			Player local = Player.Local;
			if ((Object)(object)local == (Object)null || (Object)(object)((Component)local).transform == (Object)null)
			{
				return;
			}
			Vector3 pos;
			if (QuestNetSync.RemoteHandover)
			{
				if (!DonSalvatoreNPC.ResolveGazeboPosition(out pos))
				{
					return;
				}
			}
			else
			{
				NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
				if ((Object)(object)nPC != (Object)null && (Object)(object)((Component)nPC).transform != (Object)null)
				{
					pos = ((Component)nPC).transform.position;
				}
				else if (!DonSalvatoreNPC.ResolveGazeboPosition(out pos))
				{
					return;
				}
			}
			Vector3 val = ((Component)local).transform.position - pos;
			val.y = 0f;
			float num = 4.5f;
			if (!(((Vector3)(ref val)).sqrMagnitude > num * num) && ClientActionNet.SendAction("dropoff", jCode))
			{
				_clientDropoffSentFor = jCode;
				NDLog.Debug($"[CLIENTACT] contratto report-to-Don sent for job '{jCode}' (stage={remoteJobStage}).");
			}
		}

		private static bool IsAssemblyLoaded(string simpleName)
		{
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				for (int i = 0; i < assemblies.Length; i++)
				{
					try
					{
						if (string.Equals(assemblies[i].GetName().Name, simpleName, StringComparison.OrdinalIgnoreCase))
						{
							return true;
						}
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static Assembly ResolveS1ApiAny(object sender, ResolveEventArgs args)
		{
			try
			{
				string name = new AssemblyName(args.Name).Name;
				if (!string.Equals(name, "S1API", StringComparison.OrdinalIgnoreCase))
				{
					return null;
				}
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				for (int i = 0; i < assemblies.Length; i++)
				{
					try
					{
						if (!string.Equals(assemblies[i].GetName().Name, "S1API", StringComparison.OrdinalIgnoreCase))
						{
							continue;
						}
						if (!_s1apiRedirectLogged)
						{
							_s1apiRedirectLogged = true;
							NDLog.Warn($"S1API binding redirected: requested '{args.Name}' -> loaded '{assemblies[i].GetName().FullName}' " + "(installed S1API has a different assembly version — tolerated, same product version).");
						}
						return assemblies[i];
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			return null;
		}

		public override void OnInitializeMelon()
		{
			try
			{
				AppDomain.CurrentDomain.AssemblyResolve += ResolveS1ApiAny;
			}
			catch
			{
			}
			ModConfig.Initialize();
			NDLog.DebugLogging = ModConfig.DebugLogging;
			if (!IsAssemblyLoaded("S1API"))
			{
				_s1apiMissing = true;
				NDLog.Error("S1API NOT found — TheMob requires S1API (plugin 'S1APILoader' + 'S1API.Il2Cpp.MelonLoader.dll'). Mod is DISABLED (no world content, no quests). Please install S1API and restart the game.");
				return;
			}
			try
			{
				MobFamilyRegistry.Register((MobFamily)(object)new NdranghetaFamily());
			}
			catch (Exception ex)
			{
				NDLog.Warn("[MOB] family registration failed: " + ex.Message);
			}
			NDLog.Info("v" + ((MelonBase)this).Info.Version + " initializing.");
			try
			{
				LuckyNetSync.Initialize();
			}
			catch (Exception ex2)
			{
				_netLayerDown = true;
				NDLog.Warn("Net layer unavailable (SteamNetworkLib missing?) — running solo. " + ex2.GetType().Name);
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (_s1apiMissing)
			{
				return;
			}
			_inMainScene = string.Equals(sceneName, "Main", StringComparison.Ordinal);
			if (!_inMainScene)
			{
				_npcSpawned = false;
				_startupTimer = 0f;
				_saveDataRefreshTimer = 0f;
				_wasAuthority = false;
				_demotedToClient = false;
				IntroController.ResetForSceneReload();
				try
				{
					TerritoryHandover.ForceReset();
				}
				catch
				{
				}
				PizzoJobManager.ResetForSceneReload();
				RankManager.ResetForSceneReload();
				DailyTribute.ResetForSceneReload();
				BattesimoController.ResetForSceneReload();
				ConsentController.ResetForSceneReload();
				LuckyBrawlManager.ResetForSceneReload();
				LaBombaManager.ResetForSceneReload();
				RapimentoManager.ResetForSceneReload();
				TortureManager.ResetForSceneReload();
				try
				{
					GangBattleManager.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					GangWarManager.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					FearState.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					FaidaState.ResetForSceneReload();
				}
				catch
				{
				}
				CarBombManager.ResetForSceneReload();
				InformantiManager.ResetForSceneReload();
				RealEstateManager.ResetForSceneReload();
				LuckyTargetPicker.ResetForSceneReload();
				PropVisuals.ResetForSceneReload();
				try
				{
					MobTeleport.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					MirrorRenderer.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					VisualMirror.Reset();
				}
				catch
				{
				}
				try
				{
					TeleportMirror.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					FamigliaReskinSync.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					Sfx.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					MobFamilyRegistry.ResetAllForSceneReload();
				}
				catch
				{
				}
				try
				{
					LuckyCombatDriver.Reset();
				}
				catch
				{
				}
				_staleMarkerSweepAt = 0f;
				ClientActionNet.Reset();
				_clientDropoffSentFor = null;
				_clientShortCashSmsFor = null;
				_coopPaySeqApplied = -1;
				_clientBattAnnounced = false;
				_clientBattAttackSent = false;
				try
				{
					BattesimoQuest.ClearInstanceForNext();
				}
				catch
				{
				}
				_clientConsentShown = false;
				_clientMetSent = false;
				try
				{
					ClientIntroQuest.ResetForSceneReload();
				}
				catch
				{
				}
				_clientChatMenuBuilt = false;
				_clientChatMenuState = -1;
			}
			else
			{
				NDLog.Debug("Entered Main scene — waiting for spawn delay.");
				_staleMarkerSweepAt = Time.time + 12f;
				ArmDepositoReloadRescue();
			}
		}

		private static void ArmDepositoReloadRescue()
		{
			bool flag = _depositoRescueUntil > Time.time;
			_depositoRescueAt = Time.time + 1f;
			_depositoRescueUntil = Time.time + 30f;
			_depositoLastScreenUpAt = Time.time;
			if (!flag)
			{
				_depositoReloadDetected = false;
				_depositoForceDismissAt = 0f;
				_depositoForcedDismiss = false;
			}
		}

		public override void OnGUI()
		{
			if (_s1apiMissing)
			{
				DrawS1ApiMissingBanner();
				return;
			}
			try
			{
				TortureManager.OnGUI();
			}
			catch
			{
			}
			try
			{
				GangBattleManager.OnGUI();
			}
			catch
			{
			}
			try
			{
				GangWarManager.OnGUI();
			}
			catch
			{
			}
			try
			{
				InformantiManager.OnGUI();
			}
			catch
			{
			}
		}

		private static void DrawS1ApiMissingBanner()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00bf: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0028: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (_s1apiWarnStyle == null)
				{
					_s1apiWarnStyle = new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)4,
						fontSize = 15,
						fontStyle = (FontStyle)1,
						wordWrap = true
					};
					_s1apiWarnStyle.normal.textColor = Color.white;
				}
				float num = Mathf.Min(740f, (float)Screen.width - 20f);
				float num2 = 64f;
				float num3 = ((float)Screen.width - num) * 0.5f;
				float num4 = 12f;
				Color backgroundColor = GUI.backgroundColor;
				Color color = GUI.color;
				GUI.backgroundColor = new Color(0.55f, 0.05f, 0.05f, 0.92f);
				GUI.Box(new Rect(num3, num4, num, num2), GUIContent.none);
				GUI.color = Color.white;
				GUI.Label(new Rect(num3 + 12f, num4 + 6f, num - 24f, num2 - 12f), "TheMob (Ndrangheta) is DISABLED — S1API not found.\nInstall the S1APILoader plugin + S1API.Il2Cpp.MelonLoader.dll (v3.0.5) and restart the game.", _s1apiWarnStyle);
				GUI.backgroundColor = backgroundColor;
				GUI.color = color;
			}
			catch
			{
			}
		}

		public override void OnUpdate()
		{
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			if (_s1apiMissing)
			{
				return;
			}
			if (!_netLayerDown)
			{
				try
				{
					LuckyNetSync.Tick();
					QuestNetSync.Tick();
				}
				catch (Exception ex)
				{
					_netLayerDown = true;
					NDLog.Warn("Net layer unavailable (SteamNetworkLib missing?) — running solo. " + ex.GetType().Name);
				}
			}
			if (!_inMainScene)
			{
				return;
			}
			if (!_netDiagDone)
			{
				_netDiagTimer += Time.deltaTime;
				if (_netDiagTimer >= 5f)
				{
					_netDiagDone = true;
					SessionGate.LogDiagnostics();
				}
			}
			bool isAuthority = SessionGate.IsAuthority;
			if (isAuthority != _wasAuthority)
			{
				NDLog.Debug($"[AUTH] {_wasAuthority}->{isAuthority} {SessionGate.Describe()}");
			}
			if (_wasAuthority && !isAuthority)
			{
				DemoteToClient();
			}
			_wasAuthority = isAuthority;
			if (!_netLayerDown)
			{
				if (isAuthority)
				{
					GetCurrentStepSync(out var entryText, out var entryPoi);
					QuestNetSync.PublishState(RecruitmentState.WelcomeSmsSent || RecruitmentState.Recruited, RecruitmentState.Recruited, RecruitmentState.HasMetDon, GetCurrentJobCode(), GetCurrentJobTarget(), GetCurrentJobTargetPos(), (int)PizzoJobManager.CurrentPhase, GetCurrentJobCut(), GetCurrentJobDropReward(), entryText, entryPoi, PizzoJobManager.CoopPaySeq, PizzoJobManager.CoopPayAmount, PizzoJobManager.CoopPayExclude, (int)BattesimoController.CurrentStage, TerritoryHandover.HandoverActive, RealEstateManager.SyncCode, FearState.Points, FaidaState.BenziePoints, BossMarkerSync.Label, GetBossMarkerPos(), RapimentoManager.ActiveVanGuid ?? "", ConsentController.QuestionPending, BossMarkerSync.Kind, RealEstateManager.GuardPatrolSyncCode, BossMarkerSync.RaidSeconds, IncomeTracker.QuestIncome, IncomeTracker.OtherIncome, RapimentoManager.IsRecruiting, RapimentoManager.OpDropActive, FmtVec(RapimentoManager.OpDropPos), RapimentoManager.OpDropReachInt, RapimentoManager.CurrentVariant, TortureManager.SceneActive, FmtVec(TortureManager.ScenePlayerPos), FmtVec(TortureManager.SceneReturnPos), TortureManager.SceneReturnYawInt, TortureManager.SceneBeginSeq, TortureManager.SceneEndSeq, VisualMirror.Encode(), TeleportMirror.Encode(), LuckyBrawlManager.BrawlPhase, FamigliaReskinSync.Encode(), TortureManager.SceneTimeLeftInt, TortureManager.SceneKoReached, Sfx.MirrorSeq, Sfx.MirrorName, (int)(Sfx.MirrorVol * 100f), Sfx.LoopName, RapimentoManager.ReleasedVictimSeq, RapimentoManager.ReleasedVictimObjId, FaidaState.TriadPoints);
				}
				try
				{
					TeleportMirror.TickLocalApply();
				}
				catch (Exception ex2)
				{
					NDLog.DebugWarn("[TPMIRROR] host apply: " + ex2.Message);
				}
				ClientActionNet.TickHost(Time.deltaTime);
				try
				{
					if (isAuthority)
					{
						IncomeTracker.ClearDisplayOverride();
					}
					else
					{
						IncomeTracker.SetDisplayOverride(QuestNetSync.RemoteQuestIncome, QuestNetSync.RemoteOtherIncome);
					}
				}
				catch
				{
				}
			}
			if (_staleMarkerSweepAt > 0f && Time.time >= _staleMarkerSweepAt)
			{
				_staleMarkerSweepAt = 0f;
				try
				{
					LuckyBrawlManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					LaBombaManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					RapimentoManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					GangBattleManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					GangWarManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					CarBombManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					InformantiManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					RealEstateManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					KidnapSackItem.EnsureRegistered();
				}
				catch
				{
				}
			}
			if (!isAuthority && _depositoRescueUntil > 0f && Time.time < _depositoRescueUntil)
			{
				bool flag = GameCompat.IsLoadingScreenOpen();
				if (flag)
				{
					_depositoLastScreenUpAt = Time.time;
				}
				if ((flag || Time.time - _depositoLastScreenUpAt < 5f) && Time.time >= _depositoRescueAt)
				{
					_depositoRescueAt = Time.time + 0.5f;
					bool flag2 = false;
					try
					{
						flag2 = LagerRoom.RescuePlayerIfInside();
					}
					catch
					{
					}
					if (flag2)
					{
						_depositoReloadDetected = true;
					}
				}
				if (_depositoReloadDetected && flag)
				{
					if (_depositoForceDismissAt <= 0f)
					{
						_depositoForceDismissAt = Time.time + 4f;
					}
					else if (Time.time >= _depositoForceDismissAt)
					{
						bool flag3 = GameCompat.ForceCloseLoadingScreen();
						if (!_depositoForcedDismiss)
						{
							_depositoForcedDismiss = true;
							NDLog.Debug("[LAGER] client stuck on orphaned join-loading-screen after deposito-reload — force-closing it (" + (flag3 ? "ok" : "still open") + ").");
						}
					}
				}
				else if (!flag)
				{
					_depositoForceDismissAt = 0f;
				}
				if (_depositoReloadDetected && !flag)
				{
					Player local = Player.Local;
					if ((Object)(object)local != (Object)null && (Object)(object)((Component)local).transform != (Object)null && ((Component)local).transform.position.y > -7f)
					{
						_depositoRescueUntil = 0f;
						_depositoForceDismissAt = 0f;
						_depositoForcedDismiss = false;
					}
				}
			}
			else if (_depositoRescueUntil > 0f && (isAuthority || Time.time >= _depositoRescueUntil))
			{
				_depositoRescueUntil = 0f;
				_depositoForceDismissAt = 0f;
				_depositoForcedDismiss = false;
			}
			if (!isAuthority)
			{
				bool flag4 = false;
				bool flag5 = false;
				try
				{
					flag4 = GameCompat.IsGameLoading();
				}
				catch
				{
				}
				try
				{
					flag5 = GameCompat.IsLoadingScreenOpen();
				}
				catch
				{
				}
				Player val = null;
				try
				{
					val = Player.Local;
				}
				catch
				{
				}
				if (flag4 && flag5 && (Object)(object)val != (Object)null)
				{
					if (_clientLoadStuckSince <= 0f)
					{
						_clientLoadStuckSince = Time.time;
						_clientLoadDiagAt = 0f;
						_clientLoadReqAt = 0f;
						_clientLoadReqs = 0;
						_clientGatesOkSince = 0f;
					}
					float num = Time.time - _clientLoadStuckSince;
					if (Time.time >= _clientLoadDiagAt)
					{
						_clientLoadDiagAt = Time.time + 3f;
						try
						{
							GameCompat.LogClientLoadGateState(num);
						}
						catch
						{
						}
					}
					bool flag6 = false;
					try
					{
						flag6 = GameCompat.ClientLoadGatesSatisfied();
					}
					catch
					{
					}
					if (flag6)
					{
						if (_clientGatesOkSince <= 0f)
						{
							_clientGatesOkSince = Time.time;
						}
					}
					else
					{
						_clientGatesOkSince = 0f;
						if (num >= 5f && _clientLoadReqs < 3 && Time.time >= _clientLoadReqAt)
						{
							_clientLoadReqAt = Time.time + 4f;
							_clientLoadReqs++;
							bool value = false;
							try
							{
								value = GameCompat.TryReRequestPlayerData();
							}
							catch
							{
							}
							NDLog.Debug($"[CLIENTLOAD] gates not satisfied at {num:0}s — re-requesting player data (attempt {_clientLoadReqs}/3, sent={value}).");
						}
					}
					bool flag7 = _clientGatesOkSince > 0f && Time.time - _clientGatesOkSince >= 3f;
					bool flag8 = num >= 18f;
					if (flag7 || flag8)
					{
						bool flag9 = false;
						try
						{
							flag9 = GameCompat.ForceCloseLoadingScreen();
						}
						catch
						{
						}
						if (!_clientLoadForced)
						{
							_clientLoadForced = true;
							NDLog.Debug($"[CLIENTLOAD] load gates satisfied but screen stuck (dead LoadAsClient coroutine) — forcing load complete at {num:0}s ({(flag9 ? "closed" : "still open")}; reason={(flag7 ? "gates+grace" : "timeout")}).");
						}
					}
				}
				else
				{
					_clientLoadStuckSince = 0f;
					_clientLoadDiagAt = 0f;
					_clientLoadForced = false;
					_clientLoadReqAt = 0f;
					_clientLoadReqs = 0;
					_clientGatesOkSince = 0f;
				}
			}
			try
			{
				if (TerritoryHandover.IsBossForLocalPeer && !_netLayerDown && DonMessaging.NeedsChoiceInterfaceRestore())
				{
					if (_chatRestoreAt <= 0f)
					{
						_chatRestoreAt = Time.time + 1.5f;
					}
					else if (Time.time >= _chatRestoreAt)
					{
						_chatRestoreAt = 0f;
						NDLog.Debug("[CHAT] interface was button-less — restoring main menu (FIX-151 watchdog).");
						LuckyChatController.OpenMainMenu();
					}
				}
				else
				{
					_chatRestoreAt = 0f;
				}
			}
			catch (Exception ex3)
			{
				NDLog.DebugWarn("[CHAT] interface watchdog: " + ex3.Message);
			}
			if (_demotedToClient || !isAuthority)
			{
				if (_netLayerDown)
				{
					return;
				}
				ClientPresenceTick();
				try
				{
					bool villaOwned = QuestNetSync.HasRemoteState && (QuestNetSync.RemoteEstate & 8) != 0;
					RealEstateManager.ClientGuardTick(villaOwned, QuestNetSync.HasRemoteState ? QuestNetSync.RemoteGuardPatrol : 0);
				}
				catch
				{
				}
				try
				{
					RapimentoManager.Tick(Time.deltaTime);
				}
				catch (Exception ex4)
				{
					NDLog.DebugWarn("[CLIENT] RapimentoManager.Tick: " + ex4.Message);
				}
				try
				{
					CarBombManager.Tick(Time.deltaTime);
				}
				catch (Exception ex5)
				{
					NDLog.DebugWarn("[CLIENT] CarBombManager.Tick: " + ex5.Message);
				}
				try
				{
					LaBombaManager.ClientTickBeep();
				}
				catch (Exception ex6)
				{
					NDLog.DebugWarn("[CLIENT] LaBombaManager.ClientTickBeep: " + ex6.Message);
				}
				try
				{
					if (QuestNetSync.HasRemoteState)
					{
						Sfx.ApplyMirror(QuestNetSync.RemoteSfxSeq, QuestNetSync.RemoteSfxName, (float)QuestNetSync.RemoteSfxVol100 / 100f, QuestNetSync.RemoteSfxLoop);
					}
				}
				catch (Exception ex7)
				{
					NDLog.DebugWarn("[CLIENT] Sfx.ApplyMirror: " + ex7.Message);
				}
				try
				{
					if (QuestNetSync.HasRemoteState)
					{
						RapimentoManager.ClientApplyRelease(QuestNetSync.RemoteReleasedSeq, QuestNetSync.RemoteReleasedObjId);
					}
				}
				catch (Exception ex8)
				{
					NDLog.DebugWarn("[CLIENT] RapimentoManager.ClientApplyRelease: " + ex8.Message);
				}
				try
				{
					LuckyNetSync.ClientTick(Time.deltaTime);
				}
				catch (Exception ex9)
				{
					NDLog.DebugWarn("[CLIENT] LuckyNetSync.ClientTick: " + ex9.Message);
				}
				try
				{
					MirrorRenderer.RenderVisuals(VisualMirror.Decode(QuestNetSync.RemoteVisualsRaw));
				}
				catch (Exception ex10)
				{
					NDLog.DebugWarn("[CLIENT] MirrorRenderer.RenderVisuals: " + ex10.Message);
				}
				try
				{
					MirrorRenderer.RenderTeleports(TeleportMirror.Decode(QuestNetSync.RemoteTeleportsRaw));
				}
				catch (Exception ex11)
				{
					NDLog.DebugWarn("[CLIENT] MirrorRenderer.RenderTeleports: " + ex11.Message);
				}
				try
				{
					FamigliaReskinSync.ClientApply(QuestNetSync.RemoteFamigliaGoons);
				}
				catch (Exception ex12)
				{
					NDLog.DebugWarn("[CLIENT] FamigliaReskinSync: " + ex12.Message);
				}
				try
				{
					LuckyChatController.ClientBrawlMenuTick();
				}
				catch (Exception ex13)
				{
					NDLog.DebugWarn("[CLIENT] ClientBrawlMenuTick: " + ex13.Message);
				}
				try
				{
					RapimentoManager.ClientApplyVanColor();
				}
				catch (Exception ex14)
				{
					NDLog.DebugWarn("[CLIENT] ClientApplyVanColor: " + ex14.Message);
				}
				try
				{
					TortureManager.ClientGuardTick();
					return;
				}
				catch (Exception ex15)
				{
					NDLog.DebugWarn("[CLIENT] TortureManager.ClientGuardTick: " + ex15.Message);
					return;
				}
			}
			try
			{
				MobFamilyRegistry.EnsureDefaultActive();
			}
			catch
			{
			}
			if (!_npcSpawned)
			{
				_startupTimer += Time.deltaTime;
				if (!(_startupTimer < 3f))
				{
					TrySpawnDon();
				}
				return;
			}
			IntroController.Tick(Time.deltaTime);
			PizzoJobManager.Tick(Time.deltaTime);
			IntroQuest.RefreshPoi();
			if (RecruitmentState.Recruited)
			{
				if (TerritoryHandover.HandoverActive)
				{
					PersistentDonPresenceQuest.CompleteAndClear();
				}
				else
				{
					PersistentDonPresenceQuest.EnsureStarted();
					PersistentDonPresenceQuest.RefreshPoi();
				}
			}
			if (!ProductRegistry.IsRegistered)
			{
				ProductRegistry.TryRegister();
			}
			DailyTribute.Tick(Time.deltaTime);
			BattesimoController.Tick(Time.deltaTime);
			ConsentController.Tick(Time.deltaTime);
			LuckyCombatDriver.Tick(Time.deltaTime);
			LuckyBrawlManager.Tick(Time.deltaTime);
			LaBombaManager.Tick(Time.deltaTime);
			InformantiManager.Tick(Time.deltaTime);
			RapimentoManager.Tick(Time.deltaTime);
			TortureManager.Tick(Time.deltaTime);
			GangBattleManager.Tick(Time.deltaTime);
			GangWarManager.Tick(Time.deltaTime);
			CarBombManager.Tick(Time.deltaTime);
			RealEstateManager.Tick(Time.deltaTime);
			LagerGrid.Tick(Time.deltaTime);
			LuckyNPC.TickWatchdog();
			DonSalvatoreNPC.TickWatchdog();
			GuardNPC.TickHiddenWatchdog();
			HeartbeatSave();
		}

		private void HeartbeatSave()
		{
			_saveDataRefreshTimer -= Time.deltaTime;
			if (_saveDataRefreshTimer <= 0f)
			{
				_saveDataRefreshTimer = 1f;
				NdranghetaSaveData.Instance?.PushNow();
			}
		}

		private void TrySpawnDon()
		{
			try
			{
				DonSalvatoreNPC instance = DonSalvatoreNPC.Instance;
				if (instance != null)
				{
					GameObject val = null;
					try
					{
						val = ((NPC)instance).gameObject;
					}
					catch
					{
					}
					if ((Object)(object)val != (Object)null)
					{
						_npcSpawned = true;
						EnsureVillaGuardsLoaded();
						return;
					}
				}
				try
				{
					NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
					if ((Object)(object)nPC != (Object)null && (Object)(object)((Component)nPC).gameObject != (Object)null)
					{
						_npcSpawned = true;
						EnsureVillaGuardsLoaded();
						return;
					}
				}
				catch
				{
				}
				NDLog.Debug("[SPAWN] creating Don/Lucky now — " + SessionGate.Describe());
				try
				{
					if (SessionGate.IsAuthority && LuckyNPC.Instance == null && (Object)(object)NPCManager.GetNPC("Ndrangheta_lucky") == (Object)null)
					{
						new LuckyNPC();
						NDLog.Debug($"LuckyNPC instantiated (visible={1}).");
					}
				}
				catch (Exception ex)
				{
					NDLog.Warn("LuckyNPC spawn: " + ex.Message);
				}
				new DonSalvatoreNPC();
				_npcSpawned = true;
				NDLog.Debug("DonSalvatoreNPC instantiated.");
				EnsureVillaGuardsLoaded();
			}
			catch (Exception ex2)
			{
				NDLog.Warn("DonSalvatoreNPC spawn failed (will retry): " + ex2.Message);
				_startupTimer = 0f;
			}
		}

		private static void EnsureVillaGuardsLoaded()
		{
			try
			{
				GuardNPC.CreateAll();
			}
			catch (Exception ex)
			{
				NDLog.Warn("GuardNPC.CreateAll: " + ex.Message);
			}
		}
	}
	public sealed class NdranghetaSaveData : Saveable
	{
		[SaveableField("Ndrangheta_state")]
		private NdranghetaSnapshot _data = new NdranghetaSnapshot();

		private static string _cachedGridItems = "";

		public static NdranghetaSaveData Instance { get; private set; }

		public NdranghetaSaveData()
		{
			try
			{
				_data = CaptureFromLiveState();
			}
			catch
			{
			}
			Instance = this;
		}

		public void PushNow(bool refreshGrids = false)
		{
			try
			{
				_data = CaptureFromLiveState(refreshGrids);
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("PushNow: " + ex.Message);
			}
		}

		protected override void OnLoaded()
		{
			try
			{
				NDLog.Debug($"SaveData OnLoaded: recruited={_data?.Recruited} count={_data?.PizzoCompletedCount} phase={_data?.JobPhase}");
				ApplyToLiveState(_data ?? new NdranghetaSnapshot());
			}
			catch (Exception ex)
			{
				NDLog.Warn("OnLoaded apply failed: " + ex.Message);
			}
		}

		protected override void OnSaved()
		{
			try
			{
				_data = CaptureFromLiveState();
			}
			catch
			{
			}
		}

		private static string GridItemsCapture(bool refresh)
		{
			if (refresh)
			{
				try
				{
					_cachedGridItems = GridPersistence.CaptureAllString();
				}
				catch (Exception ex)
				{
					NDLog.DebugWarn("GridItems capture: " + ex.Message);
				}
			}
			return _cachedGridItems;
		}

		public static NdranghetaSnapshot CaptureFromLiveState(bool refreshGrids = true)
		{
			PizzoJobManager.JobSnapshot jobSnapshot = PizzoJobManager.CaptureSnapshot();
			return new NdranghetaSnapshot
			{
				WelcomeSmsSent = RecruitmentState.WelcomeSmsSent,
				HasMetDon = RecruitmentState.HasMetDon,
				Recruited = RecruitmentState.Recruited,
				CurrentRank = (int)RankManager.CurrentRank,
				LastTributeDay = DailyTribute.LastTributeDay,
				BattesimoStage = BattesimoController.SaveStage,
				BattesimoAttackDay = BattesimoController.SaveAttackDay,
				BattesimoAttackTime = BattesimoController.SaveAttackTime,
				ConsentState = (int)ConsentController.CurrentState,
				LastConsentAskDay = ConsentController.LastAskDay,
				PizzoCompletedCount = jobSnapshot.CompletedCount,
				JobPhase = jobSnapshot.Phase,
				JobType = jobSnapshot.JobType,
				JobCooldownRemaining = jobSnapshot.CooldownRemaining,
				JobCashSpawned = jobSnapshot.CashSpawned,
				JobTargetName = jobSnapshot.TargetName,
				JobDropBName = jobSnapshot.DropBName,
				JobDropBGuid = jobSnapshot.DropBGuid,
				JobDropBPosX = jobSnapshot.DropBPosX,
				JobDropBPosY = jobSnapshot.DropBPosY,
				JobDropBPosZ = jobSnapshot.DropBPosZ,
				JobTargetShopHint = jobSnapshot.TargetShopHint,
				JobDropName = jobSnapshot.DropName,
				JobDropGuid = jobSnapshot.DropGuid,
				JobDropPosX = jobSnapshot.DropPosX,
				JobDropPosY = jobSnapshot.DropPosY,
				JobDropPosZ = jobSnapshot.DropPosZ,
				JobEnvelopeAmount = jobSnapshot.EnvelopeAmount,
				JobCutAmount = jobSnapshot.CutAmount,
				JobRewardAmount = jobSnapshot.RewardAmount,
				JobIsCurfew = jobSnapshot.IsCurfew,
				JobContrattoTargetName = jobSnapshot.ContrattoTargetName,
				JobContrattoTargetCategory = jobSnapshot.ContrattoTargetCategory,
				JobCaricoItemId = jobSnapshot.CaricoItemId,
				JobCaricoItemDisplayName = jobSnapshot.CaricoItemDisplayName,
				JobCaricoQuantity = jobSnapshot.CaricoQuantity,
				JobCaricoBonusBricks = jobSnapshot.CaricoBonusBricks,
				JobSchemaVersion = jobSnapshot.SchemaVersion,
				DropoffBaseline = jobSnapshot.DropoffBaseline,
				HandoverActive = TerritoryHandover.HandoverActive,
				ContrattiCompletedCount = PizzoJobManager.ContrattiCompletedCount,
				LuckyTargetName = jobSnapshot.LuckyTargetName,
				LuckyTargetCategory = jobSnapshot.LuckyTargetCategory,
				LuckyTargetRegion = jobSnapshot.LuckyTargetRegion,
				LuckyMethod = jobSnapshot.LuckyMethod,
				LuckyDispatched = jobSnapshot.LuckyDispatched,
				EstateOwned = false,
				EstateSpotIndex = 0,
				EstateFacingYaw = 0f,
				VillaOwned = RealEstateManager.VillaOwned,
				LagerMask = RealEstateManager.LagerMask,
				VillaBuildingName = (VillaLocator.BuildingName ?? ""),
				LagerFurnishA0 = RealEstateManager.GetFurnishA(0),
				LagerFurnishA1 = RealEstateManager.GetFurnishA(1),
				LagerFurnishA2 = RealEstateManager.GetFurnishA(2),
				LagerFurnishB0 = RealEstateManager.GetFurnishB(0),
				LagerFurnishB1 = RealEstateManager.GetFurnishB(1),
				LagerFurnishB2 = RealEstateManager.GetFurnishB(2),
				VillaFurnishA = RealEstateManager.GetFurnishA(3),
				VillaFurnishB = RealEstateManager.GetFurnishB(3),
				GridItems = GridItemsCapture(refreshGrids),
				KidnapVanGuid = (RapimentoManager.ActiveVanGuid ?? ""),
				IncomeQuest = IncomeTracker.QuestIncome,
				IncomeOther = IncomeTracker.OtherIncome,
				FearPoints = FearState.Points,
				FaidaBenziePoints = FaidaState.BenziePoints,
				FaidaReveals = FaidaState.RevealedDeals,
				FaidaTriadPoints = FaidaState.TriadPoints
			};
		}

		public static void ApplyToLiveState(NdranghetaSnapshot snap)
		{
			if (snap == null)
			{
				snap = new NdranghetaSnapshot();
			}
			try
			{
				GridPersistence.LoadStash(snap.GridItems);
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("GridItems stash: " + ex.Message);
			}
			try
			{
				RapimentoManager.SetPendingOrphanVan(snap.KidnapVanGuid);
			}
			catch (Exception ex2)
			{
				NDLog.DebugWarn("KidnapVan pending: " + ex2.Message);
			}
			try
			{
				IncomeTracker.LoadSnapshot(snap.IncomeQuest, snap.IncomeOther);
			}
			catch (Exception ex3)
			{
				NDLog.DebugWarn("Income restore: " + ex3.Message);
			}
			try
			{
				FearState.LoadPoints(snap.FearPoints);
			}
			catch (Exception ex4)
			{
				NDLog.DebugWarn("Fear restore: " + ex4.Message);
			}
			try
			{
				FaidaState.Load(snap.FaidaBenziePoints, snap.FaidaReveals, snap.FaidaTriadPoints);
			}
			catch (Exception ex5)
			{
				NDLog.DebugWarn("Faida restore: " + ex5.Message);
			}
			RecruitmentState.WelcomeSmsSent = snap.WelcomeSmsSent;
			RecruitmentState.HasMetDon = snap.HasMetDon;
			RecruitmentState.Recruited = snap.Recruited;
			RankManager.LoadRank((Rank)snap.CurrentRank);
			RankManager.ReconcileFromCompleted(snap.PizzoCompletedCount);
			DailyTribute.LoadLastDay(snap.LastTributeDay);
			BattesimoController.LoadStage(snap.BattesimoStage, snap.BattesimoAttackDay, snap.BattesimoAttackTime);
			ConsentController.LoadState(snap.ConsentState, snap.LastConsentAskDay);
			TerritoryHandover.LoadState(snap.HandoverActive);
			PizzoJobManager.LoadContrattiCount(snap.ContrattiCompletedCount);
			try
			{
				RealEstateManager.LoadState(snap.VillaOwned, snap.LagerMask, snap.VillaBuildingName, snap.EstateOwned, snap.EstateSpotIndex);
				RealEstateManager.LoadFurnish(snap.LagerFurnishA0, snap.LagerFurnishA1, snap.LagerFurnishA2, snap.VillaFurnishA, snap.LagerFurnishB0, snap.LagerFurnishB1, snap.LagerFurnishB2, snap.VillaFurnishB);
			}
			catch (Exception ex6)
			{
				NDLog.DebugWarn("RealEstate LoadState: " + ex6.Message);
			}
			PizzoJobManager.LoadFromSnapshot(new PizzoJobManager.JobSnapshot
			{
				Phase = snap.JobPhase,
				JobType = snap.JobType,
				CompletedCount = snap.PizzoCompletedCount,
				CooldownRemaining = snap.JobCooldownRemaining,
				CashSpawned = snap.JobCashSpawned,
				TargetName = snap.JobTargetName,
				DropBName = snap.JobDropBName,
				DropBGuid = snap.JobDropBGuid,
				DropBPosX = snap.JobDropBPosX,
				DropBPosY = snap.JobDropBPosY,
				DropBPosZ = snap.JobDropBPosZ,
				TargetShopHint = snap.JobTargetShopHint,
				DropName = snap.JobDropName,
				DropGuid = snap.JobDropGuid,
				DropPosX = snap.JobDropPosX,
				DropPosY = snap.JobDropPosY,
				DropPosZ = snap.JobDropPosZ,
				EnvelopeAmount = snap.JobEnvelopeAmount,
				CutAmount = snap.JobCutAmount,
				RewardAmount = snap.JobRewardAmount,
				IsCurfew = snap.JobIsCurfew,
				ContrattoTargetName = snap.JobContrattoTargetName,
				ContrattoTargetCategory = snap.JobContrattoTargetCategory,
				CaricoItemId = snap.JobCaricoItemId,
				CaricoItemDisplayName = snap.JobCaricoItemDisplayName,
				CaricoQuantity = snap.JobCaricoQuantity,
				CaricoBonusBricks = snap.JobCaricoBonusBricks,
				SchemaVersion = snap.JobSchemaVersion,
				LuckyTargetName = snap.LuckyTargetName,
				LuckyTargetCategory = snap.LuckyTargetCategory,
				LuckyTargetRegion = snap.LuckyTargetRegion,
				LuckyMethod = snap.LuckyMethod,
				LuckyDispatched = snap.LuckyDispatched,
				DropoffBaseline = snap.DropoffBaseline
			});
			if (snap.HandoverActive && PizzoJobManager.Current == null)
			{
				try
				{
					LuckyChatController.RefreshIfHandoverActive();
				}
				catch (Exception ex7)
				{
					NDLog.DebugWarn("OnLoaded LuckyChat refresh: " + ex7.Message);
				}
			}
		}
	}
	[Serializable]
	public sealed class NdranghetaSnapshot
	{
		public bool WelcomeSmsSent;

		public bool HasMetDon;

		public bool Recruited;

		public int CurrentRank;

		public int LastTributeDay = -1;

		public int BattesimoStage;

		public int BattesimoAttackDay;

		public int BattesimoAttackTime;

		public int ConsentState;

		public int LastConsentAskDay = -1;

		public int PizzoCompletedCount;

		public int JobPhase;

		public int JobType;

		public float JobCooldownRemaining;

		public bool JobCashSpawned;

		public string JobTargetName;

		public string JobDropBName;

		public string JobDropBGuid;

		public float JobDropBPosX;

		public float JobDropBPosY;

		public float JobDropBPosZ;

		public string JobTargetShopHint;

		public string JobDropName;

		public string JobDropGuid;

		public float JobDropPosX;

		public float JobDropPosY;

		public float JobDropPosZ;

		public int JobEnvelopeAmount;

		public int JobCutAmount;

		public int JobRewardAmount;

		public bool JobIsCurfew;

		public string JobContrattoTargetName;

		public string JobContrattoTargetCategory;

		public string JobCaricoItemId;

		public string JobCaricoItemDisplayName;

		public int JobCaricoQuantity;

		public int JobCaricoBonusBricks;

		public int JobSchemaVersion;

		public int DropoffBaseline = -1;

		public bool HandoverActive;

		public int ContrattiCompletedCount;

		public string LuckyTargetName;

		public string LuckyTargetCategory;

		public string LuckyTargetRegion;

		public int LuckyMethod;

		public bool LuckyDispatched;

		public bool EstateOwned;

		public int EstateSpotIndex;

		public float EstateFacingYaw;

		public bool VillaOwned;

		public int LagerMask;

		public string VillaBuildingName;

		public int LagerFurnishA0;

		public int LagerFurnishA1;

		public int LagerFurnishA2;

		public int LagerFurnishB0;

		public int LagerFurnishB1;

		public int LagerFurnishB2;

		public int VillaFurnishA;

		public int VillaFurnishB;

		public string GridItems;

		public string KidnapVanGuid;

		public long IncomeQuest;

		public long IncomeOther;

		public int FearPoints;

		public int FaidaBenziePoints;

		public int FaidaReveals;

		public int FaidaTriadPoints;
	}
}
namespace Ndrangheta.Quests
{
	[QuestName("Il Battesimo")]
	internal sealed class BattesimoQuestId : IQuestIdentifier
	{
	}
	internal sealed class BattesimoQuest : Quest
	{
		public const string QuestGuid = "Ndrangheta.battesimo";

		protected override string Title => "Il Battesimo";

		protected override string Description => "The 'Ndrina wants proof you can bleed without ending up in cuffs. Hit a cop, any cop. Then survive an hour clean. After that the famiglia will trust you with the real work — il contratto.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryAttack { get; private set; }

		public QuestEntry EntrySurvive { get; private set; }

		internal static BattesimoQuest Instance { get; private set; }

		public BattesimoQuest()
		{
			EntryAttack = ((Quest)this).AddEntry("Bleed for the famiglia — attack any cop and walk away", (Vector3?)null);
			EntrySurvive = ((Quest)this).AddEntry("Survive one hour clean, no arrests", (Vector3?)null);
			try
			{
				EntryAttack.ClearPOI();
			}
			catch
			{
			}
			try
			{
				EntrySurvive.ClearPOI();
			}
			catch
			{
			}
			Instance = this;
			Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");
			if ((Object)(object)val != (Object)null)
			{
				QuestIconHelper.ApplyAsync((Quest)(object)this, val);
			}
			NDLog.Debug("BattesimoQuest constructed.");
		}

		public static void EnsureCreated()
		{
			try
			{
				if (Instance == null && QuestManager.GetQuestByName("Il Battesimo") == null)
				{
					QuestManager.CreateQuest<BattesimoQuest>("Ndrangheta.battesimo");
					NDLog.Debug("BattesimoQuest created.");
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("BattesimoQuest.EnsureCreated: " + ex.Message);
			}
		}

		public static void EnsureFirstEntryActive()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				BattesimoQuest instance = Instance;
				if (instance?.EntryAttack != null && (int)instance.EntryAttack.State == 0)
				{
					instance.EntryAttack.Begin();
				}
			}
			catch
			{
			}
		}

		public static void OnAttackDetected()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			try
			{
				BattesimoQuest instance = Instance;
				if (instance?.EntryAttack != null && (int)instance.EntryAttack.State != 2)
				{
					instance.EntryAttack.Complete();
				}
				if (instance?.EntrySurvive != null && (int)instance.EntrySurvive.State == 0)
				{
					instance.EntrySurvive.Begin();
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("BattesimoQuest.OnAttackDetected: " + ex.Message);
			}
		}

		public static void OnSurvived()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				BattesimoQuest instance = Instance;
				if (instance?.EntrySurvive != null && (int)instance.EntrySurvive.State != 2)
				{
					instance.EntrySurvive.Complete();
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("BattesimoQuest.OnSurvived: " + ex.Message);
			}
		}

		public static void ClearInstanceForNext()
		{
			Instance = null;
		}
	}
	[QuestName("Pacco Bomba")]
	internal sealed class BombaMarkerQuestId : IQuestIdentifier
	{
	}
	internal sealed class BombaMarkerQuest : Quest
	{
		private static string _pendingText = "Pacco Bomba";

		internal static BombaMarkerQuest Instance { get; private set; }

		protected override string Title => "Pacco Bomba";

		protected override string Description => "The package is on its way. Keep your distance when it's armed.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public BombaMarkerQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			NDLog.Debug("[BOMBA] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					return;
				}
				_pendingText = text ?? "Pacco Bomba";
				string text2 = $"Ndrangheta.bomba.{DateTime.UtcNow.Ticks}";
				QuestManager.CreateQuest<BombaMarkerQuest>(text2);
				if (Instance != null && ((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("BombaMarkerQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		internal static void CompleteAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.Complete();
				}
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[BOMBA] marker quest cleared.");
		}
	}
	[QuestName("Brawl")]
	internal sealed class BrawlMarkerQuestId : IQuestIdentifier
	{
	}
	internal sealed class BrawlMarkerQuest : Quest
	{
		private static string _pendingText = "Brawl";

		internal static BrawlMarkerQuest Instance { get; private set; }

		protected override string Title => "Brawl";

		protected override string Description => "Our men are ready to crack skulls. Follow the marker.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public BrawlMarkerQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			NDLog.Debug("[BRAWL] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					return;
				}
				_pendingText = text ?? "Brawl";
				string text2 = $"Ndrangheta.brawl.{DateTime.UtcNow.Ticks}";
				QuestManager.CreateQuest<BrawlMarkerQuest>(text2);
				if (Instance != null && ((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("BrawlMarkerQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		internal static void CompleteAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				PoiIconHelper.SetPoiVisible(Instance.EntryMain, visible: false);
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.ClearPOI();
				}
			}
			catch
			{
			}
			try
			{
				Instance.ForceHideHudTracker();
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain2 = Instance.EntryMain;
				if (entryMain2 != null)
				{
					entryMain2.Complete();
				}
			}
			catch
			{
			}
			try
			{
				Instance.ForceHideHudTracker();
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[BRAWL] marker quest cleared.");
		}

		internal static void FailAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				PoiIconHelper.SetPoiVisible(Instance.EntryMain, visible: false);
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.ClearPOI();
				}
			}
			catch
			{
			}
			try
			{
				Instance.ForceHideHudTracker();
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain2 = Instance.EntryMain;
				if (entryMain2 != null)
				{
					entryMain2.SetState((QuestState)3);
				}
			}
			catch
			{
			}
			try
			{
				((Quest)Instance).Fail();
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[BRAWL] marker quest FAILED + cleared.");
		}

		private Quest TryGetVanillaQuest()
		{
			try
			{
				Type type = ((object)this).GetType();
				while (type != null)
				{
					PropertyInfo property = type.GetProperty("S1Quest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null)
					{
						object? value = property.GetValue(this);
						Quest val = (Quest)((value is Quest) ? value : null);
						if ((Object)(object)val != (Object)null)
						{
							return val;
						}
					}
					FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						if (!(fieldInfo.FieldType != typeof(Quest)))
						{
							object? value2 = fieldInfo.GetValue(this);
							Quest val2 = (Quest)((value2 is Quest) ? value2 : null);
							if ((Object)(object)val2 != (Object)null)
							{
								return val2;
							}
						}
					}
					type = type.BaseType;
				}
			}
			catch
			{
			}
			return null;
		}

		private void ForceHideHudTracker()
		{
			try
			{
				Quest val = TryGetVanillaQuest();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				try
				{
					val.TrackOnBegin = false;
				}
				catch
				{
				}
				try
				{
					((object)val).GetType().GetMethod("SetIsTracked", new Type[1] { typeof(bool) })?.Invoke(val, new object[1] { false });
				}
				catch
				{
				}
				try
				{
					((object)val).GetType().GetMethod("DestroyHUDUI", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val, null);
				}
				catch
				{
				}
				try
				{
					((object)val).GetType().GetMethod("DestroyJournalEntry", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val, null);
				}
				catch
				{
				}
			}
			catch
			{
			}
		}
	}
	[QuestName("Car Bomb")]
	internal sealed class CarBombMarkerQuestId : IQuestIdentifier
	{
	}
	internal sealed class CarBombMarkerQuest : Quest
	{
		private static string _pendingText = "Car Bomb";

		internal static CarBombMarkerQuest Instance { get; private set; }

		protected override string Title => "Car Bomb";

		protected override string Description => "The car's wired. Mark the spot, give the word, and get clear before the fuse runs out.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public CarBombMarkerQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			NDLog.Debug("[CARBOMB] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					return;
				}
				_pendingText = text ?? "Car Bomb";
				string text2 = $"Ndrangheta.carbomb.{DateTime.UtcNow.Ticks}";
				QuestManager.CreateQuest<CarBombMarkerQuest>(text2);
				if (Instance != null && ((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("CarBombMarkerQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		internal static void CompleteAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.Complete();
				}
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[CARBOMB] marker quest cleared.");
		}
	}
	[QuestName("Carico")]
	internal sealed class CaricoQuestId : IQuestIdentifier
	{
	}
	internal sealed class CaricoQuest : Quest
	{
		public static string CurrentJobGuid;

		private string _titleText;

		private string _descriptionText;

		private Vector3 _bPos;

		private Vector3 _donPos;

		protected override string Title => _titleText ?? "Carico";

		protected override string Description => _descriptionText ?? "Move a partita from one drop to another, then collect your share from the Don.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryPickup { get; private set; }

		public QuestEntry EntryDeliver { get; private set; }

		public QuestEntry EntryDropOff { get; private set; }

		internal static CaricoQuest Instance { get; private set; }

		public CaricoQuest()
		{
			EntryPickup = ((Quest)this).AddEntry("Pick up the partita", (Vector3?)null);
			EntryDeliver = ((Quest)this).AddEntry("Deliver the partita", (Vector3?)null);
			EntryDropOff = ((Quest)this).AddEntry("Collect your share from the Don", (Vector3?)null);
			Instance = this;
			NDLog.Debug("CaricoQuest constructed.");
		}

		public void Apply(string itemDisplayName, string itemId, int quantity, string aName, Vector3 aPos, string bName, Vector3 bPos, int reward)
		{
			//IL_004c: 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_00a0: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			_titleText = LoreStrings.CaricoTitle(itemDisplayName);
			_descriptionText = LoreStrings.CaricoDescription(itemDisplayName, itemId, quantity, aName, bName, reward);
			try
			{
				if (EntryPickup != null)
				{
					EntryPickup.Title = LoreStrings.CaricoEntryPickup(itemDisplayName, itemId, quantity, aName);
					EntryPickup.POIPosition = aPos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.deaddrop_quest.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(EntryPickup, val);
					}
				}
				if (EntryDeliver != null)
				{
					EntryDeliver.Title = LoreStrings.CaricoEntryDeliver(itemDisplayName, itemId, quantity, bName);
					_bPos = bPos;
					EntryDeliver.POIPosition = bPos;
					Sprite val2 = AssetLoader.LoadSprite("Ndrangheta.assets.deaddrop_quest.png");
					if ((Object)(object)val2 != (Object)null)
					{
						PoiIconHelper.ApplyAsync(EntryDeliver, val2);
					}
				}
				if (EntryDropOff != null)
				{
					EntryDropOff.Title = (TerritoryHandover.HandoverActive ? "Report to the cassa at the Gazebo for your share" : "Collect your share from Don Salvatore at the Gazebo");
					Vector3 val3 = ResolveDonWorldPos();
					if (val3 != Vector3.zero)
					{
						_donPos = val3;
						EntryDropOff.POIPosition = val3;
						Sprite val4 = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
						if ((Object)(object)val4 != (Object)null)
						{
							PoiIconHelper.ApplyAsync(EntryDropOff, val4);
						}
					}
					else
					{
						try
						{
							EntryDropOff.ClearPOI();
						}
						catch
						{
						}
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("CaricoQuest.Apply: " + ex.Message);
			}
			EnsureFirstEntryActive();
		}

		private static Vector3 ResolveDonWorldPos()
		{
			//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_0069: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			try
			{
				if (TerritoryHandover.HandoverActive)
				{
					if (DonSalvatoreNPC.ResolveGazeboPosition(out var pos))
					{
						return pos;
					}
					return Vector3.zero;
				}
				NPC cachedGameNpc = DonSalvatoreNPC.CachedGameNpc;
				if ((Object)(object)cachedGameNpc != (Object)null && (Object)(object)((Component)cachedGameNpc).transform != (Object)null)
				{
					return ((Component)cachedGameNpc).transform.position;
				}
			}
			catch
			{
			}
			return Vector3.zero;
		}

		public static void EnsureCreated()
		{
			try
			{
				if (Instance == null && QuestManager.GetQuestByName("Carico") == null)
				{
					CurrentJobGuid = $"Ndrangheta.carico.{DateTime.UtcNow.Ticks}";
					QuestManager.CreateQuest<CaricoQuest>(CurrentJobGuid);
					NDLog.Debug("CaricoQuest created.");
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("CaricoQuest.EnsureCreated: " + ex.Message);
			}
		}

		public static void CompletePickup()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryPickup != null && (int)instance.EntryPickup.State != 2)
				{
					instance.EntryPickup.Complete();
				}
				if (instance?.EntryDeliver != null && (int)instance.EntryDeliver.State == 0)
				{
					instance.EntryDeliver.Begin();
				}
				ReapplyDeliverIcon();
			}
			catch (Exception ex)
			{
				NDLog.Warn(ex.Message);
			}
		}

		public static void CompleteDeliver()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDeliver != null && (int)instance.EntryDeliver.State != 2)
				{
					instance.EntryDeliver.Complete();
				}
				if (instance?.EntryDropOff != null && (int)instance.EntryDropOff.State == 0)
				{
					instance.EntryDropOff.Begin();
				}
				ReapplyDropOffIcon();
			}
			catch (Exception ex)
			{
				NDLog.Warn(ex.Message);
			}
		}

		public static void CompleteDropOff()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDropOff != null && (int)instance.EntryDropOff.State != 2)
				{
					instance.EntryDropOff.Complete();
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn(ex.Message);
			}
		}

		public static void EnsureFirstEntryActive()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryPickup != null && (int)instance.EntryPickup.State == 0)
				{
					instance.EntryPickup.Begin();
				}
			}
			catch
			{
			}
		}

		private static void ReapplyDeliverIcon()
		{
			//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_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDeliver != null)
				{
					if (instance._bPos != Vector3.zero)
					{
						instance.EntryDeliver.POIPosition = instance._bPos;
					}
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.deaddrop_quest.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(instance.EntryDeliver, val);
					}
				}
			}
			catch
			{
			}
		}

		private static void ReapplyDropOffIcon()
		{
			//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_0023: 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_003b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDropOff != null)
				{
					Vector3 val = ResolveDonWorldPos();
					if (val == Vector3.zero)
					{
						val = instance._donPos;
					}
					if (val != Vector3.zero)
					{
						instance.EntryDropOff.POIPosition = val;
					}
					Sprite val2 = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val2 != (Object)null)
					{
						PoiIconHelper.ApplyAsync(instance.EntryDropOff, val2);
					}
				}
			}
			catch
			{
			}
		}

		public static void ClearInstanceForNext()
		{
			Instance = null;
		}
	}
	[QuestName("Il Circolo")]
	internal sealed class CircoloQuestId : IQuestIdentifier
	{
	}
	internal sealed class CircoloQuest : Quest
	{
		public const string QuestGuid = "Ndrangheta.circolo.marker";

		private static string _pendingText = "Il Circolo";

		internal static CircoloQuest Instance { get; private set; }

		protected override string Title => "Il Circolo";

		protected override string Description => "The famiglia's own front. The men hold the door.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public CircoloQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			Quest val = TryGetVanillaQuest();
			if ((Object)(object)val != (Object)null)
			{
				try
				{
					val.TrackOnBegin = false;
				}
				catch
				{
				}
			}
			NDLog.Debug("[CIRCOLO] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: 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)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					Instance.SuppressJournalAndHud();
					return;
				}
				_pendingText = text ?? "Il Circolo";
				QuestManager.CreateQuest<CircoloQuest>("Ndrangheta.circolo.marker");
				if (Instance == null)
				{
					return;
				}
				SetText(text);
				if (((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
				Instance.SuppressJournalAndHud();
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("CircoloQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos)

TheMob.Connector.Il2CPP.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using HarmonyLib;
using Il2Cpp;
using Il2CppFishNet;
using Il2CppFishNet.Connection;
using Il2CppFishNet.Managing;
using Il2CppFishNet.Object;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.Building;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.EntityFramework;
using Il2CppScheduleOne.Interaction;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.Money;
using Il2CppScheduleOne.Networking;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.Persistence.Datas;
using Il2CppScheduleOne.Persistence.Loaders;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Property;
using Il2CppScheduleOne.Quests;
using Il2CppScheduleOne.Storage;
using Il2CppScheduleOne.Tiles;
using Il2CppScheduleOne.Tools;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Compass;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Ndrangheta.Compat;
using Ndrangheta.Framework;
using Ndrangheta.Helper;
using S1API.Input;
using S1API.Internal.Abstraction;
using S1API.PhoneApp;
using S1API.Saveables;
using S1API.UI;
using S1API.Utils;
using S1MAPI.Core;
using S1MAPI.S1;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: MelonInfo(typeof(TheMobFrameworkMod), "TheMob Connector", "1.0.7", "Virtunerd", null)]
[assembly: MelonGame(null, "Schedule I")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: AssemblyInformationalVersion("1.0.7")]
[assembly: AssemblyVersion("1.0.7.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 Ndrangheta.UI
{
	public class FamigliaApp : PhoneApp
	{
		private static readonly Color MainBg = new Color(0.03f, 0.07f, 0.14f);

		private static readonly Color TopBarBg = new Color(0.05f, 0.1f, 0.19f);

		private static readonly Color NavBg = new Color(0.06f, 0.13f, 0.24f);

		private static readonly Color ContentBg = new Color(0.04f, 0.09f, 0.17f);

		private static readonly Color CardBg = new Color(0.02f, 0.05f, 0.1f);

		private static readonly Color SellBtn = new Color(0.42f, 0.12f, 0.12f);

		private static readonly Color LockedBg = new Color(0.05f, 0.1f, 0.18f);

		private static readonly Color LockedTxt = new Color(0.4f, 0.4f, 0.4f);

		private static readonly Color ErrorTxt = new Color(1f, 0.4f, 0.4f);

		private static readonly Color LoadPctColor = new Color(0.8f, 0.85f, 0.95f);

		private Color _accent = new Color(0.1f, 0.22f, 0.4f);

		private Color _gold = new Color(0.83f, 0.69f, 0.22f);

		private const int MinSelectSlots = 4;

		private const float APP_TOP = 0.89f;

		private const float APP_BOTTOM = 0.03f;

		private GameObject _selectPanel;

		private GameObject _loadingPanel;

		private GameObject _mainRoot;

		private RectTransform _loadFill;

		private Image _loadFillImg;

		private Text _loadPctText;

		private Text _loadFamilyText;

		private bool _loading;

		private Text _loadErrorText;

		private GameObject _loadBackBtn;

		private GameObject _homePage;

		private GameObject _realEstatePage;

		private GameObject _listaPage;

		private GameObject _cassaPage;

		private GameObject _furnishPage;

		private GameObject[] _pages;

		private RectTransform _reContent;

		private Text _statusText;

		private Text _homeTitleText;

		private Text _homeText;

		private Text _hqLabel;

		private Text _homeStatus;

		private Text _moralLadderText;

		private RectTransform _hqContent;

		private RectTransform _incomeHost;

		private GameObject _shopPage;

		private RectTransform _shopList;

		private Text _shopStatus;

		private GameObject _operationsPage;

		private RectTransform _operationsList;

		private Text _operationsStatus;

		private readonly List<object> _gifCoroutines = new List<object>();

		private Text _moralTitleText;

		private GameObject _faidaPage;

		private RectTransform _faidaList;

		private Text _faidaIntro;

		private Text _faidaTitleText;

		private Text _faidaNavText;

		private RectTransform _furnishContent;

		private GameObject _furnishTabsHost;

		private Text _furnishTitle;

		private int _furnishSurface;

		private IMobFurnishTarget _furnishTarget;

		private GameObject _furnishChooser;

		private GameObject _furnishEditor;

		private GameObject _furnishChooseHost;

		private GameObject _furnishReturnPage;

		internal static FamigliaApp Instance { get; private set; }

		private static MobFamily Active => MobFamilyRegistry.Active;

		protected override string AppName => "FamigliaApp";

		protected override string AppTitle => "TheMob";

		protected override string IconLabel => "TheMob";

		protected override string IconFileName => string.Empty;

		protected override void OnCreated()
		{
			((PhoneApp)this).OnCreated();
			Instance = this;
		}

		protected override void OnDestroyed()
		{
			Instance = null;
			((PhoneApp)this).OnDestroyed();
		}

		protected override void OnCreatedUI(GameObject container)
		{
			try
			{
				try
				{
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.appicon.png");
					if ((Object)(object)val != (Object)null)
					{
						((PhoneApp)this).SetIconSprite(val);
					}
				}
				catch (Exception ex)
				{
					NDLog.DebugWarn("[APP] icon: " + ex.Message);
				}
				BuildSelectPanel(container.transform);
				BuildLoadingPanel(container.transform);
				ShowSelect();
				NDLog.Debug($"[APP] TheMob app UI built (families={MobFamilyRegistry.All.Count}, intro flow active).");
			}
			catch (Exception ex2)
			{
				NDLog.Warn("[APP] OnCreatedUI: " + ex2.Message);
			}
		}

		protected override void OnPhoneClosed()
		{
			try
			{
				NDLog.Debug("[APP] OnPhoneClosed -> DestroyMain + ShowSelect.");
				_loading = false;
				DestroyMain();
				ShowSelect();
				Controls.IsTyping = false;
				try
				{
					EventSystem current = EventSystem.current;
					if (current != null)
					{
						current.SetSelectedGameObject((GameObject)null);
					}
				}
				catch
				{
				}
			}
			catch
			{
			}
			((PhoneApp)this).OnPhoneClosed();
		}

		private void BuildSelectPanel(Transform container)
		{
			//IL_0008: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			_selectPanel = MakePanel("SelectPanel", container, MainBg, null, null, fullAnchor: true);
			Text val = UIFactory.Text("SelTitle", "SELECT YOUR MOB", _selectPanel.transform, 24, (TextAnchor)1, (FontStyle)3);
			((Graphic)val).color = _gold;
			Rect(((Graphic)val).rectTransform, new Vector2(0.05f, 0.8f), new Vector2(0.95f, 0.95f));
			Text val2 = UIFactory.Text("SelSub", "Choose the family you run. Omerta above all.", _selectPanel.transform, 13, (TextAnchor)1, (FontStyle)2);
			((Graphic)val2).color = new Color(0.7f, 0.75f, 0.85f);
			Rect(((Graphic)val2).rectTransform, new Vector2(0.05f, 0.72f), new Vector2(0.95f, 0.8f));
			GameObject val3 = UIFactory.Panel("SelList", _selectPanel.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.2f, 0.1f), (Vector2?)new Vector2(0.8f, 0.7f), false);
			UIFactory.VerticalLayoutOnGO(val3, 10, new RectOffset(8, 8, 8, 8));
			IReadOnlyList<MobFamily> all = MobFamilyRegistry.All;
			if (all.Count == 0)
			{
				Text val4 = UIFactory.Text("SelNone", "TheMob Connector loaded, but no clans found.\n\nInstall a clan mod (e.g. Ndrangheta) to play.", val3.transform, 15, (TextAnchor)1, (FontStyle)2);
				((Graphic)val4).color = LockedTxt;
				LayoutElement val5 = ((Component)val4).gameObject.AddComponent<LayoutElement>();
				val5.minHeight = 140f;
				val5.preferredHeight = 140f;
				val5.flexibleWidth = 1f;
				return;
			}
			int num = Mathf.Max(4, all.Count);
			for (int i = 0; i < num; i++)
			{
				MobFamily mobFamily = ((i < all.Count) ? all[i] : null);
				bool flag = mobFamily?.Available ?? false;
				string text = ((mobFamily != null) ? mobFamily.DisplayName : "Coming Soon");
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel($"Fam_{i}", text, val3.transform, flag ? _accent : LockedBg, 0f, 44f, 16, flag ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement val6 = item.GetComponent<LayoutElement>();
				if ((Object)(object)val6 == (Object)null)
				{
					val6 = item.AddComponent<LayoutElement>();
				}
				val6.minHeight = 44f;
				val6.preferredHeight = 44f;
				val6.flexibleWidth = 1f;
				if (flag)
				{
					MobFamily picked = mobFamily;
					ButtonUtils.AddListener(item2, (Action)delegate
					{
						OnFamilyChosen(picked);
					});
				}
				else
				{
					try
					{
						((Selectable)item2).interactable = false;
					}
					catch
					{
					}
				}
			}
		}

		private void BuildLoadingPanel(Transform container)
		{
			//IL_0008: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: 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_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			_loadingPanel = MakePanel("LoadingPanel", container, MainBg, null, null, fullAnchor: true);
			_loadingPanel.SetActive(false);
			Text val = UIFactory.Text("LoadBrand", "THE MOB", _loadingPanel.transform, 30, (TextAnchor)7, (FontStyle)3);
			((Graphic)val).color = _gold;
			Rect(((Graphic)val).rectTransform, new Vector2(0.1f, 0.6f), new Vector2(0.9f, 0.74f));
			_loadFamilyText = UIFactory.Text("LoadFamily", "", _loadingPanel.transform, 15, (TextAnchor)1, (FontStyle)2);
			((Graphic)_loadFamilyText).color = Color.white;
			Rect(((Graphic)_loadFamilyText).rectTransform, new Vector2(0.1f, 0.52f), new Vector2(0.9f, 0.6f));
			GameObject val2 = UIFactory.Panel("LoadTrack", _loadingPanel.transform, new Color(0.02f, 0.05f, 0.1f), (Vector2?)new Vector2(0.2f, 0.4f), (Vector2?)new Vector2(0.8f, 0.46f), false);
			GameObject val3 = UIFactory.Panel("LoadFill", val2.transform, _gold, (Vector2?)new Vector2(0f, 0f), (Vector2?)new Vector2(0f, 1f), false);
			_loadFill = val3.GetComponent<RectTransform>();
			_loadFillImg = val3.GetComponent<Image>();
			_loadPctText = UIFactory.Text("LoadPct", "LOADING  0%", _loadingPanel.transform, 14, (TextAnchor)1, (FontStyle)0);
			((Graphic)_loadPctText).color = LoadPctColor;
			Rect(((Graphic)_loadPctText).rectTransform, new Vector2(0.1f, 0.31f), new Vector2(0.9f, 0.39f));
			_loadErrorText = UIFactory.Text("LoadError", "", _loadingPanel.transform, 13, (TextAnchor)1, (FontStyle)2);
			((Graphic)_loadErrorText).color = ErrorTxt;
			Rect(((Graphic)_loadErrorText).rectTransform, new Vector2(0.12f, 0.13f), new Vector2(0.88f, 0.29f));
			((Component)_loadErrorText).gameObject.SetActive(false);
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("LoadBack", "< BACK", _loadingPanel.transform, _accent, 0f, 32f, 13, Color.white);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			_loadBackBtn = item;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.35f, 0.04f);
				component.anchorMax = new Vector2(0.65f, 0.11f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			ButtonUtils.AddListener(item2, (Action)BackToSelectFromLoad);
			_loadBackBtn.SetActive(false);
		}

		private void ShowSelect()
		{
			try
			{
				if ((Object)(object)_loadingPanel != (Object)null)
				{
					_loadingPanel.SetActive(false);
				}
				if ((Object)(object)_selectPanel != (Object)null)
				{
					_selectPanel.SetActive(true);
				}
			}
			catch
			{
			}
		}

		private void OnFamilyChosen(MobFamily family)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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)
			try
			{
				MobFamilyRegistry.SetActive(family);
				if ((Object)(object)_selectPanel != (Object)null)
				{
					_selectPanel.SetActive(false);
				}
				if ((Object)(object)_loadingPanel != (Object)null)
				{
					_loadingPanel.SetActive(true);
				}
				if ((Object)(object)_loadFamilyText != (Object)null)
				{
					_loadFamilyText.text = ((family != null) ? ("Connecting to " + family.DisplayName + "...") : "");
				}
				if ((Object)(object)_loadFill != (Object)null)
				{
					_loadFill.anchorMin = new Vector2(0f, 0f);
					_loadFill.anchorMax = new Vector2(0f, 1f);
					_loadFill.offsetMin = Vector2.zero;
					_loadFill.offsetMax = Vector2.zero;
				}
				if ((Object)(object)_loadFillImg != (Object)null)
				{
					((Graphic)_loadFillImg).color = _gold;
				}
				if ((Object)(object)_loadPctText != (Object)null)
				{
					_loadPctText.text = "LOADING  0%";
					((Graphic)_loadPctText).color = LoadPctColor;
				}
				if ((Object)(object)_loadErrorText != (Object)null)
				{
					((Component)_loadErrorText).gameObject.SetActive(false);
				}
				if ((Object)(object)_loadBackBtn != (Object)null)
				{
					_loadBackBtn.SetActive(false);
				}
				_loading = true;
				MelonCoroutines.Start(LoadingRoutine());
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] OnFamilyChosen: " + ex.Message);
				RevealMain();
			}
		}

		private IEnumerator LoadingRoutine()
		{
			bool unlocked;
			try
			{
				unlocked = Active?.AppUnlocked ?? true;
			}
			catch
			{
				unlocked = true;
			}
			if (unlocked)
			{
				yield return null;
				try
				{
					if (Active != null)
					{
						_ = Active.Operations;
					}
				}
				catch (Exception ex)
				{
					Exception px = ex;
					NDLog.DebugWarn("[APP] GIF preload: " + px.Message);
				}
				float t = 0f;
				while (t < 2.2f)
				{
					if (!_loading || Instance != this)
					{
						yield break;
					}
					t += Time.deltaTime;
					float frac = Mathf.Clamp01(t / 2.2f);
					try
					{
						if ((Object)(object)_loadFill != (Object)null)
						{
							_loadFill.anchorMax = new Vector2(frac, 1f);
						}
						if ((Object)(object)_loadPctText != (Object)null)
						{
							_loadPctText.text = $"LOADING  {Mathf.RoundToInt(frac * 100f)}%";
						}
					}
					catch
					{
					}
					yield return null;
				}
				RevealMain();
				yield break;
			}
			float et = 0f;
			bool hung = false;
			while (et < 1.6f)
			{
				if (!_loading || Instance != this)
				{
					yield break;
				}
				et += Time.deltaTime;
				float frac2 = Mathf.Clamp01(et / 1.6f) * 0.7f;
				try
				{
					if ((Object)(object)_loadFill != (Object)null)
					{
						_loadFill.anchorMax = new Vector2(frac2, 1f);
					}
					if ((Object)(object)_loadPctText != (Object)null)
					{
						_loadPctText.text = $"CONNECTING  {Mathf.RoundToInt(frac2 * 100f)}%";
					}
				}
				catch
				{
				}
				yield return null;
				if (!hung && et >= 0.88000005f)
				{
					hung = true;
					if (!_loading || Instance != this)
					{
						yield break;
					}
					yield return (object)new WaitForSeconds(0.45f);
				}
			}
			ShowLoadError();
		}

		private void ShowLoadError()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_loading = false;
				MobFamily active = Active;
				string text = ((active != null) ? (active.AppLockedTitle ?? "ACCESS DENIED") : "ACCESS DENIED");
				string text2 = ((active != null) ? (active.AppLockedText ?? "") : "");
				if ((Object)(object)_loadFillImg != (Object)null)
				{
					((Graphic)_loadFillImg).color = ErrorTxt;
				}
				if ((Object)(object)_loadFill != (Object)null)
				{
					_loadFill.anchorMax = new Vector2(0.7f, 1f);
				}
				if ((Object)(object)_loadPctText != (Object)null)
				{
					_loadPctText.text = "ERROR  —  " + text;
					((Graphic)_loadPctText).color = ErrorTxt;
				}
				if ((Object)(object)_loadFamilyText != (Object)null)
				{
					_loadFamilyText.text = "CONNECTION REFUSED";
				}
				if ((Object)(object)_loadErrorText != (Object)null)
				{
					_loadErrorText.text = text2;
					((Component)_loadErrorText).gameObject.SetActive(true);
				}
				if ((Object)(object)_loadBackBtn != (Object)null)
				{
					_loadBackBtn.SetActive(true);
				}
				NDLog.Debug("[APP] loading gate -> locked (player is not boss yet).");
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ShowLoadError: " + ex.Message);
			}
		}

		private void BackToSelectFromLoad()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_loading = false;
				if ((Object)(object)_loadErrorText != (Object)null)
				{
					((Component)_loadErrorText).gameObject.SetActive(false);
				}
				if ((Object)(object)_loadBackBtn != (Object)null)
				{
					_loadBackBtn.SetActive(false);
				}
				if ((Object)(object)_loadFillImg != (Object)null)
				{
					((Graphic)_loadFillImg).color = _gold;
				}
				if ((Object)(object)_loadPctText != (Object)null)
				{
					((Graphic)_loadPctText).color = LoadPctColor;
				}
				ShowSelect();
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] BackToSelectFromLoad: " + ex.Message);
			}
		}

		private void RevealMain()
		{
			try
			{
				bool flag = true;
				try
				{
					flag = Active?.AppUnlocked ?? true;
				}
				catch
				{
					flag = true;
				}
				if (!flag)
				{
					ShowLoadError();
					return;
				}
				_loading = false;
				if ((Object)(object)_loadingPanel != (Object)null)
				{
					_loadingPanel.SetActive(false);
				}
				if ((Object)(object)_selectPanel != (Object)null)
				{
					_selectPanel.SetActive(false);
				}
				BuildMain(Active);
				if ((Object)(object)_mainRoot != (Object)null)
				{
					_mainRoot.SetActive(true);
				}
				SetActivePage(_homePage, refreshHome: true);
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] RevealMain: " + ex.Message);
			}
		}

		private void DestroyMain()
		{
			try
			{
				if ((Object)(object)_mainRoot != (Object)null)
				{
					Object.Destroy((Object)(object)_mainRoot);
				}
			}
			catch
			{
			}
			_mainRoot = null;
			_homePage = (_realEstatePage = (_listaPage = (_cassaPage = (_furnishPage = null))));
			_pages = null;
			_reContent = null;
			_statusText = null;
			_homeTitleText = null;
			_homeText = null;
			_hqLabel = null;
			_homeStatus = null;
			_hqContent = null;
			_incomeHost = null;
			_shopPage = null;
			_shopList = null;
			_shopStatus = null;
			StopGifs();
			_operationsPage = null;
			_operationsList = null;
			_operationsStatus = null;
			_furnishContent = null;
			_furnishTabsHost = null;
			_furnishTitle = null;
			_furnishChooser = (_furnishEditor = (_furnishChooseHost = null));
			_furnishTarget = null;
			_furnishReturnPage = null;
			_moralTitleText = null;
			_moralLadderText = null;
			_faidaPage = null;
			_faidaList = null;
			_faidaIntro = null;
			_faidaTitleText = null;
			_faidaNavText = null;
		}

		private void BuildMain(MobFamily fam)
		{
			//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_002c: 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_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: 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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: 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_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			DestroyMain();
			NDLog.Debug("[APP] BuildMain — Haupt-UI (neu) gebaut.");
			if (fam != null)
			{
				_accent = fam.Accent;
				_gold = fam.Highlight;
			}
			Transform val = (((Object)(object)_selectPanel != (Object)null) ? _selectPanel.transform.parent : (((Object)(object)_loadingPanel != (Object)null) ? _loadingPanel.transform.parent : null));
			if ((Object)(object)val == (Object)null)
			{
				NDLog.Warn("[APP] BuildMain: no container.");
				return;
			}
			GameObject val2 = (_mainRoot = UIFactory.Panel("FamigliaMainBG", val, MainBg, (Vector2?)new Vector2(0f, 0.03f), (Vector2?)new Vector2(1f, 0.89f), false));
			GameObject val3 = MakePanel("TopBar", val2.transform, TopBarBg, (Vector2?)new Vector2(0.039f, 0.934f), (Vector2?)new Vector2(0.962f, 1.036f), fullAnchor: false);
			string text = ((fam != null) ? fam.BrandTitle : "THE MOB");
			Text val4 = UIFactory.Text("Brand", text, val3.transform, 21, (TextAnchor)6, (FontStyle)3);
			((Graphic)val4).color = _gold;
			Rect(((Graphic)val4).rectTransform, new Vector2(0.02f, 0.35f), new Vector2(0.4f, 0.99f));
			string text2 = ((fam != null) ? fam.BrandSubtitle : "");
			Text val5 = UIFactory.Text("BrandSub", text2 ?? "", val3.transform, 12, (TextAnchor)0, (FontStyle)2);
			((Graphic)val5).color = new Color(0.6f, 0.65f, 0.75f);
			Rect(((Graphic)val5).rectTransform, new Vector2(0.02f, 0.03f), new Vector2(0.4f, 0.35f));
			_moralTitleText = UIFactory.Text("MoralTitle", (fam != null) ? (fam.MoralTitle ?? "") : "", val3.transform, 17, (TextAnchor)4, (FontStyle)3);
			((Graphic)_moralTitleText).color = _gold;
			_moralTitleText.horizontalOverflow = (HorizontalWrapMode)1;
			_moralTitleText.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_moralTitleText).rectTransform, new Vector2(0.4f, 0.05f), new Vector2(0.66f, 1.01f));
			Text val6 = UIFactory.Text("LoginAs", "LOGGED IN AS:  BOSS", val3.transform, 12, (TextAnchor)5, (FontStyle)1);
			((Graphic)val6).color = _gold;
			Rect(((Graphic)val6).rectTransform, new Vector2(0.66f, 0.01f), new Vector2(0.975f, 1.01f));
			GameObject val7 = MakePanel("NavPanel", val2.transform, NavBg, (Vector2?)new Vector2(0.041f, 0.028f), (Vector2?)new Vector2(0.248f, 0.932f), fullAnchor: false);
			GameObject val8 = MakePanel("NavPhoto", val7.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.005f, 0.508f), (Vector2?)new Vector2(0.715f, 1.036f), fullAnchor: false);
			try
			{
				Sprite val9 = null;
				try
				{
					val9 = Active?.HomeImage;
				}
				catch
				{
				}
				if ((Object)(object)val9 == (Object)null)
				{
					val9 = AssetLoader.LoadSprite("Ndrangheta.assets.icon_hometab.png");
				}
				if ((Object)(object)val9 != (Object)null)
				{
					GameObject val10 = new GameObject("NavPhotoImg");
					val10.transform.SetParent(val8.transform, false);
					Image val11 = val10.AddComponent<Image>();
					val11.sprite = val9;
					val11.preserveAspect = true;
					((Graphic)val11).raycastTarget = false;
					RectTransform component = val10.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.017f, 0.024f), new Vector2(1.3f, 1.3f));
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] NavPhoto: " + ex.Message);
			}
			GameObject val12 = MakePanel("NavTabsHost", val7.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.016f, 0.064f), (Vector2?)new Vector2(0.925f, 0.725f), fullAnchor: false);
			ScrollRect val14 = default(ScrollRect);
			RectTransform val13 = UIFactory.ScrollableVerticalList("NavList", val12.transform, ref val14);
			try
			{
				if ((Object)(object)val14 != (Object)null)
				{
					val14.horizontal = false;
					val14.vertical = true;
					val14.scrollSensitivity = 18f;
				}
				VerticalLayoutGroup component2 = ((Component)val13).GetComponent<VerticalLayoutGroup>();
				if ((Object)(object)component2 != (Object)null)
				{
					((HorizontalOrVerticalLayoutGroup)component2).spacing = 8f;
					((LayoutGroup)component2).padding = new RectOffset(8, 8, 12, 10);
					((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false;
					((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
					((LayoutGroup)component2).childAlignment = (TextAnchor)1;
				}
			}
			catch
			{
			}
			UIFactory.FitContentHeight(val13);
			HardenScrollClip(val14);
			GameObject val15 = MakePanel("ContentArea", val2.transform, ContentBg, (Vector2?)new Vector2(0.245f, 0.055f), (Vector2?)new Vector2(0.959f, 0.934f), fullAnchor: false);
			_homePage = BuildHomePage(val15.transform);
			_realEstatePage = BuildRealEstatePage(val15.transform);
			_listaPage = null;
			_cassaPage = null;
			_furnishPage = BuildFurnishPage(val15.transform);
			_shopPage = BuildShopPage(val15.transform);
			_faidaPage = BuildFaidaPage(val15.transform);
			_operationsPage = BuildOperationsPage(val15.transform);
			_pages = (GameObject[])(object)new GameObject[6] { _homePage, _realEstatePage, _furnishPage, _shopPage, _faidaPage, _operationsPage };
			AddNavButton((Transform)(object)val13, "Home", locked: false, delegate
			{
				SetActivePage(_homePage, refreshHome: true);
			});
			AddNavButton((Transform)(object)val13, "Real Estate", locked: false, delegate
			{
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
			});
			AddNavButton((Transform)(object)val13, "Little Helper", locked: false, delegate
			{
				SetActivePage(_shopPage);
				RefreshShop();
			});
			_faidaNavText = AddNavButton((Transform)(object)val13, "Faida", locked: false, delegate
			{
				SetActivePage(_faidaPage);
				RefreshFaida();
			});
			AddNavButton((Transform)(object)val13, "Operations", locked: false, delegate
			{
				SetActivePage(_operationsPage);
				RefreshOperations();
			});
			SetActivePage(_homePage, refreshHome: true);
			DisableContainerRaycasts(_mainRoot);
		}

		private GameObject BuildHomePage(Transform parent)
		{
			//IL_001b: 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_0081: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("HomePage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			_homeTitleText = UIFactory.Text("HomeTitle", "", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)_homeTitleText).color = _gold;
			Rect(((Graphic)_homeTitleText).rectTransform, new Vector2(0.045f, 0.875f), new Vector2(0.959f, 0.965f));
			_moralLadderText = UIFactory.Text("HomeMoralLadder", "", val.transform, 11, (TextAnchor)2, (FontStyle)0);
			((Graphic)_moralLadderText).color = Color.white;
			_moralLadderText.horizontalOverflow = (HorizontalWrapMode)0;
			_moralLadderText.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_moralLadderText).rectTransform, new Vector2(0.49f, 0.7f), new Vector2(0.965f, 0.965f));
			_homeText = UIFactory.Text("HomeBody", "", val.transform, 14, (TextAnchor)0, (FontStyle)0);
			((Graphic)_homeText).color = Color.white;
			Rect(((Graphic)_homeText).rectTransform, new Vector2(0.046f, 0.639f), new Vector2(0.474f, 0.904f));
			_hqLabel = UIFactory.Text("HomeHqLabel", "", val.transform, 14, (TextAnchor)6, (FontStyle)1);
			((Graphic)_hqLabel).color = _gold;
			Rect(((Graphic)_hqLabel).rectTransform, new Vector2(0.719f, 0.65f), new Vector2(1.115f, 0.71f));
			_homeStatus = UIFactory.Text("HomeStatus", "", val.transform, 12, (TextAnchor)6, (FontStyle)2);
			((Graphic)_homeStatus).color = _gold;
			_homeStatus.horizontalOverflow = (HorizontalWrapMode)0;
			_homeStatus.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_homeStatus).rectTransform, new Vector2(0.715f, 0.72f), new Vector2(0.98f, 0.865f));
			GameObject val2 = MakePanel("HomeHqHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.715f, 0.005f), (Vector2?)new Vector2(0.98f, 0.636f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_hqContent = UIFactory.ScrollableVerticalList("HomeHqList", val2.transform, ref sr);
			UIFactory.FitContentHeight(_hqContent);
			HardenScrollClip(sr);
			Text val3 = UIFactory.Text("HomeIncomeLabel", "INCOME", val.transform, 14, (TextAnchor)6, (FontStyle)1);
			((Graphic)val3).color = _gold;
			Rect(((Graphic)val3).rectTransform, new Vector2(0.053f, 0.487f), new Vector2(0.164f, 0.628f));
			GameObject val4 = MakePanel("HomeIncomeHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.047f, 0.361f), (Vector2?)new Vector2(0.322f, 0.478f), fullAnchor: false);
			_incomeHost = val4.GetComponent<RectTransform>();
			return val;
		}

		private void RefreshHome()
		{
			try
			{
				MobFamily active = Active;
				if ((Object)(object)_faidaNavText != (Object)null)
				{
					_faidaNavText.text = ((active != null) ? (active.FaidaTitle ?? "FAIDA") : "FAIDA");
				}
				if ((Object)(object)_homeTitleText != (Object)null)
				{
					_homeTitleText.text = ((active != null) ? active.HomeTitle : "");
				}
				if ((Object)(object)_moralTitleText != (Object)null)
				{
					_moralTitleText.text = ((active != null) ? (active.MoralTitle ?? "") : "");
				}
				if ((Object)(object)_moralLadderText != (Object)null)
				{
					_moralLadderText.text = ((active != null) ? (active.MoralLadder ?? "") : "");
				}
				if ((Object)(object)_homeText != (Object)null)
				{
					_homeText.text = ((active != null) ? active.GetHomeText() : "");
				}
				RefreshIncomeBars();
				BuildHeadquarter(active);
			}
			catch
			{
			}
		}

		private void RefreshIncomeBars()
		{
			//IL_0054: 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)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)_incomeHost == (Object)null))
				{
					UIFactory.ClearChildren(((Component)_incomeHost).transform);
					Color color = default(Color);
					((Color)(ref color))..ctor(0.82f, 0.86f, 0.94f);
					IncomeStatRow("TOTAL EARNED", IncomeTracker.TotalIncome, 0.67f, 1f, _gold, emphasize: true);
					IncomeStatRow("Quests", IncomeTracker.QuestIncome, 0.345f, 0.655f, color, emphasize: false);
					IncomeStatRow("Other", IncomeTracker.OtherIncome, 0f, 0.33f, color, emphasize: false);
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] RefreshIncomeBars: " + ex.Message);
			}
		}

		private void IncomeStatRow(string name, long amount, float yBot, float yTop, Color color, bool emphasize)
		{
			//IL_0025: 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_004d: 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_0096: 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)
			Text val = UIFactory.Text("IncR_" + name, name, (Transform)(object)_incomeHost, 12, (TextAnchor)3, (FontStyle)(emphasize ? 1 : 0));
			((Graphic)val).color = color;
			val.horizontalOverflow = (HorizontalWrapMode)1;
			Rect(((Graphic)val).rectTransform, new Vector2(0.02f, yBot), new Vector2(0.62f, yTop));
			Text val2 = UIFactory.Text("IncRV_" + name, CompactMoney(amount), (Transform)(object)_incomeHost, 12, (TextAnchor)5, (FontStyle)1);
			((Graphic)val2).color = color;
			val2.horizontalOverflow = (HorizontalWrapMode)1;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.4f, yBot), new Vector2(0.98f, yTop));
		}

		private static string CompactMoney(long v)
		{
			if (v < 1000000)
			{
				if (v < 1000)
				{
					return $"${v}";
				}
				return $"${(float)v / 1000f:0.0}K";
			}
			return $"${(float)v / 1000000f:0.0}M";
		}

		private void BuildHeadquarter(MobFamily fam)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_hqContent == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_hqContent).transform);
				IReadOnlyList<IMobAction> readOnlyList = fam?.HeadquarterActions;
				bool flag = readOnlyList != null && readOnlyList.Count > 0;
				if ((Object)(object)_hqLabel != (Object)null)
				{
					_hqLabel.text = (flag ? (fam.HeadquarterTitle ?? "HEADQUARTER") : "");
				}
				if (!flag)
				{
					return;
				}
				if (!fam.HeadquarterUnlocked)
				{
					Text val = UIFactory.Text("HqLocked", fam.HeadquarterLockedText ?? "Locked.", (Transform)(object)_hqContent, 13, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 90f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					IMobAction mobAction = readOnlyList[i];
					if (mobAction != null)
					{
						bool enabled = false;
						try
						{
							enabled = mobAction.Available;
						}
						catch
						{
						}
						string label = "";
						try
						{
							label = mobAction.Label ?? "";
						}
						catch
						{
						}
						IMobAction picked = mobAction;
						AddHqButton("Hq_" + (mobAction.Key ?? i.ToString()), label, enabled, delegate
						{
							InvokeHqAction(picked);
						});
					}
				}
				UIFactory.FitContentHeight(_hqContent);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] BuildHeadquarter: " + ex.Message);
			}
		}

		private void AddHqButton(string key, string label, bool enabled, Action onClick)
		{
			//IL_0015: 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_0030: 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)
			try
			{
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(key, label, (Transform)(object)_hqContent, enabled ? _accent : LockedBg, 0f, 40f, 14, enabled ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement val = item.GetComponent<LayoutElement>();
				if ((Object)(object)val == (Object)null)
				{
					val = item.AddComponent<LayoutElement>();
				}
				val.minHeight = 40f;
				val.preferredHeight = 40f;
				val.flexibleWidth = 1f;
				if (enabled && onClick != null)
				{
					ButtonUtils.AddListener(item2, onClick);
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] HqButton " + key + ": " + ex.Message);
			}
		}

		private void InvokeHqAction(IMobAction action)
		{
			if (action == null)
			{
				return;
			}
			try
			{
				MobAppTab mobAppTab = MobAppTab.None;
				try
				{
					mobAppTab = action.NavigateTo;
				}
				catch
				{
				}
				if (mobAppTab != MobAppTab.None)
				{
					NavigateToTab(mobAppTab);
					return;
				}
				string message;
				bool ok = action.Invoke(out message);
				RefreshHome();
				SetHomeStatus(message, ok);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] InvokeHqAction: " + ex.Message);
				SetHomeStatus("Couldn't reach the famiglia right now.", ok: false);
			}
		}

		private void SetHomeStatus(string msg, bool ok)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)_homeStatus == (Object)null))
				{
					_homeStatus.text = msg ?? "";
					((Graphic)_homeStatus).color = (ok ? _gold : ErrorTxt);
				}
			}
			catch
			{
			}
		}

		private void NavigateToTab(MobAppTab tab)
		{
			switch (tab)
			{
			case MobAppTab.RealEstate:
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
				break;
			case MobAppTab.Furnish:
				OpenFurnishFromRealEstate();
				break;
			case MobAppTab.ListaNera:
				SetActivePage(_listaPage);
				break;
			case MobAppTab.Cassa:
				SetActivePage(_cassaPage);
				break;
			case MobAppTab.Faida:
				SetActivePage(_faidaPage);
				RefreshFaida();
				break;
			default:
				SetActivePage(_homePage, refreshHome: true);
				break;
			}
		}

		private GameObject BuildRealEstatePage(Transform parent)
		{
			//IL_001b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("RealEstatePage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text("RETitle", "REAL ESTATE", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.055f, 0.885f), new Vector2(0.315f, 0.975f));
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("REFurnishBtn", "FURNISH", val.transform, _gold, 0f, 28f, 13, MainBg);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.055f, 0.877f);
				component.anchorMax = new Vector2(0.204f, 0.919f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			WireClick(item2, OpenFurnishFromRealEstate);
			_statusText = UIFactory.Text("REStatus", "", val.transform, 13, (TextAnchor)2, (FontStyle)2);
			((Graphic)_statusText).color = _gold;
			Rect(((Graphic)_statusText).rectTransform, new Vector2(0.55f, 0.9f), new Vector2(0.92f, 0.99f));
			GameObject val3 = MakePanel("REListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.05f, -0.009f), (Vector2?)new Vector2(0.984f, 0.815f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_reContent = UIFactory.ScrollableVerticalList("REList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_reContent);
			HardenScrollClip(sr);
			return val;
		}

		internal void RefreshRealEstate()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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)
			try
			{
				MobFamily active = Active;
				if ((Object)(object)_reContent == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_reContent).transform);
				if (active == null)
				{
					return;
				}
				if (!active.RealEstateUnlocked)
				{
					Text val = UIFactory.Text("RELocked", active.RealEstateLockedText, (Transform)(object)_reContent, 15, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 120f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					return;
				}
				IReadOnlyList<IMobProperty> properties = active.Properties;
				if (properties == null)
				{
					return;
				}
				for (int i = 0; i < properties.Count; i++)
				{
					if (properties[i] != null)
					{
						AddPropertyCard(properties[i]);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshRealEstate: " + ex.Message);
			}
		}

		private void AddPropertyCard(IMobProperty p)
		{
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: 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)
			//IL_0265: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = p.Key ?? "prop";
				GameObject val = MakePanel("Card_" + text, (Transform)(object)_reContent, CardBg);
				AddLayout(val, 100f);
				Sprite val2 = null;
				try
				{
					val2 = p.Image;
				}
				catch
				{
				}
				if ((Object)(object)val2 != (Object)null)
				{
					GameObject val3 = new GameObject(text + "_Img");
					val3.transform.SetParent(val.transform, false);
					Image val4 = val3.AddComponent<Image>();
					val4.sprite = val2;
					val4.preserveAspect = true;
					((Graphic)val4).raycastTarget = false;
					RectTransform component = val3.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.04f, 0.14f), new Vector2(0.22f, 0.86f));
					}
				}
				bool flag = false;
				try
				{
					flag = p.Owned;
				}
				catch
				{
				}
				string text2 = "";
				try
				{
					text2 = p.Name ?? "";
				}
				catch
				{
				}
				string text3 = "";
				try
				{
					text3 = p.Description ?? "";
				}
				catch
				{
				}
				string text4 = "";
				try
				{
					text4 = p.StatusText ?? "";
				}
				catch
				{
				}
				Text val5 = UIFactory.Text(text + "_Name", text2, val.transform, 15, (TextAnchor)0, (FontStyle)1);
				((Graphic)val5).color = Color.white;
				val5.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val5).rectTransform, new Vector2(0.24f, 0.55f), new Vector2(0.69f, 0.93f));
				Text val6 = UIFactory.Text(text + "_Desc", text3, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val6).color = new Color(0.75f, 0.78f, 0.85f);
				val6.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val6).rectTransform, new Vector2(0.24f, 0.08f), new Vector2(0.69f, 0.5f));
				Text val7 = UIFactory.Text(text + "_Status", text4, val.transform, 15, (TextAnchor)4, (FontStyle)1);
				((Graphic)val7).color = (flag ? _gold : Color.white);
				Rect(((Graphic)val7).rectTransform, new Vector2(0.71f, 0.55f), new Vector2(0.95f, 0.93f));
				if (flag)
				{
					AddCardButton(val, text + "_Sell", "SELL", SellBtn, delegate
					{
						string message;
						bool ok = p.Sell(out message);
						SetStatus(message, ok);
						RefreshRealEstate();
					});
				}
				else
				{
					AddCardButton(val, text + "_Buy", "BUY", _accent, delegate
					{
						string message;
						bool ok = p.Buy(out message);
						SetStatus(message, ok);
						RefreshRealEstate();
					});
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] Card " + p?.Key + ": " + ex.Message);
			}
		}

		private void AddCardButton(GameObject card, string name, string label, Color color, Action onClick)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(name, label, card.transform, color, 0f, 30f, 14, Color.white);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.71f, 0.12f);
				component.anchorMax = new Vector2(0.95f, 0.46f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			if (onClick != null)
			{
				ButtonUtils.AddListener(item2, onClick);
			}
		}

		private GameObject BuildLockedPage(Transform parent, string name, string title, string body)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			GameObject val = MakePanel(name, parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text(name + "_Title", title, val.transform, 20, (TextAnchor)1, (FontStyle)1);
			((Graphic)val2).color = LockedTxt;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.05f, 0.85f), new Vector2(0.95f, 0.97f));
			Text val3 = UIFactory.Text(name + "_Body", body, val.transform, 14, (TextAnchor)1, (FontStyle)0);
			((Graphic)val3).color = LockedTxt;
			Rect(((Graphic)val3).rectTransform, new Vector2(0.05f, 0.2f), new Vector2(0.95f, 0.82f));
			return val;
		}

		private GameObject BuildShopPage(Transform parent)
		{
			//IL_001b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("ShopPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text("ShopTitle", "LITTLE HELPER", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.04f, 0.895f), new Vector2(0.545f, 0.961f));
			_shopStatus = UIFactory.Text("ShopStatus", "", val.transform, 13, (TextAnchor)2, (FontStyle)2);
			((Graphic)_shopStatus).color = _gold;
			Rect(((Graphic)_shopStatus).rectTransform, new Vector2(0.56f, 0.9f), new Vector2(0.97f, 0.99f));
			GameObject val3 = MakePanel("ShopListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.021f, 0.005f), (Vector2?)new Vector2(0.983f, 0.865f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_shopList = UIFactory.ScrollableVerticalList("ShopList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_shopList);
			HardenScrollClip(sr);
			return val;
		}

		private void RefreshShop()
		{
			//IL_006c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_shopList == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_shopList).transform);
				IReadOnlyList<MobShopItem> readOnlyList = Active?.ShopItems;
				if (readOnlyList == null || readOnlyList.Count == 0)
				{
					Text val = UIFactory.Text("ShopNone", "Nothing in stock right now.", (Transform)(object)_shopList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 60f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_shopList);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					MobShopItem mobShopItem = readOnlyList[i];
					if (mobShopItem != null)
					{
						MobShopItem picked = mobShopItem;
						AddShopCard(picked.Key ?? i.ToString(), picked.Name ?? "", picked.Description ?? "", picked.Price, () => picked.Buy != null && picked.Buy(), picked.IconFunc);
					}
				}
				UIFactory.FitContentHeight(_shopList);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshShop: " + ex.Message);
			}
		}

		private void AddShopCard(string key, string name, string desc, int price, Func<bool> give, Func<Sprite> icon)
		{
			//IL_0020: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: 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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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)
			try
			{
				GameObject val = MakePanel("Shop_" + key, (Transform)(object)_shopList, CardBg);
				AddLayout(val, 96f);
				Sprite val2 = null;
				try
				{
					val2 = icon?.Invoke();
				}
				catch
				{
				}
				float num = 0.09f;
				if ((Object)(object)val2 != (Object)null)
				{
					GameObject val3 = new GameObject(key + "_Icon");
					val3.transform.SetParent(val.transform, false);
					Image val4 = val3.AddComponent<Image>();
					val4.sprite = val2;
					val4.preserveAspect = true;
					((Graphic)val4).raycastTarget = false;
					RectTransform component = val3.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.035f, 0.12f), new Vector2(0.235f, 0.88f));
					}
					num = 0.27f;
				}
				Text val5 = UIFactory.Text(key + "_Name", name, val.transform, 15, (TextAnchor)0, (FontStyle)1);
				((Graphic)val5).color = Color.white;
				val5.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val5).rectTransform, new Vector2(num, 0.55f), new Vector2(0.64f, 0.92f));
				Text val6 = UIFactory.Text(key + "_Desc", desc, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val6).color = new Color(0.75f, 0.78f, 0.85f);
				val6.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val6).rectTransform, new Vector2(num, 0.08f), new Vector2(0.64f, 0.52f));
				Text val7 = UIFactory.Text(key + "_Price", $"${price:N0}", val.transform, 16, (TextAnchor)4, (FontStyle)1);
				((Graphic)val7).color = _gold;
				Rect(((Graphic)val7).rectTransform, new Vector2(0.66f, 0.55f), new Vector2(0.95f, 0.92f));
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(key + "_Buy", "BUY", val.transform, _accent, 0f, 30f, 14, Color.white);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				RectTransform component2 = item.GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = new Vector2(0.66f, 0.12f);
					component2.anchorMax = new Vector2(0.95f, 0.48f);
					component2.offsetMin = Vector2.zero;
					component2.offsetMax = Vector2.zero;
				}
				int p = price;
				Func<bool> g = give;
				string n = name;
				WireClick(item2, delegate
				{
					OnShopBuy(p, g, n);
				});
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ShopCard " + key + ": " + ex.Message);
			}
		}

		private GameObject BuildOperationsPage(Transform parent)
		{
			//IL_001b: 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)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("OperationsPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			string text = ((Active != null) ? (Active.OperationsTitle ?? "OPERATIONS") : "OPERATIONS");
			Text val2 = UIFactory.Text("OpTitle", text, val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.04f, 0.895f), new Vector2(0.545f, 0.961f));
			_operationsStatus = UIFactory.Text("OpStatus", "", val.transform, 13, (TextAnchor)2, (FontStyle)2);
			((Graphic)_operationsStatus).color = _gold;
			Rect(((Graphic)_operationsStatus).rectTransform, new Vector2(0.56f, 0.9f), new Vector2(0.97f, 0.99f));
			GameObject val3 = MakePanel("OpListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.021f, 0.005f), (Vector2?)new Vector2(0.983f, 0.865f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_operationsList = UIFactory.ScrollableVerticalList("OpList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_operationsList);
			HardenScrollClip(sr);
			return val;
		}

		private void RefreshOperations()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				StopGifs();
				if ((Object)(object)_operationsList == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_operationsList).transform);
				MobFamily active = Active;
				if (active != null && !active.OperationsUnlocked)
				{
					Text val = UIFactory.Text("OpLocked", active.OperationsLockedText, (Transform)(object)_operationsList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 60f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_operationsList);
					return;
				}
				IReadOnlyList<MobOperation> readOnlyList = active?.Operations;
				if (readOnlyList == null || readOnlyList.Count == 0)
				{
					Text val2 = UIFactory.Text("OpNone", (active != null) ? active.OperationsEmptyText : "No operations right now.", (Transform)(object)_operationsList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val2).color = LockedTxt;
					AddLayout(((Component)val2).gameObject, 60f);
					Rect(((Graphic)val2).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_operationsList);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					MobOperation mobOperation = readOnlyList[i];
					if (mobOperation != null)
					{
						AddOperationCard(mobOperation);
					}
				}
				UIFactory.FitContentHeight(_operationsList);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshOperations: " + ex.Message);
			}
		}

		private void AddOperationCard(MobOperation op)
		{
			//IL_0023: 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_0189: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: 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_0080: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = op.Key ?? "op";
				GameObject val = MakePanel("Op_" + text, (Transform)(object)_operationsList, CardBg);
				AddLayout(val, 100f);
				if (op.IconFrames != null && op.IconFrames.Length != 0)
				{
					GameObject val2 = new GameObject(text + "_Gif");
					val2.transform.SetParent(val.transform, false);
					Image val3 = val2.AddComponent<Image>();
					val3.preserveAspect = true;
					((Graphic)val3).raycastTarget = false;
					val3.sprite = op.IconFrames[0];
					RectTransform component = val2.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.035f, 0.12f), new Vector2(0.235f, 0.88f));
					}
					PlayGif(val3, op.IconFrames, op.IconDelays);
				}
				bool flag = false;
				try
				{
					flag = op.Available;
				}
				catch
				{
				}
				string text2 = op.QuestName ?? "";
				string text3 = op.Description ?? "";
				Text val4 = UIFactory.Text(text + "_Name", text2, val.transform, 15, (TextAnchor)0, (FontStyle)1);
				((Graphic)val4).color = Color.white;
				val4.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val4).rectTransform, new Vector2(0.27f, 0.58f), new Vector2(0.64f, 0.92f));
				Text val5 = UIFactory.Text(text + "_Desc", text3, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val5).color = new Color(0.75f, 0.78f, 0.85f);
				val5.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val5).rectTransform, new Vector2(0.27f, 0.08f), new Vector2(0.64f, 0.55f));
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(text + "_Go", text2, val.transform, flag ? _accent : LockedBg, 0f, 34f, 13, flag ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				RectTransform component2 = item.GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = new Vector2(0.66f, 0.3f);
					component2.anchorMax = new Vector2(0.96f, 0.7f);
					component2.offsetMin = Vector2.zero;
					component2.offsetMax = Vector2.zero;
				}
				if (flag)
				{
					MobOperation picked = op;
					WireClick(item2, delegate
					{
						OnOperationTrigger(picked);
					});
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] OperationCard " + op?.Key + ": " + ex.Message);
			}
		}

		private void OnOperationTrigger(MobOperation op)
		{
			//IL_00c4: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			if (op == null)
			{
				return;
			}
			try
			{
				string message;
				bool flag = op.Invoke(out message);
				if ((Object)(object)_operationsStatus != (Object)null)
				{
					_operationsStatus.text = message ?? "";
					((Graphic)_operationsStatus).color = (flag ? _gold : ErrorTxt);
				}
				if (flag && !op.LeadsToChat)
				{
					MelonCoroutines.Start(ClosePhoneNextFrame());
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] OnOperationTrigger: " + ex.Message);
				if ((Object)(object)_operationsStatus != (Object)null)
				{
					_operationsStatus.text = "Couldn't reach the famiglia right now.";
					((Graphic)_operationsStatus).color = ErrorTxt;
				}
			}
		}

		private static IEnumerator ClosePhoneNextFrame()
		{
			yield return null;
			try
			{
				GameplayMenu instance = Singleton<GameplayMenu>.Instance;
				if (instance != null)
				{
					instance.Close();
				}
			}
			catch
			{
			}
		}

		private void PlayGif(Image img, Sprite[] frames, float[] delays)
		{
			if ((Object)(object)img == (Object)null || frames == null || frames.Length == 0)
			{
				return;
			}
			if (frames.Length == 1)
			{
				img.sprite = frames[0];
				return;
			}
			try
			{
				object obj = MelonCoroutines.Start(AnimateGif(img, frames, delays));
				if (obj != null)
				{
					_gifCoroutines.Add(obj);
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] PlayGif: " + ex.Message);
			}
		}

		private static IEnumerator AnimateGif(Image img, Sprite[] frames, float[] delays)
		{
			int i = 0;
			while (!((Object)(object)img == (Object)null))
			{
				try
				{
					img.sprite = frames[i];
				}
				catch
				{
					break;
				}
				float d = ((delays != null && i < delays.Length && delays[i] > 0f) ? delays[i] : 0.1f);
				i = (i + 1) % frames.Length;
				yield return (object)new WaitForSeconds(d);
			}
		}

		private void StopGifs()
		{
			try
			{
				for (int i = 0; i < _gifCoroutines.Count; i++)
				{
					try
					{
						MelonCoroutines.Stop(_gifCoroutines[i]);
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			_gifCoroutines.Clear();
		}

		private GameObject BuildFaidaPage(Transform parent)
		{
			//IL_001b: 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_0081: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("FaidaPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			_faidaTitleText = UIFactory.Text("FaidaTitle", "FAIDA", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)_faidaTitleText).color = _gold;
			Rect(((Graphic)_faidaTitleText).rectTransform, new Vector2(0.04f, 0.895f), new Vector2(0.545f, 0.961f));
			_faidaIntro = UIFactory.Text("FaidaIntro", "", val.transform, 13, (TextAnchor)0, (FontStyle)0);
			((Graphic)_faidaIntro).color = Color.white;
			_faidaIntro.horizontalOverflow = (HorizontalWrapMode)0;
			_faidaIntro.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_faidaIntro).rectTransform, new Vector2(0.042f, 0.76f), new Vector2(0.965f, 0.88f));
			Text val2 = UIFactory.Text("FaidaRivalLabel", "RIVAL POINTS", val.transform, 13, (TextAnchor)6, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.042f, 0.7f), new Vector2(0.545f, 0.758f));
			GameObject val3 = MakePanel("FaidaListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.021f, 0.005f), (Vector2?)new Vector2(0.983f, 0.69f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_faidaList = UIFactory.ScrollableVerticalList("FaidaList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_faidaList);
			HardenScrollClip(sr);
			return val;
		}

		private void RefreshFaida()
		{
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				MobFamily active = Active;
				string text = ((active != null) ? (active.FaidaTitle ?? "FAIDA") : "FAIDA");
				if ((Object)(object)_faidaTitleText != (Object)null)
				{
					_faidaTitleText.text = text;
				}
				if ((Object)(object)_faidaNavText != (Object)null)
				{
					_faidaNavText.text = text;
				}
				if ((Object)(object)_faidaIntro != (Object)null)
				{
					_faidaIntro.text = ((active != null) ? (active.FaidaIntro ?? "") : "");
				}
				if ((Object)(object)_faidaList == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_faidaList).transform);
				if (active != null && !active.FaidaUnlocked)
				{
					Text val = UIFactory.Text("FaidaLocked", active.FaidaLockedText ?? "Locked.", (Transform)(object)_faidaList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					val.horizontalOverflow = (HorizontalWrapMode)0;
					val.verticalOverflow = (VerticalWrapMode)1;
					AddLayout(((Component)val).gameObject, 90f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_faidaList);
					return;
				}
				try
				{
					MobOperation mobOperation = active?.FaidaAction;
					if (mobOperation != null)
					{
						AddFaidaActionCard(mobOperation);
					}
				}
				catch
				{
				}
				IReadOnlyList<MobFaidaTarget> readOnlyList = active?.FaidaTargets;
				if (readOnlyList == null || readOnlyList.Count == 0)
				{
					Text val2 = UIFactory.Text("FaidaNone", (active != null) ? (active.FaidaEmptyText ?? "No rivals yet.") : "", (Transform)(object)_faidaList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val2).color = LockedTxt;
					val2.horizontalOverflow = (HorizontalWrapMode)0;
					val2.verticalOverflow = (VerticalWrapMode)1;
					AddLayout(((Component)val2).gameObject, 70f);
					Rect(((Graphic)val2).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_faidaList);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					MobFaidaTarget mobFaidaTarget = readOnlyList[i];
					if (mobFaidaTarget != null)
					{
						AddFaidaRow(mobFaidaTarget.Name ?? $"Rival {i}", mobFaidaTarget.Points, mobFaidaTarget.Detail ?? "");
					}
				}
				UIFactory.FitContentHeight(_faidaList);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshFaida: " + ex.Message);
			}
		}

		private void AddFaidaRow(string name, int points, string detail)
		{
			//IL_0027: 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_0093: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = (name ?? "").Replace(' ', '_');
				GameObject val = MakePanel("Faida_" + text, (Transform)(object)_faidaList, CardBg);
				AddLayout(val, 64f);
				Text val2 = UIFactory.Text(text + "_Name", name, val.transform, 16, (TextAnchor)3, (FontStyle)1);
				((Graphic)val2).color = Color.white;
				val2.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val2).rectTransform, new Vector2(0.09f, 0.46f), new Vector2(0.7f, 0.94f));
				Text val3 = UIFactory.Text(text + "_Detail", detail, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val3).color = new Color(0.75f, 0.78f, 0.85f);
				val3.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val3).rectTransform, new Vector2(0.09f, 0.08f), new Vector2(0.7f, 0.44f));
				Text val4 = UIFactory.Text(text + "_Pts", points.ToString(), val.transform, 22, (TextAnchor)5, (FontStyle)1);
				((Graphic)val4).color = _gold;
				Rect(((Graphic)val4).rectTransform, new Vector2(0.72f, 0.2f), new Vector2(0.95f, 0.8f));
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] FaidaRow " + name + ": " + ex.Message);
			}
		}

		private void AddFaidaActionCard(MobOperation op)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (op == null)
				{
					return;
				}
				bool flag = false;
				try
				{
					flag = op.Available;
				}
				catch
				{
				}
				string text = op.Key ?? "faidaaction";
				GameObject val = MakePanel("FaidaAct_" + text, (Transform)(object)_faidaList, CardBg);
				AddLayout(val, 96f);
				Text val2 = UIFactory.Text(text + "_Name", op.QuestName ?? "DECLARE WAR", val.transform, 16, (TextAnchor)0, (FontStyle)1);
				((Graphic)val2).color = _gold;
				val2.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val2).rectTransform, new Vector2(0.06f, 0.62f), new Vector2(0.7f, 0.93f));
				Text val3 = UIFactory.Text(text + "_Desc", op.Description ?? "", val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val3).color = new Color(0.8f, 0.82f, 0.88f);
				val3.horizontalOverflow = (HorizontalWrapMode)0;
				val3.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val3).rectTransform, new Vector2(0.06f, 0.07f), new Vector2(0.7f, 0.58f));
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(text + "_Go", op.QuestName ?? "WAR", val.transform, flag ? _accent : LockedBg, 0f, 34f, 13, flag ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				RectTransform component = item.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = new Vector2(0.72f, 0.3f);
					component.anchorMax = new Vector2(0.96f, 0.7f);
					component.offsetMin = Vector2.zero;
					component.offsetMax = Vector2.zero;
				}
				if (flag)
				{
					MobOperation picked = op;
					WireClick(item2, delegate
					{
						OnOperationTrigger(picked);
					});
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] FaidaActionCard: " + ex.Message);
			}
		}

		private void OnShopBuy(int price, Func<bool> give, string name)
		{
			try
			{
				if (!MobEconomy.TryChargeLocal(price, "Little Helper: " + name, out var message))
				{
					SetShopStatus(message, ok: false);
					return;
				}
				bool flag = false;
				try
				{
					flag = give?.Invoke() ?? false;
				}
				catch
				{
					flag = false;
				}
				if (!flag)
				{
					MobEconomy.RefundLocal(price, "Little Helper refund: " + name, out var _);
					SetShopStatus("Couldn't deliver — inventory full or item unavailable.", ok: false);
				}
				else
				{
					SetShopStatus("Delivered: " + name + ".", ok: true);
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] OnShopBuy: " + ex.Message);
				SetShopStatus("Shop error.", ok: false);
			}
		}

		private void SetShopStatus(string msg, bool ok)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)_shopStatus == (Object)null))
				{
					_shopStatus.text = msg ?? "";
					((Graphic)_shopStatus).color = (ok ? _gold : ErrorTxt);
				}
			}
			catch
			{
			}
		}

		private GameObject BuildFurnishPage(Transform parent)
		{
			//IL_001b: 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_00a0: 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_00ca: 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_00fc: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: 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_0268: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("FurnishPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			_furnishChooser = MakePanel("FurnChooser", val.transform, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text("FurnChooseTitle", "FURNISH", _furnishChooser.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.05f, 0.898f), new Vector2(0.482f, 0.97f));
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("FurnChooseBack", "< REAL ESTATE", _furnishChooser.transform, _accent, 0f, 26f, 12, Color.white);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.85f, 0.92f);
				component.anchorMax = new Vector2(0.985f, 0.975f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			WireClick(item2, delegate
			{
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
			});
			Text val3 = UIFactory.Text("FurnChooseSub", "Choose what to furnish.", _furnishChooser.transform, 14, (TextAnchor)0, (FontStyle)2);
			((Graphic)val3).color = new Color(0.7f, 0.75f, 0.85f);
			Rect(((Graphic)val3).rectTransform, new Vector2(0.0531f, 0.5491f), new Vector2(0.4685f, 0.9247f));
			_furnishChooseHost = MakePanel("FurnChooseList", _furnishChooser.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.024f, 0.6f), (Vector2?)new Vector2(0.381f, 0.715f), fullAnchor: false);
			UIFactory.VerticalLayoutOnGO(_furnishChooseHost, 12, new RectOffset(8, 8, 8, 8));
			_furnishEditor = MakePanel("FurnEditor", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(-0.015f, -0.032f), (Vector2?)new Vector2(1.018f, 0.982f), fullAnchor: false);
			_furnishTitle = UIFactory.Text("FurnTitle", "FURNISH", _furnishEditor.transform, 18, (TextAnchor)0, (FontStyle)1);
			((Graphic)_furnishTitle).color = _gold;
			Rect(((Graphic)_furnishTitle).rectTransform, new Vector2(0.04f, 0.876f), new Vector2(0.678f, 0.975f));
			ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.RoundedButtonWithLabel("FurnBack", "< BACK", _furnishEditor.transform, _accent, 0f, 26f, 13, Color.white);
			GameObject item4 = valueTuple2.Item1;
			Button item5 = valueTuple2.Item2;
			Text item6 = valueTuple2.Item3;
			RectTransform component2 = item4.GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.anchorMin = new Vector2(0.871f, 0.939f);
				component2.anchorMax = new Vector2(0.965f, 0.992f);
				component2.offsetMin = Vector2.zero;
				component2.offsetMax = Vector2.zero;
			}
			WireClick(item5, ReturnFromFurnish);
			_furnishTabsHost = MakePanel("FurnTabs", _furnishEditor.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.04f, 0.76f), (Vector2?)new Vector2(0.52f, 0.86f), fullAnchor: false);
			UIFactory.HorizontalLayoutOnGO(_furnishTabsHost, 8, 0, 0, 0, 0, (TextAnchor)4);
			GameObject val4 = MakePanel("FurnListHost", _furnishEditor.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.045f, 0.04f), (Vector2?)new Vector2(0.96f, 0.745f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_furnishContent = UIFactory.ScrollableVerticalList("FurnList", val4.transform, ref sr);
			UIFactory.FitContentHeight(_furnishContent);
			HardenScrollClip(sr);
			_furnishEditor.SetActive(false);
			return val;
		}

		private void OpenFurnishFromRealEstate()
		{
			NDLog.Debug("[APP] FURNISH-Button geklickt -> Furnish-Seite.");
			GameObject activePage = GetActivePage();
			_furnishReturnPage = (((Object)(object)activePage != (Object)null && (Object)(object)activePage != (Object)(object)_furnishPage) ? activePage : _realEstatePage);
			SetActivePage(_furnishPage);
			ShowFurnishChooser();
		}

		private GameObject GetActivePage()
		{
			if (_pages == null)
			{
				return null;
			}
			for (int i = 0; i < _pages.Length; i++)
			{
				if ((Object)(object)_pages[i] != (Object)null && _pages[i].activeSelf)
				{
					return _pages[i];
				}
			}
			return null;
		}

		private void ReturnFromFurnish()
		{
			GameObject val = _furnishReturnPage;
			if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)_furnishPage)
			{
				val = _realEstatePage;
			}
			if ((Object)(object)val == (Object)(object)_realEstatePage)
			{
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
			}
			else if ((Object)(object)val == (Object)(object)_homePage)
			{
				SetActivePage(_homePage, refreshHome: true);
			}
			else
			{
				SetActivePage(val);
			}
		}

		private void ShowFurnishChooser()
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_furnishEditor != (Object)null)
				{
					_furnishEditor.SetActive(false);
				}
				if ((Object)(object)_furnishChooser != (Object)null)
				{
					_furnishChooser.SetActive(true);
				}
				if ((Object)(object)_furnishChooseHost == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(_furnishChooseHost.transform);
				MobFamily active = Active;
				IReadOnlyList<IMobFurnishTarget> readOnlyList = active?.FurnishTargets;
				bool flag = false;
				if (readOnlyList != null)
				{
					for (int i = 0; i < readOnlyList.Count; i++)
					{
						IMobFurnishTarget mobFurnishTarget = readOnlyList[i];
						if (mobFurnishTarget != null)
						{
							bool flag2 = false;
							try
							{
								flag2 = mobFurnishTarget.Available;
							}
							catch
							{
							}
							if (flag2)
							{
								flag = true;
								break;
							}
						}
					}
				}
				if (!flag)
				{
					Text val = UIFactory.Text("FurnNone", (active != null) ? active.FurnishEmptyText : "Nothing to furnish.", _furnishChooseHost.transform, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 60f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					return;
				}
				for (int j = 0; j < readOnlyList.Count; j++)
				{
					IMobFurnishTarget mobFurnishTarget2 = readOnlyList[j];
					if (mobFurnishTarget2 != null)
					{
						bool enabled = false;
						try
						{
							enabled = mobFurnishTarget2.Available;
						}
						catch
						{
						}
						IMobFurnishTarget picked = mobFurnishTarget2;
						AddChooserButton($"FurnCh_{j}", mobFurnishTarget2.Name, enabled, delegate
						{
							OpenFurnish(picked);
						});
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ShowFurnishChooser: " + ex.Message);
			}
		}

		private void AddChooserButton(string key, string label, bool enabled, Action onClick)
		{
			//IL_001a: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(key, label, _furnishChooseHost.transform, enabled ? _accent : LockedBg, 0f, 50f, 16, enabled ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement val = item.GetComponent<LayoutElement>();
				if ((Object)(object)val == (Object)null)
				{
					val = item.AddComponent<LayoutElement>();
				}
				val.minHeight = 50f;
				val.preferredHeight = 50f;
				val.flexibleWidth = 1f;
				if (enabled && onClick != null)
				{
					ButtonUtils.AddListener(item2, onClick);
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ChooserButton " + key + ": " + ex.Message);
			}
		}

		private void OpenFurnish(IMobFurnishTarget target)
		{
			bool flag = false;
			try
			{
				flag = target?.Available ?? false;
			}
			catch
			{
			}
			if (!flag)
			{
				ShowFurnishChooser();
				return;
			}
			_furnishTarget = target;
			_furnishSurface = 0;
			if ((Object)(object)_furnishChooser != (Object)null)
			{
				_furnishChooser.SetActive(false);
			}
			if ((Object)(object)_furnishEditor != (Object)null)
			{
				_furnishEditor.SetActive(true);
			}
			RefreshFurnish();
		}

		private void RefreshFurnish()
		{
			//IL_0149: 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_0159: 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)
			try
			{
				if ((Object)(object)_furnishContent == (Object)null || (Object)(object)_furnishTabsHost == (Object)null)
				{
					return;
				}
				IMobFurnishTarget t = _furnishTarget;
				bool flag = false;
				try
				{
					flag = t != null && t.Available;
				}
				catch
				{
				}
				if (!flag)
				{
					ShowFurnishChooser();
					return;
				}
				if ((Object)(object)_furnishTitle != (Object)null)
				{
					_furnishTitle.text = "FURNISH — " + t.Name;
				}
				UIFactory.ClearChildren(_furnishTabsHost.transform);
				string[] array = new string[3] { "Floor", "Wall", "Ceiling" };
				for (int i = 0; i < array.Length; i++)
				{
					int sel = i;
					bool flag2 = _furnishSurface == i;
					AddChip(_furnishTabsHost, $"Tab_{i}", array[i], flag2 ? _gold : _accent, flag2 ? MainBg : Color.white, 30f, delegate
					{
						_furnishSurface = sel;
						RefreshFurnish();
					});
				}
				UIFactory.ClearChildren(((Component)_furnishContent).transform);
				int curMat = t.GetMat(_furnishSurface);
				int curCol = t.GetCol(_furnishSurface);
				AddSectionLabel(_furnishContent, "MATERIAL");
				BuildChipGrid(_furnishContent, "mat", FurnishCatalog.Materials.Length, 3, delegate(int num)
				{
					//IL_0049: 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_0058: 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)
					bool flag3 = num == curMat;
					return ((string label, Color bg, Color txt, Action onClick))(label: FurnishCatalog.Materials[num].Name, bg: flag3 ? _gold : CardBg, txt: flag3 ? MainBg : Color.white, onClick: delegate
					{
						t.SetMat(_furnishSurface, num);
						RefreshFurnish();
					});
				});
				AddSectionLabel(_furnishContent, "COLOR");
				BuildChipGrid(_furnishContent, "col", FurnishCatalog.Colors.Length, 3, delegate(int num)
				{
					//IL_0049: 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_0058: 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)
					bool flag3 = num == curCol;
					return ((string label, Color bg, Color txt, Action onClick))(label: FurnishCatalog.Colors[num].Name, bg: flag3 ? _gold : CardBg, txt: flag3 ? MainBg : Color.white, onClick: delegate
					{
						t.SetCol(_furnishSurface, num);
						RefreshFurnish();
					});
				});
				UIFactory.FitContentHeight(_furnishContent);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshFurnish: " + ex.Message);
			}
		}

		private GameObject AddFurnishRow(Transform content, float height)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("FurnRow", content, new Color(0f, 0f, 0f, 0f));
			AddLayout(val, height);
			UIFactory.HorizontalLayoutOnGO(val, 6, 0, 0, 0, 0, (TextAnchor)4);
			return val;
		}

		private void AddChip(GameObject row, string key, string label, Color bg, Color txt, float height, Action onClick)
		{
			//IL_000a:

TheMob.MONO.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using FishNet.Connection;
using FishNet.Object;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Ndrangheta;
using Ndrangheta.Compat;
using Ndrangheta.Families;
using Ndrangheta.Framework;
using Ndrangheta.Helper;
using Ndrangheta.Messaging;
using Ndrangheta.NPCs;
using Ndrangheta.Quests;
using S1API.Entities;
using S1API.Entities.Appearances.AccessoryFields;
using S1API.Entities.Appearances.BodyLayerFields;
using S1API.Entities.Appearances.CustomizationFields;
using S1API.Entities.Appearances.FaceLayerFields;
using S1API.Internal.Abstraction;
using S1API.Quests;
using S1API.Quests.Constants;
using S1API.Quests.Identifiers;
using S1API.Saveables;
using S1API.Vehicles;
using ScheduleOne;
using ScheduleOne.Audio;
using ScheduleOne.AvatarFramework;
using ScheduleOne.AvatarFramework.Emotions;
using ScheduleOne.AvatarFramework.Equipping;
using ScheduleOne.Building;
using ScheduleOne.Cartel;
using ScheduleOne.Combat;
using ScheduleOne.Core.Items.Framework;
using ScheduleOne.DevUtilities;
using ScheduleOne.Dialogue;
using ScheduleOne.Doors;
using ScheduleOne.Dragging;
using ScheduleOne.Economy;
using ScheduleOne.EntityFramework;
using ScheduleOne.Equipping;
using ScheduleOne.GameTime;
using ScheduleOne.Interaction;
using ScheduleOne.ItemFramework;
using ScheduleOne.Map;
using ScheduleOne.Messaging;
using ScheduleOne.Money;
using ScheduleOne.NPCs;
using ScheduleOne.NPCs.Behaviour;
using ScheduleOne.NPCs.CharacterClasses;
using ScheduleOne.NPCs.Relation;
using ScheduleOne.NPCs.Responses;
using ScheduleOne.NPCs.Schedules;
using ScheduleOne.Noise;
using ScheduleOne.ObjectScripts;
using ScheduleOne.Persistence;
using ScheduleOne.Persistence.Datas;
using ScheduleOne.Persistence.Loaders;
using ScheduleOne.PlayerScripts;
using ScheduleOne.PlayerScripts.Health;
using ScheduleOne.Police;
using ScheduleOne.Product;
using ScheduleOne.Product.Packaging;
using ScheduleOne.Property;
using ScheduleOne.Quests;
using ScheduleOne.Storage;
using ScheduleOne.Tiles;
using ScheduleOne.Tools;
using ScheduleOne.UI;
using ScheduleOne.UI.Compass;
using ScheduleOne.UI.Phone;
using ScheduleOne.UI.Phone.Messages;
using ScheduleOne.Vehicles;
using ScheduleOne.Vehicles.Modification;
using ScheduleOne.Vision;
using SteamNetworkLib;
using SteamNetworkLib.Events;
using SteamNetworkLib.Sync;
using Steamworks;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonOptionalDependencies(new string[] { "SteamNetworkLib" })]
[assembly: AssemblyTitle("Ndrangheta")]
[assembly: AssemblyDescription("Schedule I MelonLoader Mod")]
[assembly: AssemblyCompany("Virtunerd")]
[assembly: AssemblyProduct("Ndrangheta")]
[assembly: AssemblyCopyright("Copyright (c) Virtunerd 2026")]
[assembly: ComVisible(false)]
[assembly: Guid("1197b5da-0218-4ec8-8548-e328bd9c8b5f")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: MelonInfo(typeof(NdranghetaMod), "Ndrangheta", "1.0.7", "Virtunerd", null)]
[assembly: MelonGame(null, "Schedule I")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: AssemblyInformationalVersion("1.0.7")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.7.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 Ndrangheta
{
	internal static class ImguiCompat
	{
		private static GUIStyle _style;

		internal static void DrawTexture(Rect position, Texture2D image)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Blit(position, image);
		}

		internal static void DrawTexture(Rect position, Texture2D image, ScaleMode scaleMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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)
			Blit(Fit(position, image, scaleMode), image);
		}

		private static Rect Fit(Rect position, Texture2D image, ScaleMode scaleMode)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0018: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_004d: 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_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)
			if ((Object)(object)image == (Object)null || (int)scaleMode == 0)
			{
				return position;
			}
			float num = ((Texture)image).width;
			float num2 = ((Texture)image).height;
			if (num <= 0f || num2 <= 0f)
			{
				return position;
			}
			float num3 = (((int)scaleMode == 2) ? Mathf.Min(((Rect)(ref position)).width / num, ((Rect)(ref position)).height / num2) : Mathf.Max(((Rect)(ref position)).width / num, ((Rect)(ref position)).height / num2));
			float num4 = num * num3;
			float num5 = num2 * num3;
			return new Rect(((Rect)(ref position)).x + (((Rect)(ref position)).width - num4) * 0.5f, ((Rect)(ref position)).y + (((Rect)(ref position)).height - num5) * 0.5f, num4, num5);
		}

		private static void Blit(Rect position, Texture2D image)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0059: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if ((Object)(object)image == (Object)null)
			{
				return;
			}
			Event current = Event.current;
			if (current != null && (int)current.type == 7)
			{
				if (_style == null)
				{
					_style = new GUIStyle();
				}
				_style.normal.background = image;
				Color backgroundColor = GUI.backgroundColor;
				GUI.backgroundColor = Color.white;
				_style.Draw(position, false, false, false, false);
				GUI.backgroundColor = backgroundColor;
			}
		}
	}
	public class NdranghetaMod : MelonMod
	{
		private const string MAIN_SCENE_NAME = "Main";

		private bool _inMainScene;

		private bool _npcSpawned;

		private float _startupTimer;

		private float _saveDataRefreshTimer;

		private float _clientPresenceTimer;

		private bool _netDiagDone;

		private float _netDiagTimer;

		private bool _wasAuthority;

		private bool _demotedToClient;

		private static bool _netLayerDown;

		private static bool _s1apiMissing;

		private static float _staleMarkerSweepAt;

		private static float _depositoRescueAt;

		private static float _depositoRescueUntil;

		private static bool _depositoReloadDetected;

		private static float _depositoForceDismissAt;

		private static bool _depositoForcedDismiss;

		private static float _depositoLastScreenUpAt;

		private static float _clientLoadStuckSince;

		private static float _clientLoadDiagAt;

		private static bool _clientLoadForced;

		private static float _clientLoadReqAt;

		private static int _clientLoadReqs;

		private static float _clientGatesOkSince;

		private const float CLIENT_LOAD_GATES_GRACE = 3f;

		private const float CLIENT_LOAD_FORCE_SECONDS = 18f;

		private static float _chatRestoreAt;

		private const float CHAT_INTERFACE_RESTORE_GRACE = 1.5f;

		private const float NPC_SPAWN_DELAY = 3f;

		private const float SAVE_DATA_REFRESH_INTERVAL = 1f;

		private bool _clientDonSeenLogged;

		private bool _clientDonMissingLogged;

		private bool _clientQuestStarted;

		private bool _clientMetSent;

		private bool _clientChatMenuBuilt;

		private int _clientChatMenuState = -1;

		private bool _clientConsentShown;

		private static bool _clientBattAnnounced;

		private static bool _clientBattAttackSent;

		private static int _coopPaySeqApplied = -1;

		private static string _clientDropoffSentFor;

		private static string _clientShortCashSmsFor;

		private static bool _s1apiRedirectLogged;

		private static GUIStyle _s1apiWarnStyle;

		private void DemoteToClient()
		{
			if (_demotedToClient)
			{
				return;
			}
			_demotedToClient = true;
			NDLog.Debug("Authority lost (became FishNet client) — switching to client mode, cleaning transient host state.");
			try
			{
				IntroController.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				TerritoryHandover.ForceReset();
			}
			catch
			{
			}
			try
			{
				PizzoJobManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				RankManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				DailyTribute.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				BattesimoController.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				ConsentController.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				LuckyTargetPicker.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				LuckyBrawlManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				LaBombaManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				RapimentoManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				TortureManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				GangBattleManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				GangWarManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				FearState.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				FaidaState.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				CarBombManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				InformantiManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				RealEstateManager.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				PropVisuals.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				MobTeleport.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				MirrorRenderer.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				VisualMirror.Reset();
			}
			catch
			{
			}
			try
			{
				TeleportMirror.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				FamigliaReskinSync.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				Sfx.ResetForSceneReload();
			}
			catch
			{
			}
			try
			{
				MobFamilyRegistry.ResetAllForSceneReload();
			}
			catch
			{
			}
			try
			{
				LuckyCombatDriver.Reset();
			}
			catch
			{
			}
			_staleMarkerSweepAt = Time.time + 12f;
			ArmDepositoReloadRescue();
			_clientLoadStuckSince = 0f;
			_clientLoadDiagAt = 0f;
			_clientLoadForced = false;
			_clientLoadReqAt = 0f;
			_clientLoadReqs = 0;
			_clientGatesOkSince = 0f;
			_chatRestoreAt = 0f;
			try
			{
				ClientActionNet.Reset();
			}
			catch
			{
			}
			_clientDropoffSentFor = null;
			_clientShortCashSmsFor = null;
			_coopPaySeqApplied = -1;
			_clientBattAnnounced = false;
			_clientBattAttackSent = false;
			try
			{
				BattesimoQuest.ClearInstanceForNext();
			}
			catch
			{
			}
			_clientConsentShown = false;
			_clientMetSent = false;
			try
			{
				ClientIntroQuest.ResetForSceneReload();
			}
			catch
			{
			}
			_clientChatMenuBuilt = false;
			_clientChatMenuState = -1;
			try
			{
				DonSalvatoreNPC.ResetForDemotion();
			}
			catch
			{
			}
			try
			{
				LuckyNPC.ResetForDemotion();
			}
			catch
			{
			}
			try
			{
				NPCRelationData val = NPCManager.GetNPC("Ndrangheta_don_salvatore")?.RelationData;
				if (val != null && val.Unlocked)
				{
					val.Unlocked = false;
					NDLog.Debug("Don contact re-locked (client demotion).");
				}
			}
			catch
			{
			}
			_npcSpawned = false;
			_startupTimer = 0f;
		}

		private static int GetCurrentJobCut()
		{
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return 0;
				}
				return (current.Type == PizzoJobManager.JobType.Pizzo || current.Type == PizzoJobManager.JobType.Trasporto) ? current.CutAmount : 0;
			}
			catch
			{
				return 0;
			}
		}

		private static int GetCurrentJobDropReward()
		{
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return 0;
				}
				return (current.Type == PizzoJobManager.JobType.Trasporto || current.Type == PizzoJobManager.JobType.Carico) ? current.RewardAmount : 0;
			}
			catch
			{
				return 0;
			}
		}

		private static void GetCurrentStepSync(out string entryText, out string entryPoi)
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			entryText = "";
			entryPoi = "";
			try
			{
				Quest val = null;
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return;
				}
				switch (current.Type)
				{
				case PizzoJobManager.JobType.Pizzo:
					val = (Quest)(object)PizzoQuest.Instance;
					break;
				case PizzoJobManager.JobType.Trasporto:
					val = (Quest)(object)TrasportoQuest.Instance;
					break;
				case PizzoJobManager.JobType.Contratto:
					val = (Quest)(object)ContrattoQuest.Instance;
					break;
				case PizzoJobManager.JobType.Carico:
					val = (Quest)(object)CaricoQuest.Instance;
					break;
				}
				if (val == null)
				{
					return;
				}
				List<QuestEntry> questEntries = val.QuestEntries;
				if (questEntries == null)
				{
					return;
				}
				for (int i = 0; i < questEntries.Count; i++)
				{
					QuestEntry val2 = questEntries[i];
					if (val2 == null)
					{
						continue;
					}
					bool flag = false;
					try
					{
						flag = (int)val2.State == 1;
					}
					catch
					{
					}
					if (!flag)
					{
						continue;
					}
					try
					{
						entryText = val2.Title ?? "";
					}
					catch
					{
					}
					try
					{
						Vector3 pOIPosition = val2.POIPosition;
						if (((Vector3)(ref pOIPosition)).sqrMagnitude > 1f)
						{
							entryPoi = string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", pOIPosition.x, pOIPosition.y, pOIPosition.z);
						}
						break;
					}
					catch
					{
						break;
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("GetCurrentStepSync: " + ex.Message);
			}
		}

		private static string GetCurrentJobCode()
		{
			try
			{
				PizzoJobManager.Phase currentPhase = PizzoJobManager.CurrentPhase;
				if (currentPhase == PizzoJobManager.Phase.Idle || currentPhase == PizzoJobManager.Phase.Cooldown)
				{
					return "";
				}
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return "";
				}
				return current.Type switch
				{
					PizzoJobManager.JobType.Contratto => current.LuckyDispatched ? "lc" : "c", 
					PizzoJobManager.JobType.Pizzo => "p", 
					PizzoJobManager.JobType.Trasporto => "t", 
					PizzoJobManager.JobType.Carico => "ca", 
					_ => "", 
				};
			}
			catch
			{
				return "";
			}
		}

		private static string GetCurrentJobTarget()
		{
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null)
				{
					return "";
				}
				if (current.Type == PizzoJobManager.JobType.Contratto)
				{
					return current.LuckyDispatched ? (current.LuckyTargetName ?? "") : (current.ContrattoTargetName ?? "");
				}
				return "";
			}
			catch
			{
				return "";
			}
		}

		private static string GetCurrentJobTargetPos()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PizzoJobManager.ActiveJob current = PizzoJobManager.Current;
				if (current == null || current.Type != PizzoJobManager.JobType.Contratto)
				{
					return "";
				}
				NPC activeContrattoTarget = PizzoJobManager.ActiveContrattoTarget;
				if ((Object)(object)activeContrattoTarget == (Object)null || (Object)(object)((Component)activeContrattoTarget).transform == (Object)null)
				{
					return "";
				}
				Vector3 position = ((Component)activeContrattoTarget).transform.position;
				return string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", position.x, position.y, position.z);
			}
			catch
			{
				return "";
			}
		}

		private static string GetBossMarkerPos()
		{
			//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_002c: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Vector3 pos = BossMarkerSync.Pos;
				if (((Vector3)(ref pos)).sqrMagnitude < 1f)
				{
					return "";
				}
				return string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", pos.x, pos.y, pos.z);
			}
			catch
			{
				return "";
			}
		}

		private static string FmtVec(Vector3 p)
		{
			//IL_0025: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref p)).sqrMagnitude < 1f)
			{
				return "";
			}
			return string.Format(CultureInfo.InvariantCulture, "{0:F1};{1:F1};{2:F1}", p.x, p.y, p.z);
		}

		private static Vector3 ParseVec3(string s)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (string.IsNullOrEmpty(s))
				{
					return Vector3.zero;
				}
				string[] array = s.Split(new char[1] { ';' });
				if (array.Length != 3)
				{
					return Vector3.zero;
				}
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				NumberStyles style = NumberStyles.Float;
				if (float.TryParse(array[0], style, invariantCulture, out var result) && float.TryParse(array[1], style, invariantCulture, out var result2) && float.TryParse(array[2], style, invariantCulture, out var result3))
				{
					return new Vector3(result, result2, result3);
				}
			}
			catch
			{
			}
			return Vector3.zero;
		}

		private void ClientPresenceTick()
		{
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			_clientPresenceTimer -= Time.deltaTime;
			if (_clientPresenceTimer > 0f)
			{
				return;
			}
			_clientPresenceTimer = 2f;
			try
			{
				RealEstateManager.ClientMirror(QuestNetSync.HasRemoteState ? QuestNetSync.RemoteEstate : 0);
			}
			catch
			{
			}
			bool flag = QuestNetSync.HasRemoteState && QuestNetSync.RemoteDonReady;
			bool flag2 = QuestNetSync.HasRemoteState && QuestNetSync.RemoteRecruited;
			Vector3 val2;
			try
			{
				NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
				if ((Object)(object)nPC != (Object)null && (Object)(object)((Component)nPC).transform != (Object)null)
				{
					if (!_clientDonSeenLogged)
					{
						Vector3 position = ((Component)nPC).transform.position;
						NDLog.Debug($"[CLIENTDON] host-Don replicated, found at ({position.x:F1},{position.y:F1},{position.z:F1})");
						_clientDonSeenLogged = true;
					}
					EnsureNpcStationaryOnClient(nPC);
					Vector3 pos;
					if (QuestNetSync.RemoteHandover)
					{
						Vector3 val = default(Vector3);
						((Vector3)(ref val))..ctor(0f, -2000f, 0f);
						val2 = ((Component)nPC).transform.position - val;
						if (((Vector3)(ref val2)).sqrMagnitude > 100f)
						{
							((Component)nPC).transform.position = val;
						}
					}
					else if (DonSalvatoreNPC.ResolveGazeboPosition(out pos))
					{
						val2 = ((Component)nPC).transform.position - pos;
						if (((Vector3)(ref val2)).sqrMagnitude > 1f)
						{
							((Component)nPC).transform.position = pos;
						}
					}
				}
				else if (!_clientDonMissingLogged)
				{
					NDLog.Debug("[CLIENTDON] no Don via NPCManager — host-Don NOT replicated to client yet.");
					_clientDonMissingLogged = true;
				}
			}
			catch
			{
			}
			try
			{
				if (!LuckyNetSync.ClientCombatActive)
				{
					NPC nPC2 = NPCManager.GetNPC("Ndrangheta_lucky");
					if ((Object)(object)nPC2 != (Object)null && (Object)(object)((Component)nPC2).transform != (Object)null)
					{
						Vector3 val3 = default(Vector3);
						((Vector3)(ref val3))..ctor(0f, -2000f, 0f);
						val2 = ((Component)nPC2).transform.position - val3;
						if (((Vector3)(ref val2)).sqrMagnitude > 100f)
						{
							((Component)nPC2).transform.position = val3;
						}
					}
				}
			}
			catch
			{
			}
			if (flag)
			{
				try
				{
					DonMessaging.TryUnlock();
				}
				catch
				{
				}
				try
				{
					DonMessaging.PatchAsSupplier();
				}
				catch
				{
				}
				try
				{
					DonMessaging.SendClientPresenceMessageIfNotYet();
				}
				catch
				{
				}
			}
			bool flag3 = false;
			try
			{
				flag3 = (Object)(object)PlayerSingleton<JournalApp>.Instance != (Object)null;
			}
			catch
			{
			}
			if (!flag)
			{
				_clientMetSent = false;
			}
			if (flag && !flag2)
			{
				if (flag3 && DonSalvatoreNPC.ResolveGazeboPosition(out var pos2))
				{
					if (ClientIntroQuest.Instance == null)
					{
						ClientIntroQuest.EnsureCreated(pos2);
					}
					else
					{
						ClientIntroQuest.RefreshPoi(pos2);
					}
					TryClientMeetDon(pos2);
				}
			}
			else if (flag2 && ClientIntroQuest.Instance != null)
			{
				try
				{
					ClientIntroQuest.CompleteAndClear();
				}
				catch
				{
				}
			}
			if (flag2 && QuestNetSync.RemoteHandover)
			{
				try
				{
					PersistentDonPresenceQuest.CompleteAndClear();
				}
				catch
				{
				}
			}
			else if (flag2)
			{
				if (flag3)
				{
					try
					{
						PersistentDonPresenceQuest.EnsureStarted();
					}
					catch
					{
					}
				}
				try
				{
					PersistentDonPresenceQuest.RefreshPoi();
				}
				catch
				{
				}
				if (PersistentDonPresenceQuest.Instance != null && !_clientQuestStarted)
				{
					NDLog.Debug("[QUESTSYNC] client started Don-presence quest from host state.");
					_clientQuestStarted = true;
				}
			}
			if (flag2 && QuestNetSync.HasRemoteState)
			{
				string text = QuestNetSync.RemoteJobCode ?? "";
				string target = QuestNetSync.RemoteJobTarget ?? "";
				bool flag4 = !string.IsNullOrEmpty(text);
				if (flag4 && flag3 && ClientJobMirrorQuest.Instance == null)
				{
					_clientDropoffSentFor = null;
					_clientShortCashSmsFor = null;
					Vector3 pos3 = ParseVec3(QuestNetSync.RemoteJobTargetPos);
					try
					{
						ClientJobMirrorQuest.EnsureCreated(text, target, pos3);
					}
					catch (Exception ex)
					{
						NDLog.DebugWarn("ClientJobMirrorQuest start: " + ex.Message);
					}
				}
				else if (!flag4 && ClientJobMirrorQuest.Instance != null)
				{
					try
					{
						ClientJobMirrorQuest.CompleteAndClear();
					}
					catch
					{
					}
				}
				if (flag4 && ClientJobMirrorQuest.Instance != null)
				{
					try
					{
						if (!DonSalvatoreNPC.ResolveGazeboPosition(out var pos4))
						{
							pos4 = Vector3.zero;
						}
						ClientJobMirrorQuest.UpdateStage(QuestNetSync.RemoteJobStage, text, pos4, QuestNetSync.RemoteEntryText, ParseVec3(QuestNetSync.RemoteEntryPoi));
					}
					catch (Exception ex2)
					{
						NDLog.DebugWarn("Client stage mirror: " + ex2.Message);
					}
					try
					{
						ClientJobDropoffTick(text);
					}
					catch (Exception ex3)
					{
						NDLog.DebugWarn("ClientJobDropoffTick: " + ex3.Message);
					}
				}
				try
				{
					ApplyCoopPayout();
				}
				catch (Exception ex4)
				{
					NDLog.DebugWarn("ApplyCoopPayout: " + ex4.Message);
				}
				try
				{
					ClientBattesimoTick(flag3);
				}
				catch (Exception ex5)
				{
					NDLog.DebugWarn("ClientBattesimoTick: " + ex5.Message);
				}
				try
				{
					ClientBossMarkerTick(flag3);
				}
				catch (Exception ex6)
				{
					NDLog.DebugWarn("ClientBossMarkerTick: " + ex6.Message);
				}
				try
				{
					ClientTortureQuestTick(flag3);
				}
				catch (Exception ex7)
				{
					NDLog.DebugWarn("ClientTortureQuestTick: " + ex7.Message);
				}
				try
				{
					ClientConsentTick();
				}
				catch (Exception ex8)
				{
					NDLog.DebugWarn("ClientConsentTick: " + ex8.Message);
				}
			}
			try
			{
				ClientChatMenuTick();
			}
			catch (Exception ex9)
			{
				NDLog.DebugWarn("ClientChatMenuTick: " + ex9.Message);
			}
		}

		private void ClientChatMenuTick()
		{
			if (!QuestNetSync.HasRemoteState || !QuestNetSync.RemoteRecruited || !QuestNetSync.RemoteHandover)
			{
				_clientChatMenuBuilt = false;
				_clientChatMenuState = -1;
			}
			else if (DonMessaging.ResolveConversation() != null && !_clientChatMenuBuilt && !DonMessaging.IsPhoneOpen())
			{
				LuckyChatController.OpenMainMenu();
				_clientChatMenuBuilt = true;
				_clientChatMenuState = 1;
				NDLog.Debug("[CLIENTCHAT] Don chat menu built on client (boss).");
			}
		}

		private void ClientConsentTick()
		{
			bool flag = QuestNetSync.HasRemoteState && QuestNetSync.RemoteConsentPending;
			if (flag && !_clientConsentShown)
			{
				DonMessaging.RegisterYesNoButtons("Yes, more contracts.", delegate
				{
					ClientActionNet.SendAction("consent", "yes");
				}, "Not for me. Ask later.", delegate
				{
					ClientActionNet.SendAction("consent", "no");
				});
				_clientConsentShown = true;
				NDLog.Debug("[CLIENTCONSENT] Yes/No buttons shown on client.");
			}
			else if (!flag && _clientConsentShown)
			{
				try
				{
					DonMessaging.RemoveYesNoButtons("Yes, more contracts.", "Not for me. Ask later.");
				}
				catch
				{
				}
				_clientConsentShown = false;
				NDLog.Debug("[CLIENTCONSENT] Yes/No buttons cleared on client.");
			}
		}

		private void ClientBossMarkerTick(bool journalReady)
		{
			//IL_001f: 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_004b: 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_0098: 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)
			string text = QuestNetSync.RemoteBossLabel ?? "";
			bool flag = !string.IsNullOrEmpty(text);
			Vector3 pos = ParseVec3(QuestNetSync.RemoteBossPos);
			if (flag && journalReady)
			{
				if (ClientBossMarkerQuest.Instance == null)
				{
					ClientBossMarkerQuest.EnsureCreated(text, pos, QuestNetSync.RemoteBossKind);
				}
				else
				{
					ClientBossMarkerQuest.UpdateLabelAndPoi(text, pos, QuestNetSync.RemoteBossKind);
				}
			}
			else if (!flag && ClientBossMarkerQuest.Instance != null)
			{
				ClientBossMarkerQuest.CompleteAndClear();
			}
			if (flag && QuestNetSync.RemoteBossKind == 1 && ((Vector3)(ref pos)).sqrMagnitude > 1f)
			{
				InformantiManager.ClientShowNote(pos);
			}
			else
			{
				InformantiManager.ClientHideNote();
			}
			if (flag && QuestNetSync.RemoteBossKind == 2 && ((Vector3)(ref pos)).sqrMagnitude > 1f)
			{
				LaBombaManager.ClientShowProp(pos, text != null && text.IndexOf("ARMED", StringComparison.OrdinalIgnoreCase) >= 0);
			}
			else
			{
				LaBombaManager.ClientHideProp();
			}
		}

		private void ClientTortureQuestTick(bool journalReady)
		{
			bool flag = QuestNetSync.RemoteSceneActive && TerritoryHandover.IsBossForLocalPeer;
			if (flag && journalReady)
			{
				if (TortureManager.ClientSceneText(QuestNetSync.RemoteOpVariant, QuestNetSync.RemoteSceneKoReached, out var title, out var objective))
				{
					if (TortureClientMirrorQuest.Instance == null)
					{
						TortureClientMirrorQuest.EnsureCreated(title, objective);
					}
					else
					{
						TortureClientMirrorQuest.UpdateLabel(objective);
					}
				}
			}
			else if (!flag && TortureClientMirrorQuest.Instance != null)
			{
				TortureClientMirrorQuest.CompleteAndClear();
			}
		}

		private void TryClientMeetDon(Vector3 donPos)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0055: 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_0064: 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)
			if (_clientMetSent)
			{
				return;
			}
			try
			{
				Player local = Player.Local;
				if (!((Object)(object)local == (Object)null) && !((Object)(object)((Component)local).transform == (Object)null))
				{
					Vector3 position = ((Component)local).transform.position;
					float num = position.x - donPos.x;
					float num2 = position.z - donPos.z;
					float num3 = position.y - donPos.y;
					float num4 = num * num + num2 * num2 + num3 * num3 * 0.25f;
					if (!(num4 > 16f) && ClientActionNet.SendAction("metdon", ""))
					{
						_clientMetSent = true;
						NDLog.Debug("[CLIENTINTRO] client reached the Don — sent 'metdon' to host.");
					}
				}
			}
			catch
			{
			}
		}

		private void ClientBattesimoTick(bool journalReady)
		{
			int remoteBattesimoStage = QuestNetSync.RemoteBattesimoStage;
			if ((remoteBattesimoStage == 1 || remoteBattesimoStage == 2) && journalReady)
			{
				BattesimoQuest.EnsureCreated();
				BattesimoQuest.EnsureFirstEntryActive();
				if (!_clientBattAnnounced && BattesimoQuest.Instance != null)
				{
					_clientBattAnnounced = true;
					try
					{
						DonMessaging.SendDon("Il battesimo — that goes for every one of you. Hit a cop, walk away clean, stay free for an hour. Check the journal.");
					}
					catch
					{
					}
				}
			}
			if (remoteBattesimoStage >= 2)
			{
				BattesimoQuest.OnAttackDetected();
			}
			if (remoteBattesimoStage >= 3 && BattesimoQuest.Instance != null)
			{
				BattesimoQuest.OnSurvived();
			}
			if (remoteBattesimoStage == 1 && !_clientBattAttackSent)
			{
				try
				{
					List<PoliceOfficer> officers = PoliceOfficer.Officers;
					if (officers != null)
					{
						for (int i = 0; i < officers.Count; i++)
						{
							PoliceOfficer val;
							try
							{
								val = officers[i];
							}
							catch
							{
								continue;
							}
							if (!((Object)(object)val == (Object)null))
							{
								float num;
								try
								{
									num = (((Object)(object)((NPC)val).Health != (Object)null) ? ((float)((NPC)val).Health.HoursSinceAttackedByPlayer) : (-1f));
								}
								catch
								{
									continue;
								}
								if (num >= 0f && num < 2f)
								{
									if (ClientActionNet.SendAction("battattack", ""))
									{
										_clientBattAttackSent = true;
										NDLog.Debug("[CLIENTACT] battesimo attack detected locally — reported to host.");
									}
									break;
								}
							}
						}
					}
					return;
				}
				catch
				{
					return;
				}
			}
			if (remoteBattesimoStage != 1)
			{
				_clientBattAttackSent = false;
			}
		}

		private void ApplyCoopPayout()
		{
			int remotePaySeq = QuestNetSync.RemotePaySeq;
			if (_coopPaySeqApplied < 0)
			{
				_coopPaySeqApplied = remotePaySeq;
			}
			else
			{
				if (remotePaySeq <= _coopPaySeqApplied)
				{
					return;
				}
				_coopPaySeqApplied = remotePaySeq;
				int remotePayAmount = QuestNetSync.RemotePayAmount;
				if (remotePayAmount <= 0)
				{
					return;
				}
				string text = QuestNetSync.RemotePayExclude ?? "";
				string localIdString = LuckyNetSync.LocalIdString;
				if (string.IsNullOrEmpty(text) || !(text == localIdString))
				{
					PayoutHelper.AddCash(remotePayAmount, "Famiglia coop share");
					try
					{
						ClientActionNet.SendAction("income", $"q|{remotePayAmount}");
					}
					catch
					{
					}
					try
					{
						DonMessaging.SendDon($"Your share of the famiglia's take: ${remotePayAmount}.");
					}
					catch
					{
					}
					NDLog.Info($"[COOPPAY] client credited ${remotePayAmount} (seq={remotePaySeq}).");
				}
			}
		}

		private static void EnsureNpcStationaryOnClient(NPC npc)
		{
			try
			{
				NPCMovement movement = npc.Movement;
				if ((Object)(object)movement != (Object)null && ((Behaviour)movement).enabled)
				{
					try
					{
						movement.PauseMovement();
					}
					catch
					{
					}
					try
					{
						movement.SetAgentEnabled(false);
					}
					catch
					{
					}
					try
					{
						((Behaviour)movement).enabled = false;
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			try
			{
				NavMeshAgent val = (((Object)(object)((Component)npc).gameObject != (Object)null) ? ((Component)npc).gameObject.GetComponent<NavMeshAgent>() : null);
				if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
				{
					((Behaviour)val).enabled = false;
				}
			}
			catch
			{
			}
			try
			{
				NPCBehaviour behaviour = npc.Behaviour;
				if ((Object)(object)behaviour != (Object)null && ((Behaviour)behaviour).enabled)
				{
					((Behaviour)behaviour).enabled = false;
				}
			}
			catch
			{
			}
		}

		private void ClientJobDropoffTick(string jCode)
		{
			//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_00da: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			int remoteJobStage = QuestNetSync.RemoteJobStage;
			if (remoteJobStage != 6 || string.Equals(_clientDropoffSentFor, jCode, StringComparison.Ordinal))
			{
				return;
			}
			Player local = Player.Local;
			if ((Object)(object)local == (Object)null || (Object)(object)((Component)local).transform == (Object)null)
			{
				return;
			}
			Vector3 pos;
			if (QuestNetSync.RemoteHandover)
			{
				if (!DonSalvatoreNPC.ResolveGazeboPosition(out pos))
				{
					return;
				}
			}
			else
			{
				NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
				if ((Object)(object)nPC != (Object)null && (Object)(object)((Component)nPC).transform != (Object)null)
				{
					pos = ((Component)nPC).transform.position;
				}
				else if (!DonSalvatoreNPC.ResolveGazeboPosition(out pos))
				{
					return;
				}
			}
			Vector3 val = ((Component)local).transform.position - pos;
			val.y = 0f;
			float num = 4.5f;
			if (!(((Vector3)(ref val)).sqrMagnitude > num * num) && ClientActionNet.SendAction("dropoff", jCode))
			{
				_clientDropoffSentFor = jCode;
				NDLog.Debug($"[CLIENTACT] contratto report-to-Don sent for job '{jCode}' (stage={remoteJobStage}).");
			}
		}

		private static bool IsAssemblyLoaded(string simpleName)
		{
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				for (int i = 0; i < assemblies.Length; i++)
				{
					try
					{
						if (string.Equals(assemblies[i].GetName().Name, simpleName, StringComparison.OrdinalIgnoreCase))
						{
							return true;
						}
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static Assembly ResolveS1ApiAny(object sender, ResolveEventArgs args)
		{
			try
			{
				string name = new AssemblyName(args.Name).Name;
				if (!string.Equals(name, "S1API", StringComparison.OrdinalIgnoreCase))
				{
					return null;
				}
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				for (int i = 0; i < assemblies.Length; i++)
				{
					try
					{
						if (!string.Equals(assemblies[i].GetName().Name, "S1API", StringComparison.OrdinalIgnoreCase))
						{
							continue;
						}
						if (!_s1apiRedirectLogged)
						{
							_s1apiRedirectLogged = true;
							NDLog.Warn("S1API binding redirected: requested '" + args.Name + "' -> loaded '" + assemblies[i].GetName().FullName + "' (installed S1API has a different assembly version — tolerated, same product version).");
						}
						return assemblies[i];
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			return null;
		}

		public override void OnInitializeMelon()
		{
			try
			{
				AppDomain.CurrentDomain.AssemblyResolve += ResolveS1ApiAny;
			}
			catch
			{
			}
			ModConfig.Initialize();
			NDLog.DebugLogging = ModConfig.DebugLogging;
			if (!IsAssemblyLoaded("S1API"))
			{
				_s1apiMissing = true;
				NDLog.Error("S1API NOT found — TheMob requires S1API (plugin 'S1APILoader' + 'S1API.Il2Cpp.MelonLoader.dll'). Mod is DISABLED (no world content, no quests). Please install S1API and restart the game.");
				return;
			}
			try
			{
				MobFamilyRegistry.Register((MobFamily)(object)new NdranghetaFamily());
			}
			catch (Exception ex)
			{
				NDLog.Warn("[MOB] family registration failed: " + ex.Message);
			}
			NDLog.Info("v" + ((MelonBase)this).Info.Version + " initializing.");
			try
			{
				LuckyNetSync.Initialize();
			}
			catch (Exception ex2)
			{
				_netLayerDown = true;
				NDLog.Warn("Net layer unavailable (SteamNetworkLib missing?) — running solo. " + ex2.GetType().Name);
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (_s1apiMissing)
			{
				return;
			}
			_inMainScene = string.Equals(sceneName, "Main", StringComparison.Ordinal);
			if (!_inMainScene)
			{
				_npcSpawned = false;
				_startupTimer = 0f;
				_saveDataRefreshTimer = 0f;
				_wasAuthority = false;
				_demotedToClient = false;
				IntroController.ResetForSceneReload();
				try
				{
					TerritoryHandover.ForceReset();
				}
				catch
				{
				}
				PizzoJobManager.ResetForSceneReload();
				RankManager.ResetForSceneReload();
				DailyTribute.ResetForSceneReload();
				BattesimoController.ResetForSceneReload();
				ConsentController.ResetForSceneReload();
				LuckyBrawlManager.ResetForSceneReload();
				LaBombaManager.ResetForSceneReload();
				RapimentoManager.ResetForSceneReload();
				TortureManager.ResetForSceneReload();
				try
				{
					GangBattleManager.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					GangWarManager.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					FearState.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					FaidaState.ResetForSceneReload();
				}
				catch
				{
				}
				CarBombManager.ResetForSceneReload();
				InformantiManager.ResetForSceneReload();
				RealEstateManager.ResetForSceneReload();
				LuckyTargetPicker.ResetForSceneReload();
				PropVisuals.ResetForSceneReload();
				try
				{
					MobTeleport.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					MirrorRenderer.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					VisualMirror.Reset();
				}
				catch
				{
				}
				try
				{
					TeleportMirror.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					FamigliaReskinSync.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					Sfx.ResetForSceneReload();
				}
				catch
				{
				}
				try
				{
					MobFamilyRegistry.ResetAllForSceneReload();
				}
				catch
				{
				}
				try
				{
					LuckyCombatDriver.Reset();
				}
				catch
				{
				}
				_staleMarkerSweepAt = 0f;
				ClientActionNet.Reset();
				_clientDropoffSentFor = null;
				_clientShortCashSmsFor = null;
				_coopPaySeqApplied = -1;
				_clientBattAnnounced = false;
				_clientBattAttackSent = false;
				try
				{
					BattesimoQuest.ClearInstanceForNext();
				}
				catch
				{
				}
				_clientConsentShown = false;
				_clientMetSent = false;
				try
				{
					ClientIntroQuest.ResetForSceneReload();
				}
				catch
				{
				}
				_clientChatMenuBuilt = false;
				_clientChatMenuState = -1;
			}
			else
			{
				NDLog.Debug("Entered Main scene — waiting for spawn delay.");
				_staleMarkerSweepAt = Time.time + 12f;
				ArmDepositoReloadRescue();
			}
		}

		private static void ArmDepositoReloadRescue()
		{
			bool flag = _depositoRescueUntil > Time.time;
			_depositoRescueAt = Time.time + 1f;
			_depositoRescueUntil = Time.time + 30f;
			_depositoLastScreenUpAt = Time.time;
			if (!flag)
			{
				_depositoReloadDetected = false;
				_depositoForceDismissAt = 0f;
				_depositoForcedDismiss = false;
			}
		}

		public override void OnGUI()
		{
			if (_s1apiMissing)
			{
				DrawS1ApiMissingBanner();
				return;
			}
			try
			{
				TortureManager.OnGUI();
			}
			catch
			{
			}
			try
			{
				GangBattleManager.OnGUI();
			}
			catch
			{
			}
			try
			{
				GangWarManager.OnGUI();
			}
			catch
			{
			}
			try
			{
				InformantiManager.OnGUI();
			}
			catch
			{
			}
		}

		private static void DrawS1ApiMissingBanner()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00bf: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0028: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (_s1apiWarnStyle == null)
				{
					_s1apiWarnStyle = new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)4,
						fontSize = 15,
						fontStyle = (FontStyle)1,
						wordWrap = true
					};
					_s1apiWarnStyle.normal.textColor = Color.white;
				}
				float num = Mathf.Min(740f, (float)Screen.width - 20f);
				float num2 = 64f;
				float num3 = ((float)Screen.width - num) * 0.5f;
				float num4 = 12f;
				Color backgroundColor = GUI.backgroundColor;
				Color color = GUI.color;
				GUI.backgroundColor = new Color(0.55f, 0.05f, 0.05f, 0.92f);
				GUI.Box(new Rect(num3, num4, num, num2), GUIContent.none);
				GUI.color = Color.white;
				GUI.Label(new Rect(num3 + 12f, num4 + 6f, num - 24f, num2 - 12f), "TheMob (Ndrangheta) is DISABLED — S1API not found.\nInstall the S1APILoader plugin + S1API.Il2Cpp.MelonLoader.dll (v3.0.5) and restart the game.", _s1apiWarnStyle);
				GUI.backgroundColor = backgroundColor;
				GUI.color = color;
			}
			catch
			{
			}
		}

		public override void OnUpdate()
		{
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			if (_s1apiMissing)
			{
				return;
			}
			if (!_netLayerDown)
			{
				try
				{
					LuckyNetSync.Tick();
					QuestNetSync.Tick();
				}
				catch (Exception ex)
				{
					_netLayerDown = true;
					NDLog.Warn("Net layer unavailable (SteamNetworkLib missing?) — running solo. " + ex.GetType().Name);
				}
			}
			if (!_inMainScene)
			{
				return;
			}
			if (!_netDiagDone)
			{
				_netDiagTimer += Time.deltaTime;
				if (_netDiagTimer >= 5f)
				{
					_netDiagDone = true;
					SessionGate.LogDiagnostics();
				}
			}
			bool isAuthority = SessionGate.IsAuthority;
			if (isAuthority != _wasAuthority)
			{
				NDLog.Debug($"[AUTH] {_wasAuthority}->{isAuthority} {SessionGate.Describe()}");
			}
			if (_wasAuthority && !isAuthority)
			{
				DemoteToClient();
			}
			_wasAuthority = isAuthority;
			if (!_netLayerDown)
			{
				if (isAuthority)
				{
					GetCurrentStepSync(out var entryText, out var entryPoi);
					QuestNetSync.PublishState(RecruitmentState.WelcomeSmsSent || RecruitmentState.Recruited, RecruitmentState.Recruited, RecruitmentState.HasMetDon, GetCurrentJobCode(), GetCurrentJobTarget(), GetCurrentJobTargetPos(), (int)PizzoJobManager.CurrentPhase, GetCurrentJobCut(), GetCurrentJobDropReward(), entryText, entryPoi, PizzoJobManager.CoopPaySeq, PizzoJobManager.CoopPayAmount, PizzoJobManager.CoopPayExclude, (int)BattesimoController.CurrentStage, TerritoryHandover.HandoverActive, RealEstateManager.SyncCode, FearState.Points, FaidaState.BenziePoints, BossMarkerSync.Label, GetBossMarkerPos(), RapimentoManager.ActiveVanGuid ?? "", ConsentController.QuestionPending, BossMarkerSync.Kind, RealEstateManager.GuardPatrolSyncCode, BossMarkerSync.RaidSeconds, IncomeTracker.QuestIncome, IncomeTracker.OtherIncome, RapimentoManager.IsRecruiting, RapimentoManager.OpDropActive, FmtVec(RapimentoManager.OpDropPos), RapimentoManager.OpDropReachInt, RapimentoManager.CurrentVariant, TortureManager.SceneActive, FmtVec(TortureManager.ScenePlayerPos), FmtVec(TortureManager.SceneReturnPos), TortureManager.SceneReturnYawInt, TortureManager.SceneBeginSeq, TortureManager.SceneEndSeq, VisualMirror.Encode(), TeleportMirror.Encode(), LuckyBrawlManager.BrawlPhase, FamigliaReskinSync.Encode(), TortureManager.SceneTimeLeftInt, TortureManager.SceneKoReached, Sfx.MirrorSeq, Sfx.MirrorName, (int)(Sfx.MirrorVol * 100f), Sfx.LoopName, RapimentoManager.ReleasedVictimSeq, RapimentoManager.ReleasedVictimObjId, FaidaState.TriadPoints);
				}
				try
				{
					TeleportMirror.TickLocalApply();
				}
				catch (Exception ex2)
				{
					NDLog.DebugWarn("[TPMIRROR] host apply: " + ex2.Message);
				}
				ClientActionNet.TickHost(Time.deltaTime);
				try
				{
					if (isAuthority)
					{
						IncomeTracker.ClearDisplayOverride();
					}
					else
					{
						IncomeTracker.SetDisplayOverride(QuestNetSync.RemoteQuestIncome, QuestNetSync.RemoteOtherIncome);
					}
				}
				catch
				{
				}
			}
			if (_staleMarkerSweepAt > 0f && Time.time >= _staleMarkerSweepAt)
			{
				_staleMarkerSweepAt = 0f;
				try
				{
					LuckyBrawlManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					LaBombaManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					RapimentoManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					GangBattleManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					GangWarManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					CarBombManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					InformantiManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					RealEstateManager.SweepStaleMarker();
				}
				catch
				{
				}
				try
				{
					KidnapSackItem.EnsureRegistered();
				}
				catch
				{
				}
			}
			if (!isAuthority && _depositoRescueUntil > 0f && Time.time < _depositoRescueUntil)
			{
				bool flag = GameCompat.IsLoadingScreenOpen();
				if (flag)
				{
					_depositoLastScreenUpAt = Time.time;
				}
				if ((flag || Time.time - _depositoLastScreenUpAt < 5f) && Time.time >= _depositoRescueAt)
				{
					_depositoRescueAt = Time.time + 0.5f;
					bool flag2 = false;
					try
					{
						flag2 = LagerRoom.RescuePlayerIfInside();
					}
					catch
					{
					}
					if (flag2)
					{
						_depositoReloadDetected = true;
					}
				}
				if (_depositoReloadDetected && flag)
				{
					if (_depositoForceDismissAt <= 0f)
					{
						_depositoForceDismissAt = Time.time + 4f;
					}
					else if (Time.time >= _depositoForceDismissAt)
					{
						bool flag3 = GameCompat.ForceCloseLoadingScreen();
						if (!_depositoForcedDismiss)
						{
							_depositoForcedDismiss = true;
							NDLog.Debug("[LAGER] client stuck on orphaned join-loading-screen after deposito-reload — force-closing it (" + (flag3 ? "ok" : "still open") + ").");
						}
					}
				}
				else if (!flag)
				{
					_depositoForceDismissAt = 0f;
				}
				if (_depositoReloadDetected && !flag)
				{
					Player local = Player.Local;
					if ((Object)(object)local != (Object)null && (Object)(object)((Component)local).transform != (Object)null && ((Component)local).transform.position.y > -7f)
					{
						_depositoRescueUntil = 0f;
						_depositoForceDismissAt = 0f;
						_depositoForcedDismiss = false;
					}
				}
			}
			else if (_depositoRescueUntil > 0f && (isAuthority || Time.time >= _depositoRescueUntil))
			{
				_depositoRescueUntil = 0f;
				_depositoForceDismissAt = 0f;
				_depositoForcedDismiss = false;
			}
			if (!isAuthority)
			{
				bool flag4 = false;
				bool flag5 = false;
				try
				{
					flag4 = GameCompat.IsGameLoading();
				}
				catch
				{
				}
				try
				{
					flag5 = GameCompat.IsLoadingScreenOpen();
				}
				catch
				{
				}
				Player val = null;
				try
				{
					val = Player.Local;
				}
				catch
				{
				}
				if (flag4 && flag5 && (Object)(object)val != (Object)null)
				{
					if (_clientLoadStuckSince <= 0f)
					{
						_clientLoadStuckSince = Time.time;
						_clientLoadDiagAt = 0f;
						_clientLoadReqAt = 0f;
						_clientLoadReqs = 0;
						_clientGatesOkSince = 0f;
					}
					float num = Time.time - _clientLoadStuckSince;
					if (Time.time >= _clientLoadDiagAt)
					{
						_clientLoadDiagAt = Time.time + 3f;
						try
						{
							GameCompat.LogClientLoadGateState(num);
						}
						catch
						{
						}
					}
					bool flag6 = false;
					try
					{
						flag6 = GameCompat.ClientLoadGatesSatisfied();
					}
					catch
					{
					}
					if (flag6)
					{
						if (_clientGatesOkSince <= 0f)
						{
							_clientGatesOkSince = Time.time;
						}
					}
					else
					{
						_clientGatesOkSince = 0f;
						if (num >= 5f && _clientLoadReqs < 3 && Time.time >= _clientLoadReqAt)
						{
							_clientLoadReqAt = Time.time + 4f;
							_clientLoadReqs++;
							bool flag7 = false;
							try
							{
								flag7 = GameCompat.TryReRequestPlayerData();
							}
							catch
							{
							}
							NDLog.Debug($"[CLIENTLOAD] gates not satisfied at {num:0}s — re-requesting player data (attempt {_clientLoadReqs}/3, sent={flag7}).");
						}
					}
					bool flag8 = _clientGatesOkSince > 0f && Time.time - _clientGatesOkSince >= 3f;
					bool flag9 = num >= 18f;
					if (flag8 || flag9)
					{
						bool flag10 = false;
						try
						{
							flag10 = GameCompat.ForceCloseLoadingScreen();
						}
						catch
						{
						}
						if (!_clientLoadForced)
						{
							_clientLoadForced = true;
							NDLog.Debug(string.Format("[CLIENTLOAD] load gates satisfied but screen stuck (dead LoadAsClient coroutine) — forcing load complete at {0:0}s ({1}; reason={2}).", num, flag10 ? "closed" : "still open", flag8 ? "gates+grace" : "timeout"));
						}
					}
				}
				else
				{
					_clientLoadStuckSince = 0f;
					_clientLoadDiagAt = 0f;
					_clientLoadForced = false;
					_clientLoadReqAt = 0f;
					_clientLoadReqs = 0;
					_clientGatesOkSince = 0f;
				}
			}
			try
			{
				if (TerritoryHandover.IsBossForLocalPeer && !_netLayerDown && DonMessaging.NeedsChoiceInterfaceRestore())
				{
					if (_chatRestoreAt <= 0f)
					{
						_chatRestoreAt = Time.time + 1.5f;
					}
					else if (Time.time >= _chatRestoreAt)
					{
						_chatRestoreAt = 0f;
						NDLog.Debug("[CHAT] interface was button-less — restoring main menu (FIX-151 watchdog).");
						LuckyChatController.OpenMainMenu();
					}
				}
				else
				{
					_chatRestoreAt = 0f;
				}
			}
			catch (Exception ex3)
			{
				NDLog.DebugWarn("[CHAT] interface watchdog: " + ex3.Message);
			}
			if (_demotedToClient || !isAuthority)
			{
				if (_netLayerDown)
				{
					return;
				}
				ClientPresenceTick();
				try
				{
					bool villaOwned = QuestNetSync.HasRemoteState && (QuestNetSync.RemoteEstate & 8) != 0;
					RealEstateManager.ClientGuardTick(villaOwned, QuestNetSync.HasRemoteState ? QuestNetSync.RemoteGuardPatrol : 0);
				}
				catch
				{
				}
				try
				{
					RapimentoManager.Tick(Time.deltaTime);
				}
				catch (Exception ex4)
				{
					NDLog.DebugWarn("[CLIENT] RapimentoManager.Tick: " + ex4.Message);
				}
				try
				{
					CarBombManager.Tick(Time.deltaTime);
				}
				catch (Exception ex5)
				{
					NDLog.DebugWarn("[CLIENT] CarBombManager.Tick: " + ex5.Message);
				}
				try
				{
					LaBombaManager.ClientTickBeep();
				}
				catch (Exception ex6)
				{
					NDLog.DebugWarn("[CLIENT] LaBombaManager.ClientTickBeep: " + ex6.Message);
				}
				try
				{
					if (QuestNetSync.HasRemoteState)
					{
						Sfx.ApplyMirror(QuestNetSync.RemoteSfxSeq, QuestNetSync.RemoteSfxName, (float)QuestNetSync.RemoteSfxVol100 / 100f, QuestNetSync.RemoteSfxLoop);
					}
				}
				catch (Exception ex7)
				{
					NDLog.DebugWarn("[CLIENT] Sfx.ApplyMirror: " + ex7.Message);
				}
				try
				{
					if (QuestNetSync.HasRemoteState)
					{
						RapimentoManager.ClientApplyRelease(QuestNetSync.RemoteReleasedSeq, QuestNetSync.RemoteReleasedObjId);
					}
				}
				catch (Exception ex8)
				{
					NDLog.DebugWarn("[CLIENT] RapimentoManager.ClientApplyRelease: " + ex8.Message);
				}
				try
				{
					LuckyNetSync.ClientTick(Time.deltaTime);
				}
				catch (Exception ex9)
				{
					NDLog.DebugWarn("[CLIENT] LuckyNetSync.ClientTick: " + ex9.Message);
				}
				try
				{
					MirrorRenderer.RenderVisuals(VisualMirror.Decode(QuestNetSync.RemoteVisualsRaw));
				}
				catch (Exception ex10)
				{
					NDLog.DebugWarn("[CLIENT] MirrorRenderer.RenderVisuals: " + ex10.Message);
				}
				try
				{
					MirrorRenderer.RenderTeleports(TeleportMirror.Decode(QuestNetSync.RemoteTeleportsRaw));
				}
				catch (Exception ex11)
				{
					NDLog.DebugWarn("[CLIENT] MirrorRenderer.RenderTeleports: " + ex11.Message);
				}
				try
				{
					FamigliaReskinSync.ClientApply(QuestNetSync.RemoteFamigliaGoons);
				}
				catch (Exception ex12)
				{
					NDLog.DebugWarn("[CLIENT] FamigliaReskinSync: " + ex12.Message);
				}
				try
				{
					LuckyChatController.ClientBrawlMenuTick();
				}
				catch (Exception ex13)
				{
					NDLog.DebugWarn("[CLIENT] ClientBrawlMenuTick: " + ex13.Message);
				}
				try
				{
					RapimentoManager.ClientApplyVanColor();
				}
				catch (Exception ex14)
				{
					NDLog.DebugWarn("[CLIENT] ClientApplyVanColor: " + ex14.Message);
				}
				try
				{
					TortureManager.ClientGuardTick();
					return;
				}
				catch (Exception ex15)
				{
					NDLog.DebugWarn("[CLIENT] TortureManager.ClientGuardTick: " + ex15.Message);
					return;
				}
			}
			try
			{
				MobFamilyRegistry.EnsureDefaultActive();
			}
			catch
			{
			}
			if (!_npcSpawned)
			{
				_startupTimer += Time.deltaTime;
				if (!(_startupTimer < 3f))
				{
					TrySpawnDon();
				}
				return;
			}
			IntroController.Tick(Time.deltaTime);
			PizzoJobManager.Tick(Time.deltaTime);
			IntroQuest.RefreshPoi();
			if (RecruitmentState.Recruited)
			{
				if (TerritoryHandover.HandoverActive)
				{
					PersistentDonPresenceQuest.CompleteAndClear();
				}
				else
				{
					PersistentDonPresenceQuest.EnsureStarted();
					PersistentDonPresenceQuest.RefreshPoi();
				}
			}
			if (!ProductRegistry.IsRegistered)
			{
				ProductRegistry.TryRegister();
			}
			DailyTribute.Tick(Time.deltaTime);
			BattesimoController.Tick(Time.deltaTime);
			ConsentController.Tick(Time.deltaTime);
			LuckyCombatDriver.Tick(Time.deltaTime);
			LuckyBrawlManager.Tick(Time.deltaTime);
			LaBombaManager.Tick(Time.deltaTime);
			InformantiManager.Tick(Time.deltaTime);
			RapimentoManager.Tick(Time.deltaTime);
			TortureManager.Tick(Time.deltaTime);
			GangBattleManager.Tick(Time.deltaTime);
			GangWarManager.Tick(Time.deltaTime);
			CarBombManager.Tick(Time.deltaTime);
			RealEstateManager.Tick(Time.deltaTime);
			LagerGrid.Tick(Time.deltaTime);
			LuckyNPC.TickWatchdog();
			DonSalvatoreNPC.TickWatchdog();
			GuardNPC.TickHiddenWatchdog();
			HeartbeatSave();
		}

		private void HeartbeatSave()
		{
			_saveDataRefreshTimer -= Time.deltaTime;
			if (_saveDataRefreshTimer <= 0f)
			{
				_saveDataRefreshTimer = 1f;
				NdranghetaSaveData.Instance?.PushNow();
			}
		}

		private void TrySpawnDon()
		{
			try
			{
				DonSalvatoreNPC instance = DonSalvatoreNPC.Instance;
				if (instance != null)
				{
					GameObject val = null;
					try
					{
						val = ((NPC)instance).gameObject;
					}
					catch
					{
					}
					if ((Object)(object)val != (Object)null)
					{
						_npcSpawned = true;
						EnsureVillaGuardsLoaded();
						return;
					}
				}
				try
				{
					NPC nPC = NPCManager.GetNPC("Ndrangheta_don_salvatore");
					if ((Object)(object)nPC != (Object)null && (Object)(object)((Component)nPC).gameObject != (Object)null)
					{
						_npcSpawned = true;
						EnsureVillaGuardsLoaded();
						return;
					}
				}
				catch
				{
				}
				NDLog.Debug("[SPAWN] creating Don/Lucky now — " + SessionGate.Describe());
				try
				{
					if (SessionGate.IsAuthority && LuckyNPC.Instance == null && (Object)(object)NPCManager.GetNPC("Ndrangheta_lucky") == (Object)null)
					{
						new LuckyNPC();
						NDLog.Debug($"LuckyNPC instantiated (visible={true}).");
					}
				}
				catch (Exception ex)
				{
					NDLog.Warn("LuckyNPC spawn: " + ex.Message);
				}
				new DonSalvatoreNPC();
				_npcSpawned = true;
				NDLog.Debug("DonSalvatoreNPC instantiated.");
				EnsureVillaGuardsLoaded();
			}
			catch (Exception ex2)
			{
				NDLog.Warn("DonSalvatoreNPC spawn failed (will retry): " + ex2.Message);
				_startupTimer = 0f;
			}
		}

		private static void EnsureVillaGuardsLoaded()
		{
			try
			{
				GuardNPC.CreateAll();
			}
			catch (Exception ex)
			{
				NDLog.Warn("GuardNPC.CreateAll: " + ex.Message);
			}
		}
	}
	public sealed class NdranghetaSaveData : Saveable
	{
		[SaveableField("Ndrangheta_state")]
		private NdranghetaSnapshot _data = new NdranghetaSnapshot();

		private static string _cachedGridItems = "";

		public static NdranghetaSaveData Instance { get; private set; }

		public NdranghetaSaveData()
		{
			try
			{
				_data = CaptureFromLiveState();
			}
			catch
			{
			}
			Instance = this;
		}

		public void PushNow(bool refreshGrids = false)
		{
			try
			{
				_data = CaptureFromLiveState(refreshGrids);
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("PushNow: " + ex.Message);
			}
		}

		protected override void OnLoaded()
		{
			try
			{
				NDLog.Debug($"SaveData OnLoaded: recruited={_data?.Recruited} count={_data?.PizzoCompletedCount} phase={_data?.JobPhase}");
				ApplyToLiveState(_data ?? new NdranghetaSnapshot());
			}
			catch (Exception ex)
			{
				NDLog.Warn("OnLoaded apply failed: " + ex.Message);
			}
		}

		protected override void OnSaved()
		{
			try
			{
				_data = CaptureFromLiveState();
			}
			catch
			{
			}
		}

		private static string GridItemsCapture(bool refresh)
		{
			if (refresh)
			{
				try
				{
					_cachedGridItems = GridPersistence.CaptureAllString();
				}
				catch (Exception ex)
				{
					NDLog.DebugWarn("GridItems capture: " + ex.Message);
				}
			}
			return _cachedGridItems;
		}

		public static NdranghetaSnapshot CaptureFromLiveState(bool refreshGrids = true)
		{
			PizzoJobManager.JobSnapshot jobSnapshot = PizzoJobManager.CaptureSnapshot();
			return new NdranghetaSnapshot
			{
				WelcomeSmsSent = RecruitmentState.WelcomeSmsSent,
				HasMetDon = RecruitmentState.HasMetDon,
				Recruited = RecruitmentState.Recruited,
				CurrentRank = (int)RankManager.CurrentRank,
				LastTributeDay = DailyTribute.LastTributeDay,
				BattesimoStage = BattesimoController.SaveStage,
				BattesimoAttackDay = BattesimoController.SaveAttackDay,
				BattesimoAttackTime = BattesimoController.SaveAttackTime,
				ConsentState = (int)ConsentController.CurrentState,
				LastConsentAskDay = ConsentController.LastAskDay,
				PizzoCompletedCount = jobSnapshot.CompletedCount,
				JobPhase = jobSnapshot.Phase,
				JobType = jobSnapshot.JobType,
				JobCooldownRemaining = jobSnapshot.CooldownRemaining,
				JobCashSpawned = jobSnapshot.CashSpawned,
				JobTargetName = jobSnapshot.TargetName,
				JobDropBName = jobSnapshot.DropBName,
				JobDropBGuid = jobSnapshot.DropBGuid,
				JobDropBPosX = jobSnapshot.DropBPosX,
				JobDropBPosY = jobSnapshot.DropBPosY,
				JobDropBPosZ = jobSnapshot.DropBPosZ,
				JobTargetShopHint = jobSnapshot.TargetShopHint,
				JobDropName = jobSnapshot.DropName,
				JobDropGuid = jobSnapshot.DropGuid,
				JobDropPosX = jobSnapshot.DropPosX,
				JobDropPosY = jobSnapshot.DropPosY,
				JobDropPosZ = jobSnapshot.DropPosZ,
				JobEnvelopeAmount = jobSnapshot.EnvelopeAmount,
				JobCutAmount = jobSnapshot.CutAmount,
				JobRewardAmount = jobSnapshot.RewardAmount,
				JobIsCurfew = jobSnapshot.IsCurfew,
				JobContrattoTargetName = jobSnapshot.ContrattoTargetName,
				JobContrattoTargetCategory = jobSnapshot.ContrattoTargetCategory,
				JobCaricoItemId = jobSnapshot.CaricoItemId,
				JobCaricoItemDisplayName = jobSnapshot.CaricoItemDisplayName,
				JobCaricoQuantity = jobSnapshot.CaricoQuantity,
				JobCaricoBonusBricks = jobSnapshot.CaricoBonusBricks,
				JobSchemaVersion = jobSnapshot.SchemaVersion,
				DropoffBaseline = jobSnapshot.DropoffBaseline,
				HandoverActive = TerritoryHandover.HandoverActive,
				ContrattiCompletedCount = PizzoJobManager.ContrattiCompletedCount,
				LuckyTargetName = jobSnapshot.LuckyTargetName,
				LuckyTargetCategory = jobSnapshot.LuckyTargetCategory,
				LuckyTargetRegion = jobSnapshot.LuckyTargetRegion,
				LuckyMethod = jobSnapshot.LuckyMethod,
				LuckyDispatched = jobSnapshot.LuckyDispatched,
				EstateOwned = false,
				EstateSpotIndex = 0,
				EstateFacingYaw = 0f,
				VillaOwned = RealEstateManager.VillaOwned,
				LagerMask = RealEstateManager.LagerMask,
				VillaBuildingName = (VillaLocator.BuildingName ?? ""),
				LagerFurnishA0 = RealEstateManager.GetFurnishA(0),
				LagerFurnishA1 = RealEstateManager.GetFurnishA(1),
				LagerFurnishA2 = RealEstateManager.GetFurnishA(2),
				LagerFurnishB0 = RealEstateManager.GetFurnishB(0),
				LagerFurnishB1 = RealEstateManager.GetFurnishB(1),
				LagerFurnishB2 = RealEstateManager.GetFurnishB(2),
				VillaFurnishA = RealEstateManager.GetFurnishA(3),
				VillaFurnishB = RealEstateManager.GetFurnishB(3),
				GridItems = GridItemsCapture(refreshGrids),
				KidnapVanGuid = (RapimentoManager.ActiveVanGuid ?? ""),
				IncomeQuest = IncomeTracker.QuestIncome,
				IncomeOther = IncomeTracker.OtherIncome,
				FearPoints = FearState.Points,
				FaidaBenziePoints = FaidaState.BenziePoints,
				FaidaReveals = FaidaState.RevealedDeals,
				FaidaTriadPoints = FaidaState.TriadPoints
			};
		}

		public static void ApplyToLiveState(NdranghetaSnapshot snap)
		{
			if (snap == null)
			{
				snap = new NdranghetaSnapshot();
			}
			try
			{
				GridPersistence.LoadStash(snap.GridItems);
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("GridItems stash: " + ex.Message);
			}
			try
			{
				RapimentoManager.SetPendingOrphanVan(snap.KidnapVanGuid);
			}
			catch (Exception ex2)
			{
				NDLog.DebugWarn("KidnapVan pending: " + ex2.Message);
			}
			try
			{
				IncomeTracker.LoadSnapshot(snap.IncomeQuest, snap.IncomeOther);
			}
			catch (Exception ex3)
			{
				NDLog.DebugWarn("Income restore: " + ex3.Message);
			}
			try
			{
				FearState.LoadPoints(snap.FearPoints);
			}
			catch (Exception ex4)
			{
				NDLog.DebugWarn("Fear restore: " + ex4.Message);
			}
			try
			{
				FaidaState.Load(snap.FaidaBenziePoints, snap.FaidaReveals, snap.FaidaTriadPoints);
			}
			catch (Exception ex5)
			{
				NDLog.DebugWarn("Faida restore: " + ex5.Message);
			}
			RecruitmentState.WelcomeSmsSent = snap.WelcomeSmsSent;
			RecruitmentState.HasMetDon = snap.HasMetDon;
			RecruitmentState.Recruited = snap.Recruited;
			RankManager.LoadRank((Rank)snap.CurrentRank);
			RankManager.ReconcileFromCompleted(snap.PizzoCompletedCount);
			DailyTribute.LoadLastDay(snap.LastTributeDay);
			BattesimoController.LoadStage(snap.BattesimoStage, snap.BattesimoAttackDay, snap.BattesimoAttackTime);
			ConsentController.LoadState(snap.ConsentState, snap.LastConsentAskDay);
			TerritoryHandover.LoadState(snap.HandoverActive);
			PizzoJobManager.LoadContrattiCount(snap.ContrattiCompletedCount);
			try
			{
				RealEstateManager.LoadState(snap.VillaOwned, snap.LagerMask, snap.VillaBuildingName, snap.EstateOwned, snap.EstateSpotIndex);
				RealEstateManager.LoadFurnish(snap.LagerFurnishA0, snap.LagerFurnishA1, snap.LagerFurnishA2, snap.VillaFurnishA, snap.LagerFurnishB0, snap.LagerFurnishB1, snap.LagerFurnishB2, snap.VillaFurnishB);
			}
			catch (Exception ex6)
			{
				NDLog.DebugWarn("RealEstate LoadState: " + ex6.Message);
			}
			PizzoJobManager.LoadFromSnapshot(new PizzoJobManager.JobSnapshot
			{
				Phase = snap.JobPhase,
				JobType = snap.JobType,
				CompletedCount = snap.PizzoCompletedCount,
				CooldownRemaining = snap.JobCooldownRemaining,
				CashSpawned = snap.JobCashSpawned,
				TargetName = snap.JobTargetName,
				DropBName = snap.JobDropBName,
				DropBGuid = snap.JobDropBGuid,
				DropBPosX = snap.JobDropBPosX,
				DropBPosY = snap.JobDropBPosY,
				DropBPosZ = snap.JobDropBPosZ,
				TargetShopHint = snap.JobTargetShopHint,
				DropName = snap.JobDropName,
				DropGuid = snap.JobDropGuid,
				DropPosX = snap.JobDropPosX,
				DropPosY = snap.JobDropPosY,
				DropPosZ = snap.JobDropPosZ,
				EnvelopeAmount = snap.JobEnvelopeAmount,
				CutAmount = snap.JobCutAmount,
				RewardAmount = snap.JobRewardAmount,
				IsCurfew = snap.JobIsCurfew,
				ContrattoTargetName = snap.JobContrattoTargetName,
				ContrattoTargetCategory = snap.JobContrattoTargetCategory,
				CaricoItemId = snap.JobCaricoItemId,
				CaricoItemDisplayName = snap.JobCaricoItemDisplayName,
				CaricoQuantity = snap.JobCaricoQuantity,
				CaricoBonusBricks = snap.JobCaricoBonusBricks,
				SchemaVersion = snap.JobSchemaVersion,
				LuckyTargetName = snap.LuckyTargetName,
				LuckyTargetCategory = snap.LuckyTargetCategory,
				LuckyTargetRegion = snap.LuckyTargetRegion,
				LuckyMethod = snap.LuckyMethod,
				LuckyDispatched = snap.LuckyDispatched,
				DropoffBaseline = snap.DropoffBaseline
			});
			if (snap.HandoverActive && PizzoJobManager.Current == null)
			{
				try
				{
					LuckyChatController.RefreshIfHandoverActive();
				}
				catch (Exception ex7)
				{
					NDLog.DebugWarn("OnLoaded LuckyChat refresh: " + ex7.Message);
				}
			}
		}
	}
	[Serializable]
	public sealed class NdranghetaSnapshot
	{
		public bool WelcomeSmsSent;

		public bool HasMetDon;

		public bool Recruited;

		public int CurrentRank;

		public int LastTributeDay = -1;

		public int BattesimoStage;

		public int BattesimoAttackDay;

		public int BattesimoAttackTime;

		public int ConsentState;

		public int LastConsentAskDay = -1;

		public int PizzoCompletedCount;

		public int JobPhase;

		public int JobType;

		public float JobCooldownRemaining;

		public bool JobCashSpawned;

		public string JobTargetName;

		public string JobDropBName;

		public string JobDropBGuid;

		public float JobDropBPosX;

		public float JobDropBPosY;

		public float JobDropBPosZ;

		public string JobTargetShopHint;

		public string JobDropName;

		public string JobDropGuid;

		public float JobDropPosX;

		public float JobDropPosY;

		public float JobDropPosZ;

		public int JobEnvelopeAmount;

		public int JobCutAmount;

		public int JobRewardAmount;

		public bool JobIsCurfew;

		public string JobContrattoTargetName;

		public string JobContrattoTargetCategory;

		public string JobCaricoItemId;

		public string JobCaricoItemDisplayName;

		public int JobCaricoQuantity;

		public int JobCaricoBonusBricks;

		public int JobSchemaVersion;

		public int DropoffBaseline = -1;

		public bool HandoverActive;

		public int ContrattiCompletedCount;

		public string LuckyTargetName;

		public string LuckyTargetCategory;

		public string LuckyTargetRegion;

		public int LuckyMethod;

		public bool LuckyDispatched;

		public bool EstateOwned;

		public int EstateSpotIndex;

		public float EstateFacingYaw;

		public bool VillaOwned;

		public int LagerMask;

		public string VillaBuildingName;

		public int LagerFurnishA0;

		public int LagerFurnishA1;

		public int LagerFurnishA2;

		public int LagerFurnishB0;

		public int LagerFurnishB1;

		public int LagerFurnishB2;

		public int VillaFurnishA;

		public int VillaFurnishB;

		public string GridItems;

		public string KidnapVanGuid;

		public long IncomeQuest;

		public long IncomeOther;

		public int FearPoints;

		public int FaidaBenziePoints;

		public int FaidaReveals;

		public int FaidaTriadPoints;
	}
}
namespace Ndrangheta.Quests
{
	[QuestName("Il Battesimo")]
	internal sealed class BattesimoQuestId : IQuestIdentifier
	{
	}
	internal sealed class BattesimoQuest : Quest
	{
		public const string QuestGuid = "Ndrangheta.battesimo";

		protected override string Title => "Il Battesimo";

		protected override string Description => "The 'Ndrina wants proof you can bleed without ending up in cuffs. Hit a cop, any cop. Then survive an hour clean. After that the famiglia will trust you with the real work — il contratto.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryAttack { get; private set; }

		public QuestEntry EntrySurvive { get; private set; }

		internal static BattesimoQuest Instance { get; private set; }

		public BattesimoQuest()
		{
			EntryAttack = ((Quest)this).AddEntry("Bleed for the famiglia — attack any cop and walk away", (Vector3?)null);
			EntrySurvive = ((Quest)this).AddEntry("Survive one hour clean, no arrests", (Vector3?)null);
			try
			{
				EntryAttack.ClearPOI();
			}
			catch
			{
			}
			try
			{
				EntrySurvive.ClearPOI();
			}
			catch
			{
			}
			Instance = this;
			Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");
			if ((Object)(object)val != (Object)null)
			{
				QuestIconHelper.ApplyAsync((Quest)(object)this, val);
			}
			NDLog.Debug("BattesimoQuest constructed.");
		}

		public static void EnsureCreated()
		{
			try
			{
				if (Instance == null && QuestManager.GetQuestByName("Il Battesimo") == null)
				{
					QuestManager.CreateQuest<BattesimoQuest>("Ndrangheta.battesimo");
					NDLog.Debug("BattesimoQuest created.");
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("BattesimoQuest.EnsureCreated: " + ex.Message);
			}
		}

		public static void EnsureFirstEntryActive()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				BattesimoQuest instance = Instance;
				if (instance?.EntryAttack != null && (int)instance.EntryAttack.State == 0)
				{
					instance.EntryAttack.Begin();
				}
			}
			catch
			{
			}
		}

		public static void OnAttackDetected()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			try
			{
				BattesimoQuest instance = Instance;
				if (instance?.EntryAttack != null && (int)instance.EntryAttack.State != 2)
				{
					instance.EntryAttack.Complete();
				}
				if (instance?.EntrySurvive != null && (int)instance.EntrySurvive.State == 0)
				{
					instance.EntrySurvive.Begin();
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("BattesimoQuest.OnAttackDetected: " + ex.Message);
			}
		}

		public static void OnSurvived()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				BattesimoQuest instance = Instance;
				if (instance?.EntrySurvive != null && (int)instance.EntrySurvive.State != 2)
				{
					instance.EntrySurvive.Complete();
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("BattesimoQuest.OnSurvived: " + ex.Message);
			}
		}

		public static void ClearInstanceForNext()
		{
			Instance = null;
		}
	}
	[QuestName("Pacco Bomba")]
	internal sealed class BombaMarkerQuestId : IQuestIdentifier
	{
	}
	internal sealed class BombaMarkerQuest : Quest
	{
		private static string _pendingText = "Pacco Bomba";

		internal static BombaMarkerQuest Instance { get; private set; }

		protected override string Title => "Pacco Bomba";

		protected override string Description => "The package is on its way. Keep your distance when it's armed.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public BombaMarkerQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			NDLog.Debug("[BOMBA] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					return;
				}
				_pendingText = text ?? "Pacco Bomba";
				string text2 = $"Ndrangheta.bomba.{DateTime.UtcNow.Ticks}";
				QuestManager.CreateQuest<BombaMarkerQuest>(text2);
				if (Instance != null && ((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("BombaMarkerQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		internal static void CompleteAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.Complete();
				}
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[BOMBA] marker quest cleared.");
		}
	}
	[QuestName("Brawl")]
	internal sealed class BrawlMarkerQuestId : IQuestIdentifier
	{
	}
	internal sealed class BrawlMarkerQuest : Quest
	{
		private static string _pendingText = "Brawl";

		internal static BrawlMarkerQuest Instance { get; private set; }

		protected override string Title => "Brawl";

		protected override string Description => "Our men are ready to crack skulls. Follow the marker.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public BrawlMarkerQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			NDLog.Debug("[BRAWL] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					return;
				}
				_pendingText = text ?? "Brawl";
				string text2 = $"Ndrangheta.brawl.{DateTime.UtcNow.Ticks}";
				QuestManager.CreateQuest<BrawlMarkerQuest>(text2);
				if (Instance != null && ((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("BrawlMarkerQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		internal static void CompleteAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				PoiIconHelper.SetPoiVisible(Instance.EntryMain, visible: false);
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.ClearPOI();
				}
			}
			catch
			{
			}
			try
			{
				Instance.ForceHideHudTracker();
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain2 = Instance.EntryMain;
				if (entryMain2 != null)
				{
					entryMain2.Complete();
				}
			}
			catch
			{
			}
			try
			{
				Instance.ForceHideHudTracker();
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[BRAWL] marker quest cleared.");
		}

		internal static void FailAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				PoiIconHelper.SetPoiVisible(Instance.EntryMain, visible: false);
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.ClearPOI();
				}
			}
			catch
			{
			}
			try
			{
				Instance.ForceHideHudTracker();
			}
			catch
			{
			}
			try
			{
				QuestEntry entryMain2 = Instance.EntryMain;
				if (entryMain2 != null)
				{
					entryMain2.SetState((QuestState)3);
				}
			}
			catch
			{
			}
			try
			{
				((Quest)Instance).Fail();
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[BRAWL] marker quest FAILED + cleared.");
		}

		private Quest TryGetVanillaQuest()
		{
			try
			{
				Type type = ((object)this).GetType();
				while (type != null)
				{
					PropertyInfo property = type.GetProperty("S1Quest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null)
					{
						object? value = property.GetValue(this);
						Quest val = (Quest)((value is Quest) ? value : null);
						if ((Object)(object)val != (Object)null)
						{
							return val;
						}
					}
					FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						if (!(fieldInfo.FieldType != typeof(Quest)))
						{
							object? value2 = fieldInfo.GetValue(this);
							Quest val2 = (Quest)((value2 is Quest) ? value2 : null);
							if ((Object)(object)val2 != (Object)null)
							{
								return val2;
							}
						}
					}
					type = type.BaseType;
				}
			}
			catch
			{
			}
			return null;
		}

		private void ForceHideHudTracker()
		{
			try
			{
				Quest val = TryGetVanillaQuest();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				try
				{
					val.TrackOnBegin = false;
				}
				catch
				{
				}
				try
				{
					((object)val).GetType().GetMethod("SetIsTracked", new Type[1] { typeof(bool) })?.Invoke(val, new object[1] { false });
				}
				catch
				{
				}
				try
				{
					((object)val).GetType().GetMethod("DestroyHUDUI", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val, null);
				}
				catch
				{
				}
				try
				{
					((object)val).GetType().GetMethod("DestroyJournalEntry", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val, null);
				}
				catch
				{
				}
			}
			catch
			{
			}
		}
	}
	[QuestName("Car Bomb")]
	internal sealed class CarBombMarkerQuestId : IQuestIdentifier
	{
	}
	internal sealed class CarBombMarkerQuest : Quest
	{
		private static string _pendingText = "Car Bomb";

		internal static CarBombMarkerQuest Instance { get; private set; }

		protected override string Title => "Car Bomb";

		protected override string Description => "The car's wired. Mark the spot, give the word, and get clear before the fuse runs out.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public CarBombMarkerQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			NDLog.Debug("[CARBOMB] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					return;
				}
				_pendingText = text ?? "Car Bomb";
				string text2 = $"Ndrangheta.carbomb.{DateTime.UtcNow.Ticks}";
				QuestManager.CreateQuest<CarBombMarkerQuest>(text2);
				if (Instance != null && ((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("CarBombMarkerQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		internal static void CompleteAndClear()
		{
			if (Instance == null)
			{
				return;
			}
			try
			{
				QuestEntry entryMain = Instance.EntryMain;
				if (entryMain != null)
				{
					entryMain.Complete();
				}
			}
			catch
			{
			}
			Instance = null;
			NDLog.Debug("[CARBOMB] marker quest cleared.");
		}
	}
	[QuestName("Carico")]
	internal sealed class CaricoQuestId : IQuestIdentifier
	{
	}
	internal sealed class CaricoQuest : Quest
	{
		public static string CurrentJobGuid;

		private string _titleText;

		private string _descriptionText;

		private Vector3 _bPos;

		private Vector3 _donPos;

		protected override string Title => _titleText ?? "Carico";

		protected override string Description => _descriptionText ?? "Move a partita from one drop to another, then collect your share from the Don.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryPickup { get; private set; }

		public QuestEntry EntryDeliver { get; private set; }

		public QuestEntry EntryDropOff { get; private set; }

		internal static CaricoQuest Instance { get; private set; }

		public CaricoQuest()
		{
			EntryPickup = ((Quest)this).AddEntry("Pick up the partita", (Vector3?)null);
			EntryDeliver = ((Quest)this).AddEntry("Deliver the partita", (Vector3?)null);
			EntryDropOff = ((Quest)this).AddEntry("Collect your share from the Don", (Vector3?)null);
			Instance = this;
			NDLog.Debug("CaricoQuest constructed.");
		}

		public void Apply(string itemDisplayName, string itemId, int quantity, string aName, Vector3 aPos, string bName, Vector3 bPos, int reward)
		{
			//IL_004c: 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_00a0: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			_titleText = LoreStrings.CaricoTitle(itemDisplayName);
			_descriptionText = LoreStrings.CaricoDescription(itemDisplayName, itemId, quantity, aName, bName, reward);
			try
			{
				if (EntryPickup != null)
				{
					EntryPickup.Title = LoreStrings.CaricoEntryPickup(itemDisplayName, itemId, quantity, aName);
					EntryPickup.POIPosition = aPos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.deaddrop_quest.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(EntryPickup, val);
					}
				}
				if (EntryDeliver != null)
				{
					EntryDeliver.Title = LoreStrings.CaricoEntryDeliver(itemDisplayName, itemId, quantity, bName);
					_bPos = bPos;
					EntryDeliver.POIPosition = bPos;
					Sprite val2 = AssetLoader.LoadSprite("Ndrangheta.assets.deaddrop_quest.png");
					if ((Object)(object)val2 != (Object)null)
					{
						PoiIconHelper.ApplyAsync(EntryDeliver, val2);
					}
				}
				if (EntryDropOff != null)
				{
					EntryDropOff.Title = (TerritoryHandover.HandoverActive ? "Report to the cassa at the Gazebo for your share" : "Collect your share from Don Salvatore at the Gazebo");
					Vector3 val3 = ResolveDonWorldPos();
					if (val3 != Vector3.zero)
					{
						_donPos = val3;
						EntryDropOff.POIPosition = val3;
						Sprite val4 = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
						if ((Object)(object)val4 != (Object)null)
						{
							PoiIconHelper.ApplyAsync(EntryDropOff, val4);
						}
					}
					else
					{
						try
						{
							EntryDropOff.ClearPOI();
						}
						catch
						{
						}
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("CaricoQuest.Apply: " + ex.Message);
			}
			EnsureFirstEntryActive();
		}

		private static Vector3 ResolveDonWorldPos()
		{
			//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_0069: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			try
			{
				if (TerritoryHandover.HandoverActive)
				{
					if (DonSalvatoreNPC.ResolveGazeboPosition(out var pos))
					{
						return pos;
					}
					return Vector3.zero;
				}
				NPC cachedGameNpc = DonSalvatoreNPC.CachedGameNpc;
				if ((Object)(object)cachedGameNpc != (Object)null && (Object)(object)((Component)cachedGameNpc).transform != (Object)null)
				{
					return ((Component)cachedGameNpc).transform.position;
				}
			}
			catch
			{
			}
			return Vector3.zero;
		}

		public static void EnsureCreated()
		{
			try
			{
				if (Instance == null && QuestManager.GetQuestByName("Carico") == null)
				{
					CurrentJobGuid = $"Ndrangheta.carico.{DateTime.UtcNow.Ticks}";
					QuestManager.CreateQuest<CaricoQuest>(CurrentJobGuid);
					NDLog.Debug("CaricoQuest created.");
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("CaricoQuest.EnsureCreated: " + ex.Message);
			}
		}

		public static void CompletePickup()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryPickup != null && (int)instance.EntryPickup.State != 2)
				{
					instance.EntryPickup.Complete();
				}
				if (instance?.EntryDeliver != null && (int)instance.EntryDeliver.State == 0)
				{
					instance.EntryDeliver.Begin();
				}
				ReapplyDeliverIcon();
			}
			catch (Exception ex)
			{
				NDLog.Warn(ex.Message);
			}
		}

		public static void CompleteDeliver()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDeliver != null && (int)instance.EntryDeliver.State != 2)
				{
					instance.EntryDeliver.Complete();
				}
				if (instance?.EntryDropOff != null && (int)instance.EntryDropOff.State == 0)
				{
					instance.EntryDropOff.Begin();
				}
				ReapplyDropOffIcon();
			}
			catch (Exception ex)
			{
				NDLog.Warn(ex.Message);
			}
		}

		public static void CompleteDropOff()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDropOff != null && (int)instance.EntryDropOff.State != 2)
				{
					instance.EntryDropOff.Complete();
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn(ex.Message);
			}
		}

		public static void EnsureFirstEntryActive()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryPickup != null && (int)instance.EntryPickup.State == 0)
				{
					instance.EntryPickup.Begin();
				}
			}
			catch
			{
			}
		}

		private static void ReapplyDeliverIcon()
		{
			//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_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDeliver != null)
				{
					if (instance._bPos != Vector3.zero)
					{
						instance.EntryDeliver.POIPosition = instance._bPos;
					}
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.deaddrop_quest.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(instance.EntryDeliver, val);
					}
				}
			}
			catch
			{
			}
		}

		private static void ReapplyDropOffIcon()
		{
			//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_0023: 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_003b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CaricoQuest instance = Instance;
				if (instance?.EntryDropOff != null)
				{
					Vector3 val = ResolveDonWorldPos();
					if (val == Vector3.zero)
					{
						val = instance._donPos;
					}
					if (val != Vector3.zero)
					{
						instance.EntryDropOff.POIPosition = val;
					}
					Sprite val2 = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val2 != (Object)null)
					{
						PoiIconHelper.ApplyAsync(instance.EntryDropOff, val2);
					}
				}
			}
			catch
			{
			}
		}

		public static void ClearInstanceForNext()
		{
			Instance = null;
		}
	}
	[QuestName("Il Circolo")]
	internal sealed class CircoloQuestId : IQuestIdentifier
	{
	}
	internal sealed class CircoloQuest : Quest
	{
		public const string QuestGuid = "Ndrangheta.circolo.marker";

		private static string _pendingText = "Il Circolo";

		internal static CircoloQuest Instance { get; private set; }

		protected override string Title => "Il Circolo";

		protected override string Description => "The famiglia's own front. The men hold the door.";

		protected override bool AutoBegin => true;

		protected override Sprite QuestIcon => AssetLoader.LoadSprite("Ndrangheta.assets.don_quest.png");

		public QuestEntry EntryMain { get; private set; }

		public CircoloQuest()
		{
			EntryMain = ((Quest)this).AddEntry(_pendingText, (Vector3?)null);
			Instance = this;
			Quest val = TryGetVanillaQuest();
			if ((Object)(object)val != (Object)null)
			{
				try
				{
					val.TrackOnBegin = false;
				}
				catch
				{
				}
			}
			NDLog.Debug("[CIRCOLO] marker quest created.");
		}

		internal static void EnsureCreated(string text, Vector3 pos)
		{
			//IL_0016: 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)
			try
			{
				if (Instance != null)
				{
					SetText(text);
					MoveTo(pos);
					Instance.SuppressJournalAndHud();
					return;
				}
				_pendingText = text ?? "Il Circolo";
				QuestManager.CreateQuest<CircoloQuest>("Ndrangheta.circolo.marker");
				if (Instance == null)
				{
					return;
				}
				SetText(text);
				if (((Vector3)(ref pos)).sqrMagnitude > 1f)
				{
					Instance.EntryMain.POIPosition = pos;
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.don_icon.png");
					if ((Object)(object)val != (Object)null)
					{
						PoiIconHelper.ApplyAsync(Instance.EntryMain, val);
					}
				}
				Instance.SuppressJournalAndHud();
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("CircoloQuest.EnsureCreated: " + ex.Message);
			}
		}

		internal static void SetText(string text)
		{
			try
			{
				if (Instance?.EntryMain != null && !string.IsNullOrEmpty(text))
				{
					Instance.EntryMain.Title = text;
				}
			}
			catch
			{
			}
		}

		internal static void MoveTo(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Instance?.EntryMain != null && !(((Vector3)(ref pos)).sqrMagnitude < 1f))
				{
					PoiIconHelper.MovePoi(Instance.EntryMain, pos);
				}
			}
			catch
			{
			}
		}

		public static void SuppressHud()
		{
			try
			{
				Instance?.SuppressJournalAndHud();
			}
			catch
			{
			}
		}

		private void SuppressJournalAndHud()
		{
			try
			{
				Quest val = TryGetVanillaQuest();
				if ((Object)(object)val 

TheMob.Connector.MONO.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using FishNet;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Object;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Ndrangheta.Compat;
using Ndrangheta.Framework;
using Ndrangheta.Helper;
using S1API.Input;
using S1API.Internal.Abstraction;
using S1API.PhoneApp;
using S1API.Saveables;
using S1API.UI;
using S1API.Utils;
using ScheduleOne;
using ScheduleOne.Building;
using ScheduleOne.DevUtilities;
using ScheduleOne.EntityFramework;
using ScheduleOne.Interaction;
using ScheduleOne.ItemFramework;
using ScheduleOne.Map;
using ScheduleOne.Money;
using ScheduleOne.Networking;
using ScheduleOne.Persistence;
using ScheduleOne.Persistence.Datas;
using ScheduleOne.Persistence.Loaders;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Property;
using ScheduleOne.Quests;
using ScheduleOne.Storage;
using ScheduleOne.Tiles;
using ScheduleOne.Tools;
using ScheduleOne.UI;
using ScheduleOne.UI.Compass;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: MelonInfo(typeof(TheMobFrameworkMod), "TheMob Connector", "1.0.7", "Virtunerd", null)]
[assembly: MelonGame(null, "Schedule I")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: AssemblyInformationalVersion("1.0.7")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.7.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 Ndrangheta.UI
{
	public class FamigliaApp : PhoneApp
	{
		private static readonly Color MainBg = new Color(0.03f, 0.07f, 0.14f);

		private static readonly Color TopBarBg = new Color(0.05f, 0.1f, 0.19f);

		private static readonly Color NavBg = new Color(0.06f, 0.13f, 0.24f);

		private static readonly Color ContentBg = new Color(0.04f, 0.09f, 0.17f);

		private static readonly Color CardBg = new Color(0.02f, 0.05f, 0.1f);

		private static readonly Color SellBtn = new Color(0.42f, 0.12f, 0.12f);

		private static readonly Color LockedBg = new Color(0.05f, 0.1f, 0.18f);

		private static readonly Color LockedTxt = new Color(0.4f, 0.4f, 0.4f);

		private static readonly Color ErrorTxt = new Color(1f, 0.4f, 0.4f);

		private static readonly Color LoadPctColor = new Color(0.8f, 0.85f, 0.95f);

		private Color _accent = new Color(0.1f, 0.22f, 0.4f);

		private Color _gold = new Color(0.83f, 0.69f, 0.22f);

		private const int MinSelectSlots = 4;

		private const float APP_TOP = 0.89f;

		private const float APP_BOTTOM = 0.03f;

		private GameObject _selectPanel;

		private GameObject _loadingPanel;

		private GameObject _mainRoot;

		private RectTransform _loadFill;

		private Image _loadFillImg;

		private Text _loadPctText;

		private Text _loadFamilyText;

		private bool _loading;

		private Text _loadErrorText;

		private GameObject _loadBackBtn;

		private GameObject _homePage;

		private GameObject _realEstatePage;

		private GameObject _listaPage;

		private GameObject _cassaPage;

		private GameObject _furnishPage;

		private GameObject[] _pages;

		private RectTransform _reContent;

		private Text _statusText;

		private Text _homeTitleText;

		private Text _homeText;

		private Text _hqLabel;

		private Text _homeStatus;

		private Text _moralLadderText;

		private RectTransform _hqContent;

		private RectTransform _incomeHost;

		private GameObject _shopPage;

		private RectTransform _shopList;

		private Text _shopStatus;

		private GameObject _operationsPage;

		private RectTransform _operationsList;

		private Text _operationsStatus;

		private readonly List<object> _gifCoroutines = new List<object>();

		private Text _moralTitleText;

		private GameObject _faidaPage;

		private RectTransform _faidaList;

		private Text _faidaIntro;

		private Text _faidaTitleText;

		private Text _faidaNavText;

		private RectTransform _furnishContent;

		private GameObject _furnishTabsHost;

		private Text _furnishTitle;

		private int _furnishSurface;

		private IMobFurnishTarget _furnishTarget;

		private GameObject _furnishChooser;

		private GameObject _furnishEditor;

		private GameObject _furnishChooseHost;

		private GameObject _furnishReturnPage;

		internal static FamigliaApp Instance { get; private set; }

		private static MobFamily Active => MobFamilyRegistry.Active;

		protected override string AppName => "FamigliaApp";

		protected override string AppTitle => "TheMob";

		protected override string IconLabel => "TheMob";

		protected override string IconFileName => string.Empty;

		protected override void OnCreated()
		{
			((PhoneApp)this).OnCreated();
			Instance = this;
		}

		protected override void OnDestroyed()
		{
			Instance = null;
			((PhoneApp)this).OnDestroyed();
		}

		protected override void OnCreatedUI(GameObject container)
		{
			try
			{
				try
				{
					Sprite val = AssetLoader.LoadSprite("Ndrangheta.assets.appicon.png");
					if ((Object)(object)val != (Object)null)
					{
						((PhoneApp)this).SetIconSprite(val);
					}
				}
				catch (Exception ex)
				{
					NDLog.DebugWarn("[APP] icon: " + ex.Message);
				}
				BuildSelectPanel(container.transform);
				BuildLoadingPanel(container.transform);
				ShowSelect();
				NDLog.Debug($"[APP] TheMob app UI built (families={MobFamilyRegistry.All.Count}, intro flow active).");
			}
			catch (Exception ex2)
			{
				NDLog.Warn("[APP] OnCreatedUI: " + ex2.Message);
			}
		}

		protected override void OnPhoneClosed()
		{
			try
			{
				NDLog.Debug("[APP] OnPhoneClosed -> DestroyMain + ShowSelect.");
				_loading = false;
				DestroyMain();
				ShowSelect();
				Controls.IsTyping = false;
				try
				{
					EventSystem current = EventSystem.current;
					if (current != null)
					{
						current.SetSelectedGameObject((GameObject)null);
					}
				}
				catch
				{
				}
			}
			catch
			{
			}
			((PhoneApp)this).OnPhoneClosed();
		}

		private void BuildSelectPanel(Transform container)
		{
			//IL_0008: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0183: 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_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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)
			_selectPanel = MakePanel("SelectPanel", container, MainBg, null, null, fullAnchor: true);
			Text val = UIFactory.Text("SelTitle", "SELECT YOUR MOB", _selectPanel.transform, 24, (TextAnchor)1, (FontStyle)3);
			((Graphic)val).color = _gold;
			Rect(((Graphic)val).rectTransform, new Vector2(0.05f, 0.8f), new Vector2(0.95f, 0.95f));
			Text val2 = UIFactory.Text("SelSub", "Choose the family you run. Omerta above all.", _selectPanel.transform, 13, (TextAnchor)1, (FontStyle)2);
			((Graphic)val2).color = new Color(0.7f, 0.75f, 0.85f);
			Rect(((Graphic)val2).rectTransform, new Vector2(0.05f, 0.72f), new Vector2(0.95f, 0.8f));
			GameObject val3 = UIFactory.Panel("SelList", _selectPanel.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.2f, 0.1f), (Vector2?)new Vector2(0.8f, 0.7f), false);
			UIFactory.VerticalLayoutOnGO(val3, 10, new RectOffset(8, 8, 8, 8));
			IReadOnlyList<MobFamily> all = MobFamilyRegistry.All;
			if (all.Count == 0)
			{
				Text val4 = UIFactory.Text("SelNone", "TheMob Connector loaded, but no clans found.\n\nInstall a clan mod (e.g. Ndrangheta) to play.", val3.transform, 15, (TextAnchor)1, (FontStyle)2);
				((Graphic)val4).color = LockedTxt;
				LayoutElement val5 = ((Component)val4).gameObject.AddComponent<LayoutElement>();
				val5.minHeight = 140f;
				val5.preferredHeight = 140f;
				val5.flexibleWidth = 1f;
				return;
			}
			int num = Mathf.Max(4, all.Count);
			for (int i = 0; i < num; i++)
			{
				MobFamily mobFamily = ((i < all.Count) ? all[i] : null);
				bool flag = mobFamily?.Available ?? false;
				string text = ((mobFamily != null) ? mobFamily.DisplayName : "Coming Soon");
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel($"Fam_{i}", text, val3.transform, flag ? _accent : LockedBg, 0f, 44f, 16, flag ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement val6 = item.GetComponent<LayoutElement>();
				if ((Object)(object)val6 == (Object)null)
				{
					val6 = item.AddComponent<LayoutElement>();
				}
				val6.minHeight = 44f;
				val6.preferredHeight = 44f;
				val6.flexibleWidth = 1f;
				if (flag)
				{
					MobFamily picked = mobFamily;
					ButtonUtils.AddListener(item2, (Action)delegate
					{
						OnFamilyChosen(picked);
					});
				}
				else
				{
					try
					{
						((Selectable)item2).interactable = false;
					}
					catch
					{
					}
				}
			}
		}

		private void BuildLoadingPanel(Transform container)
		{
			//IL_0008: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: 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_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			_loadingPanel = MakePanel("LoadingPanel", container, MainBg, null, null, fullAnchor: true);
			_loadingPanel.SetActive(false);
			Text val = UIFactory.Text("LoadBrand", "THE MOB", _loadingPanel.transform, 30, (TextAnchor)7, (FontStyle)3);
			((Graphic)val).color = _gold;
			Rect(((Graphic)val).rectTransform, new Vector2(0.1f, 0.6f), new Vector2(0.9f, 0.74f));
			_loadFamilyText = UIFactory.Text("LoadFamily", "", _loadingPanel.transform, 15, (TextAnchor)1, (FontStyle)2);
			((Graphic)_loadFamilyText).color = Color.white;
			Rect(((Graphic)_loadFamilyText).rectTransform, new Vector2(0.1f, 0.52f), new Vector2(0.9f, 0.6f));
			GameObject val2 = UIFactory.Panel("LoadTrack", _loadingPanel.transform, new Color(0.02f, 0.05f, 0.1f), (Vector2?)new Vector2(0.2f, 0.4f), (Vector2?)new Vector2(0.8f, 0.46f), false);
			GameObject val3 = UIFactory.Panel("LoadFill", val2.transform, _gold, (Vector2?)new Vector2(0f, 0f), (Vector2?)new Vector2(0f, 1f), false);
			_loadFill = val3.GetComponent<RectTransform>();
			_loadFillImg = val3.GetComponent<Image>();
			_loadPctText = UIFactory.Text("LoadPct", "LOADING  0%", _loadingPanel.transform, 14, (TextAnchor)1, (FontStyle)0);
			((Graphic)_loadPctText).color = LoadPctColor;
			Rect(((Graphic)_loadPctText).rectTransform, new Vector2(0.1f, 0.31f), new Vector2(0.9f, 0.39f));
			_loadErrorText = UIFactory.Text("LoadError", "", _loadingPanel.transform, 13, (TextAnchor)1, (FontStyle)2);
			((Graphic)_loadErrorText).color = ErrorTxt;
			Rect(((Graphic)_loadErrorText).rectTransform, new Vector2(0.12f, 0.13f), new Vector2(0.88f, 0.29f));
			((Component)_loadErrorText).gameObject.SetActive(false);
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("LoadBack", "< BACK", _loadingPanel.transform, _accent, 0f, 32f, 13, Color.white);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			_loadBackBtn = item;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.35f, 0.04f);
				component.anchorMax = new Vector2(0.65f, 0.11f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			ButtonUtils.AddListener(item2, (Action)BackToSelectFromLoad);
			_loadBackBtn.SetActive(false);
		}

		private void ShowSelect()
		{
			try
			{
				if ((Object)(object)_loadingPanel != (Object)null)
				{
					_loadingPanel.SetActive(false);
				}
				if ((Object)(object)_selectPanel != (Object)null)
				{
					_selectPanel.SetActive(true);
				}
			}
			catch
			{
			}
		}

		private void OnFamilyChosen(MobFamily family)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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)
			try
			{
				MobFamilyRegistry.SetActive(family);
				if ((Object)(object)_selectPanel != (Object)null)
				{
					_selectPanel.SetActive(false);
				}
				if ((Object)(object)_loadingPanel != (Object)null)
				{
					_loadingPanel.SetActive(true);
				}
				if ((Object)(object)_loadFamilyText != (Object)null)
				{
					_loadFamilyText.text = ((family != null) ? ("Connecting to " + family.DisplayName + "...") : "");
				}
				if ((Object)(object)_loadFill != (Object)null)
				{
					_loadFill.anchorMin = new Vector2(0f, 0f);
					_loadFill.anchorMax = new Vector2(0f, 1f);
					_loadFill.offsetMin = Vector2.zero;
					_loadFill.offsetMax = Vector2.zero;
				}
				if ((Object)(object)_loadFillImg != (Object)null)
				{
					((Graphic)_loadFillImg).color = _gold;
				}
				if ((Object)(object)_loadPctText != (Object)null)
				{
					_loadPctText.text = "LOADING  0%";
					((Graphic)_loadPctText).color = LoadPctColor;
				}
				if ((Object)(object)_loadErrorText != (Object)null)
				{
					((Component)_loadErrorText).gameObject.SetActive(false);
				}
				if ((Object)(object)_loadBackBtn != (Object)null)
				{
					_loadBackBtn.SetActive(false);
				}
				_loading = true;
				MelonCoroutines.Start(LoadingRoutine());
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] OnFamilyChosen: " + ex.Message);
				RevealMain();
			}
		}

		private IEnumerator LoadingRoutine()
		{
			bool unlocked;
			try
			{
				unlocked = Active?.AppUnlocked ?? true;
			}
			catch
			{
				unlocked = true;
			}
			if (unlocked)
			{
				yield return null;
				try
				{
					if (Active != null)
					{
						_ = Active.Operations;
					}
				}
				catch (Exception ex)
				{
					Exception px = ex;
					NDLog.DebugWarn("[APP] GIF preload: " + px.Message);
				}
				float t = 0f;
				while (t < 2.2f)
				{
					if (!_loading || Instance != this)
					{
						yield break;
					}
					t += Time.deltaTime;
					float frac = Mathf.Clamp01(t / 2.2f);
					try
					{
						if ((Object)(object)_loadFill != (Object)null)
						{
							_loadFill.anchorMax = new Vector2(frac, 1f);
						}
						if ((Object)(object)_loadPctText != (Object)null)
						{
							_loadPctText.text = $"LOADING  {Mathf.RoundToInt(frac * 100f)}%";
						}
					}
					catch
					{
					}
					yield return null;
				}
				RevealMain();
				yield break;
			}
			float et = 0f;
			bool hung = false;
			while (et < 1.6f)
			{
				if (!_loading || Instance != this)
				{
					yield break;
				}
				et += Time.deltaTime;
				float frac2 = Mathf.Clamp01(et / 1.6f) * 0.7f;
				try
				{
					if ((Object)(object)_loadFill != (Object)null)
					{
						_loadFill.anchorMax = new Vector2(frac2, 1f);
					}
					if ((Object)(object)_loadPctText != (Object)null)
					{
						_loadPctText.text = $"CONNECTING  {Mathf.RoundToInt(frac2 * 100f)}%";
					}
				}
				catch
				{
				}
				yield return null;
				if (!hung && et >= 0.88000005f)
				{
					hung = true;
					if (!_loading || Instance != this)
					{
						yield break;
					}
					yield return (object)new WaitForSeconds(0.45f);
				}
			}
			ShowLoadError();
		}

		private void ShowLoadError()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_loading = false;
				MobFamily active = Active;
				string text = ((active != null) ? (active.AppLockedTitle ?? "ACCESS DENIED") : "ACCESS DENIED");
				string text2 = ((active != null) ? (active.AppLockedText ?? "") : "");
				if ((Object)(object)_loadFillImg != (Object)null)
				{
					((Graphic)_loadFillImg).color = ErrorTxt;
				}
				if ((Object)(object)_loadFill != (Object)null)
				{
					_loadFill.anchorMax = new Vector2(0.7f, 1f);
				}
				if ((Object)(object)_loadPctText != (Object)null)
				{
					_loadPctText.text = "ERROR  —  " + text;
					((Graphic)_loadPctText).color = ErrorTxt;
				}
				if ((Object)(object)_loadFamilyText != (Object)null)
				{
					_loadFamilyText.text = "CONNECTION REFUSED";
				}
				if ((Object)(object)_loadErrorText != (Object)null)
				{
					_loadErrorText.text = text2;
					((Component)_loadErrorText).gameObject.SetActive(true);
				}
				if ((Object)(object)_loadBackBtn != (Object)null)
				{
					_loadBackBtn.SetActive(true);
				}
				NDLog.Debug("[APP] loading gate -> locked (player is not boss yet).");
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ShowLoadError: " + ex.Message);
			}
		}

		private void BackToSelectFromLoad()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_loading = false;
				if ((Object)(object)_loadErrorText != (Object)null)
				{
					((Component)_loadErrorText).gameObject.SetActive(false);
				}
				if ((Object)(object)_loadBackBtn != (Object)null)
				{
					_loadBackBtn.SetActive(false);
				}
				if ((Object)(object)_loadFillImg != (Object)null)
				{
					((Graphic)_loadFillImg).color = _gold;
				}
				if ((Object)(object)_loadPctText != (Object)null)
				{
					((Graphic)_loadPctText).color = LoadPctColor;
				}
				ShowSelect();
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] BackToSelectFromLoad: " + ex.Message);
			}
		}

		private void RevealMain()
		{
			try
			{
				bool flag = true;
				try
				{
					flag = Active?.AppUnlocked ?? true;
				}
				catch
				{
					flag = true;
				}
				if (!flag)
				{
					ShowLoadError();
					return;
				}
				_loading = false;
				if ((Object)(object)_loadingPanel != (Object)null)
				{
					_loadingPanel.SetActive(false);
				}
				if ((Object)(object)_selectPanel != (Object)null)
				{
					_selectPanel.SetActive(false);
				}
				BuildMain(Active);
				if ((Object)(object)_mainRoot != (Object)null)
				{
					_mainRoot.SetActive(true);
				}
				SetActivePage(_homePage, refreshHome: true);
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] RevealMain: " + ex.Message);
			}
		}

		private void DestroyMain()
		{
			try
			{
				if ((Object)(object)_mainRoot != (Object)null)
				{
					Object.Destroy((Object)(object)_mainRoot);
				}
			}
			catch
			{
			}
			_mainRoot = null;
			_homePage = (_realEstatePage = (_listaPage = (_cassaPage = (_furnishPage = null))));
			_pages = null;
			_reContent = null;
			_statusText = null;
			_homeTitleText = null;
			_homeText = null;
			_hqLabel = null;
			_homeStatus = null;
			_hqContent = null;
			_incomeHost = null;
			_shopPage = null;
			_shopList = null;
			_shopStatus = null;
			StopGifs();
			_operationsPage = null;
			_operationsList = null;
			_operationsStatus = null;
			_furnishContent = null;
			_furnishTabsHost = null;
			_furnishTitle = null;
			_furnishChooser = (_furnishEditor = (_furnishChooseHost = null));
			_furnishTarget = null;
			_furnishReturnPage = null;
			_moralTitleText = null;
			_moralLadderText = null;
			_faidaPage = null;
			_faidaList = null;
			_faidaIntro = null;
			_faidaTitleText = null;
			_faidaNavText = null;
		}

		private void BuildMain(MobFamily fam)
		{
			//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_002c: 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_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: 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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: 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_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			DestroyMain();
			NDLog.Debug("[APP] BuildMain — Haupt-UI (neu) gebaut.");
			if (fam != null)
			{
				_accent = fam.Accent;
				_gold = fam.Highlight;
			}
			Transform val = (((Object)(object)_selectPanel != (Object)null) ? _selectPanel.transform.parent : (((Object)(object)_loadingPanel != (Object)null) ? _loadingPanel.transform.parent : null));
			if ((Object)(object)val == (Object)null)
			{
				NDLog.Warn("[APP] BuildMain: no container.");
				return;
			}
			GameObject val2 = (_mainRoot = UIFactory.Panel("FamigliaMainBG", val, MainBg, (Vector2?)new Vector2(0f, 0.03f), (Vector2?)new Vector2(1f, 0.89f), false));
			GameObject val3 = MakePanel("TopBar", val2.transform, TopBarBg, (Vector2?)new Vector2(0.039f, 0.934f), (Vector2?)new Vector2(0.962f, 1.036f), fullAnchor: false);
			string text = ((fam != null) ? fam.BrandTitle : "THE MOB");
			Text val4 = UIFactory.Text("Brand", text, val3.transform, 21, (TextAnchor)6, (FontStyle)3);
			((Graphic)val4).color = _gold;
			Rect(((Graphic)val4).rectTransform, new Vector2(0.02f, 0.35f), new Vector2(0.4f, 0.99f));
			string text2 = ((fam != null) ? fam.BrandSubtitle : "");
			Text val5 = UIFactory.Text("BrandSub", text2 ?? "", val3.transform, 12, (TextAnchor)0, (FontStyle)2);
			((Graphic)val5).color = new Color(0.6f, 0.65f, 0.75f);
			Rect(((Graphic)val5).rectTransform, new Vector2(0.02f, 0.03f), new Vector2(0.4f, 0.35f));
			_moralTitleText = UIFactory.Text("MoralTitle", (fam != null) ? (fam.MoralTitle ?? "") : "", val3.transform, 17, (TextAnchor)4, (FontStyle)3);
			((Graphic)_moralTitleText).color = _gold;
			_moralTitleText.horizontalOverflow = (HorizontalWrapMode)1;
			_moralTitleText.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_moralTitleText).rectTransform, new Vector2(0.4f, 0.05f), new Vector2(0.66f, 1.01f));
			Text val6 = UIFactory.Text("LoginAs", "LOGGED IN AS:  BOSS", val3.transform, 12, (TextAnchor)5, (FontStyle)1);
			((Graphic)val6).color = _gold;
			Rect(((Graphic)val6).rectTransform, new Vector2(0.66f, 0.01f), new Vector2(0.975f, 1.01f));
			GameObject val7 = MakePanel("NavPanel", val2.transform, NavBg, (Vector2?)new Vector2(0.041f, 0.028f), (Vector2?)new Vector2(0.248f, 0.932f), fullAnchor: false);
			GameObject val8 = MakePanel("NavPhoto", val7.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.005f, 0.508f), (Vector2?)new Vector2(0.715f, 1.036f), fullAnchor: false);
			try
			{
				Sprite val9 = null;
				try
				{
					val9 = Active?.HomeImage;
				}
				catch
				{
				}
				if ((Object)(object)val9 == (Object)null)
				{
					val9 = AssetLoader.LoadSprite("Ndrangheta.assets.icon_hometab.png");
				}
				if ((Object)(object)val9 != (Object)null)
				{
					GameObject val10 = new GameObject("NavPhotoImg");
					val10.transform.SetParent(val8.transform, false);
					Image val11 = val10.AddComponent<Image>();
					val11.sprite = val9;
					val11.preserveAspect = true;
					((Graphic)val11).raycastTarget = false;
					RectTransform component = val10.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.017f, 0.024f), new Vector2(1.3f, 1.3f));
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] NavPhoto: " + ex.Message);
			}
			GameObject val12 = MakePanel("NavTabsHost", val7.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.016f, 0.064f), (Vector2?)new Vector2(0.925f, 0.725f), fullAnchor: false);
			ScrollRect val14 = default(ScrollRect);
			RectTransform val13 = UIFactory.ScrollableVerticalList("NavList", val12.transform, ref val14);
			try
			{
				if ((Object)(object)val14 != (Object)null)
				{
					val14.horizontal = false;
					val14.vertical = true;
					val14.scrollSensitivity = 18f;
				}
				VerticalLayoutGroup component2 = ((Component)val13).GetComponent<VerticalLayoutGroup>();
				if ((Object)(object)component2 != (Object)null)
				{
					((HorizontalOrVerticalLayoutGroup)component2).spacing = 8f;
					((LayoutGroup)component2).padding = new RectOffset(8, 8, 12, 10);
					((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false;
					((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
					((LayoutGroup)component2).childAlignment = (TextAnchor)1;
				}
			}
			catch
			{
			}
			UIFactory.FitContentHeight(val13);
			HardenScrollClip(val14);
			GameObject val15 = MakePanel("ContentArea", val2.transform, ContentBg, (Vector2?)new Vector2(0.245f, 0.055f), (Vector2?)new Vector2(0.959f, 0.934f), fullAnchor: false);
			_homePage = BuildHomePage(val15.transform);
			_realEstatePage = BuildRealEstatePage(val15.transform);
			_listaPage = null;
			_cassaPage = null;
			_furnishPage = BuildFurnishPage(val15.transform);
			_shopPage = BuildShopPage(val15.transform);
			_faidaPage = BuildFaidaPage(val15.transform);
			_operationsPage = BuildOperationsPage(val15.transform);
			_pages = (GameObject[])(object)new GameObject[6] { _homePage, _realEstatePage, _furnishPage, _shopPage, _faidaPage, _operationsPage };
			AddNavButton((Transform)(object)val13, "Home", locked: false, delegate
			{
				SetActivePage(_homePage, refreshHome: true);
			});
			AddNavButton((Transform)(object)val13, "Real Estate", locked: false, delegate
			{
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
			});
			AddNavButton((Transform)(object)val13, "Little Helper", locked: false, delegate
			{
				SetActivePage(_shopPage);
				RefreshShop();
			});
			_faidaNavText = AddNavButton((Transform)(object)val13, "Faida", locked: false, delegate
			{
				SetActivePage(_faidaPage);
				RefreshFaida();
			});
			AddNavButton((Transform)(object)val13, "Operations", locked: false, delegate
			{
				SetActivePage(_operationsPage);
				RefreshOperations();
			});
			SetActivePage(_homePage, refreshHome: true);
			DisableContainerRaycasts(_mainRoot);
		}

		private GameObject BuildHomePage(Transform parent)
		{
			//IL_001b: 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_0081: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("HomePage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			_homeTitleText = UIFactory.Text("HomeTitle", "", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)_homeTitleText).color = _gold;
			Rect(((Graphic)_homeTitleText).rectTransform, new Vector2(0.045f, 0.875f), new Vector2(0.959f, 0.965f));
			_moralLadderText = UIFactory.Text("HomeMoralLadder", "", val.transform, 11, (TextAnchor)2, (FontStyle)0);
			((Graphic)_moralLadderText).color = Color.white;
			_moralLadderText.horizontalOverflow = (HorizontalWrapMode)0;
			_moralLadderText.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_moralLadderText).rectTransform, new Vector2(0.49f, 0.7f), new Vector2(0.965f, 0.965f));
			_homeText = UIFactory.Text("HomeBody", "", val.transform, 14, (TextAnchor)0, (FontStyle)0);
			((Graphic)_homeText).color = Color.white;
			Rect(((Graphic)_homeText).rectTransform, new Vector2(0.046f, 0.639f), new Vector2(0.474f, 0.904f));
			_hqLabel = UIFactory.Text("HomeHqLabel", "", val.transform, 14, (TextAnchor)6, (FontStyle)1);
			((Graphic)_hqLabel).color = _gold;
			Rect(((Graphic)_hqLabel).rectTransform, new Vector2(0.719f, 0.65f), new Vector2(1.115f, 0.71f));
			_homeStatus = UIFactory.Text("HomeStatus", "", val.transform, 12, (TextAnchor)6, (FontStyle)2);
			((Graphic)_homeStatus).color = _gold;
			_homeStatus.horizontalOverflow = (HorizontalWrapMode)0;
			_homeStatus.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_homeStatus).rectTransform, new Vector2(0.715f, 0.72f), new Vector2(0.98f, 0.865f));
			GameObject val2 = MakePanel("HomeHqHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.715f, 0.005f), (Vector2?)new Vector2(0.98f, 0.636f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_hqContent = UIFactory.ScrollableVerticalList("HomeHqList", val2.transform, ref sr);
			UIFactory.FitContentHeight(_hqContent);
			HardenScrollClip(sr);
			Text val3 = UIFactory.Text("HomeIncomeLabel", "INCOME", val.transform, 14, (TextAnchor)6, (FontStyle)1);
			((Graphic)val3).color = _gold;
			Rect(((Graphic)val3).rectTransform, new Vector2(0.053f, 0.487f), new Vector2(0.164f, 0.628f));
			GameObject val4 = MakePanel("HomeIncomeHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.047f, 0.361f), (Vector2?)new Vector2(0.322f, 0.478f), fullAnchor: false);
			_incomeHost = val4.GetComponent<RectTransform>();
			return val;
		}

		private void RefreshHome()
		{
			try
			{
				MobFamily active = Active;
				if ((Object)(object)_faidaNavText != (Object)null)
				{
					_faidaNavText.text = ((active != null) ? (active.FaidaTitle ?? "FAIDA") : "FAIDA");
				}
				if ((Object)(object)_homeTitleText != (Object)null)
				{
					_homeTitleText.text = ((active != null) ? active.HomeTitle : "");
				}
				if ((Object)(object)_moralTitleText != (Object)null)
				{
					_moralTitleText.text = ((active != null) ? (active.MoralTitle ?? "") : "");
				}
				if ((Object)(object)_moralLadderText != (Object)null)
				{
					_moralLadderText.text = ((active != null) ? (active.MoralLadder ?? "") : "");
				}
				if ((Object)(object)_homeText != (Object)null)
				{
					_homeText.text = ((active != null) ? active.GetHomeText() : "");
				}
				RefreshIncomeBars();
				BuildHeadquarter(active);
			}
			catch
			{
			}
		}

		private void RefreshIncomeBars()
		{
			//IL_0054: 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)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)_incomeHost == (Object)null))
				{
					UIFactory.ClearChildren(((Component)_incomeHost).transform);
					Color color = default(Color);
					((Color)(ref color))..ctor(0.82f, 0.86f, 0.94f);
					IncomeStatRow("TOTAL EARNED", IncomeTracker.TotalIncome, 0.67f, 1f, _gold, emphasize: true);
					IncomeStatRow("Quests", IncomeTracker.QuestIncome, 0.345f, 0.655f, color, emphasize: false);
					IncomeStatRow("Other", IncomeTracker.OtherIncome, 0f, 0.33f, color, emphasize: false);
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] RefreshIncomeBars: " + ex.Message);
			}
		}

		private void IncomeStatRow(string name, long amount, float yBot, float yTop, Color color, bool emphasize)
		{
			//IL_0025: 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_004d: 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_0096: 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)
			Text val = UIFactory.Text("IncR_" + name, name, (Transform)(object)_incomeHost, 12, (TextAnchor)3, (FontStyle)(emphasize ? 1 : 0));
			((Graphic)val).color = color;
			val.horizontalOverflow = (HorizontalWrapMode)1;
			Rect(((Graphic)val).rectTransform, new Vector2(0.02f, yBot), new Vector2(0.62f, yTop));
			Text val2 = UIFactory.Text("IncRV_" + name, CompactMoney(amount), (Transform)(object)_incomeHost, 12, (TextAnchor)5, (FontStyle)1);
			((Graphic)val2).color = color;
			val2.horizontalOverflow = (HorizontalWrapMode)1;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.4f, yBot), new Vector2(0.98f, yTop));
		}

		private static string CompactMoney(long v)
		{
			if (v >= 1000000)
			{
				return $"${(float)v / 1000000f:0.0}M";
			}
			if (v >= 1000)
			{
				return $"${(float)v / 1000f:0.0}K";
			}
			return $"${v}";
		}

		private void BuildHeadquarter(MobFamily fam)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_hqContent == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_hqContent).transform);
				IReadOnlyList<IMobAction> readOnlyList = fam?.HeadquarterActions;
				bool flag = readOnlyList != null && readOnlyList.Count > 0;
				if ((Object)(object)_hqLabel != (Object)null)
				{
					_hqLabel.text = (flag ? (fam.HeadquarterTitle ?? "HEADQUARTER") : "");
				}
				if (!flag)
				{
					return;
				}
				if (!fam.HeadquarterUnlocked)
				{
					Text val = UIFactory.Text("HqLocked", fam.HeadquarterLockedText ?? "Locked.", (Transform)(object)_hqContent, 13, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 90f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					IMobAction mobAction = readOnlyList[i];
					if (mobAction != null)
					{
						bool enabled = false;
						try
						{
							enabled = mobAction.Available;
						}
						catch
						{
						}
						string label = "";
						try
						{
							label = mobAction.Label ?? "";
						}
						catch
						{
						}
						IMobAction picked = mobAction;
						AddHqButton("Hq_" + (mobAction.Key ?? i.ToString()), label, enabled, delegate
						{
							InvokeHqAction(picked);
						});
					}
				}
				UIFactory.FitContentHeight(_hqContent);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] BuildHeadquarter: " + ex.Message);
			}
		}

		private void AddHqButton(string key, string label, bool enabled, Action onClick)
		{
			//IL_0015: 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_0030: 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)
			try
			{
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(key, label, (Transform)(object)_hqContent, enabled ? _accent : LockedBg, 0f, 40f, 14, enabled ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement val = item.GetComponent<LayoutElement>();
				if ((Object)(object)val == (Object)null)
				{
					val = item.AddComponent<LayoutElement>();
				}
				val.minHeight = 40f;
				val.preferredHeight = 40f;
				val.flexibleWidth = 1f;
				if (enabled && onClick != null)
				{
					ButtonUtils.AddListener(item2, onClick);
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] HqButton " + key + ": " + ex.Message);
			}
		}

		private void InvokeHqAction(IMobAction action)
		{
			if (action == null)
			{
				return;
			}
			try
			{
				MobAppTab mobAppTab = MobAppTab.None;
				try
				{
					mobAppTab = action.NavigateTo;
				}
				catch
				{
				}
				if (mobAppTab != MobAppTab.None)
				{
					NavigateToTab(mobAppTab);
					return;
				}
				string message;
				bool ok = action.Invoke(out message);
				RefreshHome();
				SetHomeStatus(message, ok);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] InvokeHqAction: " + ex.Message);
				SetHomeStatus("Couldn't reach the famiglia right now.", ok: false);
			}
		}

		private void SetHomeStatus(string msg, bool ok)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)_homeStatus == (Object)null))
				{
					_homeStatus.text = msg ?? "";
					((Graphic)_homeStatus).color = (ok ? _gold : ErrorTxt);
				}
			}
			catch
			{
			}
		}

		private void NavigateToTab(MobAppTab tab)
		{
			switch (tab)
			{
			case MobAppTab.RealEstate:
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
				break;
			case MobAppTab.Furnish:
				OpenFurnishFromRealEstate();
				break;
			case MobAppTab.ListaNera:
				SetActivePage(_listaPage);
				break;
			case MobAppTab.Cassa:
				SetActivePage(_cassaPage);
				break;
			case MobAppTab.Faida:
				SetActivePage(_faidaPage);
				RefreshFaida();
				break;
			default:
				SetActivePage(_homePage, refreshHome: true);
				break;
			}
		}

		private GameObject BuildRealEstatePage(Transform parent)
		{
			//IL_001b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("RealEstatePage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text("RETitle", "REAL ESTATE", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.055f, 0.885f), new Vector2(0.315f, 0.975f));
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("REFurnishBtn", "FURNISH", val.transform, _gold, 0f, 28f, 13, MainBg);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.055f, 0.877f);
				component.anchorMax = new Vector2(0.204f, 0.919f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			WireClick(item2, OpenFurnishFromRealEstate);
			_statusText = UIFactory.Text("REStatus", "", val.transform, 13, (TextAnchor)2, (FontStyle)2);
			((Graphic)_statusText).color = _gold;
			Rect(((Graphic)_statusText).rectTransform, new Vector2(0.55f, 0.9f), new Vector2(0.92f, 0.99f));
			GameObject val3 = MakePanel("REListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.05f, -0.009f), (Vector2?)new Vector2(0.984f, 0.815f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_reContent = UIFactory.ScrollableVerticalList("REList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_reContent);
			HardenScrollClip(sr);
			return val;
		}

		internal void RefreshRealEstate()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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)
			try
			{
				MobFamily active = Active;
				if ((Object)(object)_reContent == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_reContent).transform);
				if (active == null)
				{
					return;
				}
				if (!active.RealEstateUnlocked)
				{
					Text val = UIFactory.Text("RELocked", active.RealEstateLockedText, (Transform)(object)_reContent, 15, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 120f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					return;
				}
				IReadOnlyList<IMobProperty> properties = active.Properties;
				if (properties == null)
				{
					return;
				}
				for (int i = 0; i < properties.Count; i++)
				{
					if (properties[i] != null)
					{
						AddPropertyCard(properties[i]);
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshRealEstate: " + ex.Message);
			}
		}

		private void AddPropertyCard(IMobProperty p)
		{
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: 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)
			//IL_0265: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = p.Key ?? "prop";
				GameObject val = MakePanel("Card_" + text, (Transform)(object)_reContent, CardBg);
				AddLayout(val, 100f);
				Sprite val2 = null;
				try
				{
					val2 = p.Image;
				}
				catch
				{
				}
				if ((Object)(object)val2 != (Object)null)
				{
					GameObject val3 = new GameObject(text + "_Img");
					val3.transform.SetParent(val.transform, false);
					Image val4 = val3.AddComponent<Image>();
					val4.sprite = val2;
					val4.preserveAspect = true;
					((Graphic)val4).raycastTarget = false;
					RectTransform component = val3.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.04f, 0.14f), new Vector2(0.22f, 0.86f));
					}
				}
				bool flag = false;
				try
				{
					flag = p.Owned;
				}
				catch
				{
				}
				string text2 = "";
				try
				{
					text2 = p.Name ?? "";
				}
				catch
				{
				}
				string text3 = "";
				try
				{
					text3 = p.Description ?? "";
				}
				catch
				{
				}
				string text4 = "";
				try
				{
					text4 = p.StatusText ?? "";
				}
				catch
				{
				}
				Text val5 = UIFactory.Text(text + "_Name", text2, val.transform, 15, (TextAnchor)0, (FontStyle)1);
				((Graphic)val5).color = Color.white;
				val5.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val5).rectTransform, new Vector2(0.24f, 0.55f), new Vector2(0.69f, 0.93f));
				Text val6 = UIFactory.Text(text + "_Desc", text3, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val6).color = new Color(0.75f, 0.78f, 0.85f);
				val6.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val6).rectTransform, new Vector2(0.24f, 0.08f), new Vector2(0.69f, 0.5f));
				Text val7 = UIFactory.Text(text + "_Status", text4, val.transform, 15, (TextAnchor)4, (FontStyle)1);
				((Graphic)val7).color = (flag ? _gold : Color.white);
				Rect(((Graphic)val7).rectTransform, new Vector2(0.71f, 0.55f), new Vector2(0.95f, 0.93f));
				if (flag)
				{
					AddCardButton(val, text + "_Sell", "SELL", SellBtn, delegate
					{
						string message;
						bool ok = p.Sell(out message);
						SetStatus(message, ok);
						RefreshRealEstate();
					});
				}
				else
				{
					AddCardButton(val, text + "_Buy", "BUY", _accent, delegate
					{
						string message;
						bool ok = p.Buy(out message);
						SetStatus(message, ok);
						RefreshRealEstate();
					});
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] Card " + p?.Key + ": " + ex.Message);
			}
		}

		private void AddCardButton(GameObject card, string name, string label, Color color, Action onClick)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(name, label, card.transform, color, 0f, 30f, 14, Color.white);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.71f, 0.12f);
				component.anchorMax = new Vector2(0.95f, 0.46f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			if (onClick != null)
			{
				ButtonUtils.AddListener(item2, onClick);
			}
		}

		private GameObject BuildLockedPage(Transform parent, string name, string title, string body)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			GameObject val = MakePanel(name, parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text(name + "_Title", title, val.transform, 20, (TextAnchor)1, (FontStyle)1);
			((Graphic)val2).color = LockedTxt;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.05f, 0.85f), new Vector2(0.95f, 0.97f));
			Text val3 = UIFactory.Text(name + "_Body", body, val.transform, 14, (TextAnchor)1, (FontStyle)0);
			((Graphic)val3).color = LockedTxt;
			Rect(((Graphic)val3).rectTransform, new Vector2(0.05f, 0.2f), new Vector2(0.95f, 0.82f));
			return val;
		}

		private GameObject BuildShopPage(Transform parent)
		{
			//IL_001b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("ShopPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text("ShopTitle", "LITTLE HELPER", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.04f, 0.895f), new Vector2(0.545f, 0.961f));
			_shopStatus = UIFactory.Text("ShopStatus", "", val.transform, 13, (TextAnchor)2, (FontStyle)2);
			((Graphic)_shopStatus).color = _gold;
			Rect(((Graphic)_shopStatus).rectTransform, new Vector2(0.56f, 0.9f), new Vector2(0.97f, 0.99f));
			GameObject val3 = MakePanel("ShopListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.021f, 0.005f), (Vector2?)new Vector2(0.983f, 0.865f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_shopList = UIFactory.ScrollableVerticalList("ShopList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_shopList);
			HardenScrollClip(sr);
			return val;
		}

		private void RefreshShop()
		{
			//IL_006c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_shopList == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_shopList).transform);
				IReadOnlyList<MobShopItem> readOnlyList = Active?.ShopItems;
				if (readOnlyList == null || readOnlyList.Count == 0)
				{
					Text val = UIFactory.Text("ShopNone", "Nothing in stock right now.", (Transform)(object)_shopList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 60f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_shopList);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					MobShopItem mobShopItem = readOnlyList[i];
					if (mobShopItem != null)
					{
						MobShopItem picked = mobShopItem;
						AddShopCard(picked.Key ?? i.ToString(), picked.Name ?? "", picked.Description ?? "", picked.Price, () => picked.Buy != null && picked.Buy(), picked.IconFunc);
					}
				}
				UIFactory.FitContentHeight(_shopList);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshShop: " + ex.Message);
			}
		}

		private void AddShopCard(string key, string name, string desc, int price, Func<bool> give, Func<Sprite> icon)
		{
			//IL_0020: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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)
			try
			{
				GameObject val = MakePanel("Shop_" + key, (Transform)(object)_shopList, CardBg);
				AddLayout(val, 96f);
				Sprite val2 = null;
				try
				{
					val2 = icon?.Invoke();
				}
				catch
				{
				}
				float num = 0.09f;
				if ((Object)(object)val2 != (Object)null)
				{
					GameObject val3 = new GameObject(key + "_Icon");
					val3.transform.SetParent(val.transform, false);
					Image val4 = val3.AddComponent<Image>();
					val4.sprite = val2;
					val4.preserveAspect = true;
					((Graphic)val4).raycastTarget = false;
					RectTransform component = val3.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.035f, 0.12f), new Vector2(0.235f, 0.88f));
					}
					num = 0.27f;
				}
				Text val5 = UIFactory.Text(key + "_Name", name, val.transform, 15, (TextAnchor)0, (FontStyle)1);
				((Graphic)val5).color = Color.white;
				val5.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val5).rectTransform, new Vector2(num, 0.55f), new Vector2(0.64f, 0.92f));
				Text val6 = UIFactory.Text(key + "_Desc", desc, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val6).color = new Color(0.75f, 0.78f, 0.85f);
				val6.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val6).rectTransform, new Vector2(num, 0.08f), new Vector2(0.64f, 0.52f));
				Text val7 = UIFactory.Text(key + "_Price", $"${price:N0}", val.transform, 16, (TextAnchor)4, (FontStyle)1);
				((Graphic)val7).color = _gold;
				Rect(((Graphic)val7).rectTransform, new Vector2(0.66f, 0.55f), new Vector2(0.95f, 0.92f));
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(key + "_Buy", "BUY", val.transform, _accent, 0f, 30f, 14, Color.white);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				RectTransform component2 = item.GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = new Vector2(0.66f, 0.12f);
					component2.anchorMax = new Vector2(0.95f, 0.48f);
					component2.offsetMin = Vector2.zero;
					component2.offsetMax = Vector2.zero;
				}
				int p = price;
				Func<bool> g = give;
				string n = name;
				WireClick(item2, delegate
				{
					OnShopBuy(p, g, n);
				});
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ShopCard " + key + ": " + ex.Message);
			}
		}

		private GameObject BuildOperationsPage(Transform parent)
		{
			//IL_001b: 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)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("OperationsPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			string text = ((Active != null) ? (Active.OperationsTitle ?? "OPERATIONS") : "OPERATIONS");
			Text val2 = UIFactory.Text("OpTitle", text, val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.04f, 0.895f), new Vector2(0.545f, 0.961f));
			_operationsStatus = UIFactory.Text("OpStatus", "", val.transform, 13, (TextAnchor)2, (FontStyle)2);
			((Graphic)_operationsStatus).color = _gold;
			Rect(((Graphic)_operationsStatus).rectTransform, new Vector2(0.56f, 0.9f), new Vector2(0.97f, 0.99f));
			GameObject val3 = MakePanel("OpListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.021f, 0.005f), (Vector2?)new Vector2(0.983f, 0.865f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_operationsList = UIFactory.ScrollableVerticalList("OpList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_operationsList);
			HardenScrollClip(sr);
			return val;
		}

		private void RefreshOperations()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				StopGifs();
				if ((Object)(object)_operationsList == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_operationsList).transform);
				MobFamily active = Active;
				if (active != null && !active.OperationsUnlocked)
				{
					Text val = UIFactory.Text("OpLocked", active.OperationsLockedText, (Transform)(object)_operationsList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 60f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_operationsList);
					return;
				}
				IReadOnlyList<MobOperation> readOnlyList = active?.Operations;
				if (readOnlyList == null || readOnlyList.Count == 0)
				{
					Text val2 = UIFactory.Text("OpNone", (active != null) ? active.OperationsEmptyText : "No operations right now.", (Transform)(object)_operationsList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val2).color = LockedTxt;
					AddLayout(((Component)val2).gameObject, 60f);
					Rect(((Graphic)val2).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_operationsList);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					MobOperation mobOperation = readOnlyList[i];
					if (mobOperation != null)
					{
						AddOperationCard(mobOperation);
					}
				}
				UIFactory.FitContentHeight(_operationsList);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshOperations: " + ex.Message);
			}
		}

		private void AddOperationCard(MobOperation op)
		{
			//IL_0023: 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_0189: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: 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_0080: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = op.Key ?? "op";
				GameObject val = MakePanel("Op_" + text, (Transform)(object)_operationsList, CardBg);
				AddLayout(val, 100f);
				if (op.IconFrames != null && op.IconFrames.Length != 0)
				{
					GameObject val2 = new GameObject(text + "_Gif");
					val2.transform.SetParent(val.transform, false);
					Image val3 = val2.AddComponent<Image>();
					val3.preserveAspect = true;
					((Graphic)val3).raycastTarget = false;
					val3.sprite = op.IconFrames[0];
					RectTransform component = val2.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						Rect(component, new Vector2(0.035f, 0.12f), new Vector2(0.235f, 0.88f));
					}
					PlayGif(val3, op.IconFrames, op.IconDelays);
				}
				bool flag = false;
				try
				{
					flag = op.Available;
				}
				catch
				{
				}
				string text2 = op.QuestName ?? "";
				string text3 = op.Description ?? "";
				Text val4 = UIFactory.Text(text + "_Name", text2, val.transform, 15, (TextAnchor)0, (FontStyle)1);
				((Graphic)val4).color = Color.white;
				val4.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val4).rectTransform, new Vector2(0.27f, 0.58f), new Vector2(0.64f, 0.92f));
				Text val5 = UIFactory.Text(text + "_Desc", text3, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val5).color = new Color(0.75f, 0.78f, 0.85f);
				val5.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val5).rectTransform, new Vector2(0.27f, 0.08f), new Vector2(0.64f, 0.55f));
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(text + "_Go", text2, val.transform, flag ? _accent : LockedBg, 0f, 34f, 13, flag ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				RectTransform component2 = item.GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = new Vector2(0.66f, 0.3f);
					component2.anchorMax = new Vector2(0.96f, 0.7f);
					component2.offsetMin = Vector2.zero;
					component2.offsetMax = Vector2.zero;
				}
				if (flag)
				{
					MobOperation picked = op;
					WireClick(item2, delegate
					{
						OnOperationTrigger(picked);
					});
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] OperationCard " + op?.Key + ": " + ex.Message);
			}
		}

		private void OnOperationTrigger(MobOperation op)
		{
			//IL_00c4: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			if (op == null)
			{
				return;
			}
			try
			{
				string message;
				bool flag = op.Invoke(out message);
				if ((Object)(object)_operationsStatus != (Object)null)
				{
					_operationsStatus.text = message ?? "";
					((Graphic)_operationsStatus).color = (flag ? _gold : ErrorTxt);
				}
				if (flag && !op.LeadsToChat)
				{
					MelonCoroutines.Start(ClosePhoneNextFrame());
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] OnOperationTrigger: " + ex.Message);
				if ((Object)(object)_operationsStatus != (Object)null)
				{
					_operationsStatus.text = "Couldn't reach the famiglia right now.";
					((Graphic)_operationsStatus).color = ErrorTxt;
				}
			}
		}

		private static IEnumerator ClosePhoneNextFrame()
		{
			yield return null;
			try
			{
				GameplayMenu instance = Singleton<GameplayMenu>.Instance;
				if (instance != null)
				{
					instance.Close();
				}
			}
			catch
			{
			}
		}

		private void PlayGif(Image img, Sprite[] frames, float[] delays)
		{
			if ((Object)(object)img == (Object)null || frames == null || frames.Length == 0)
			{
				return;
			}
			if (frames.Length == 1)
			{
				img.sprite = frames[0];
				return;
			}
			try
			{
				object obj = MelonCoroutines.Start(AnimateGif(img, frames, delays));
				if (obj != null)
				{
					_gifCoroutines.Add(obj);
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] PlayGif: " + ex.Message);
			}
		}

		private static IEnumerator AnimateGif(Image img, Sprite[] frames, float[] delays)
		{
			int i = 0;
			while (!((Object)(object)img == (Object)null))
			{
				try
				{
					img.sprite = frames[i];
				}
				catch
				{
					break;
				}
				float d = ((delays != null && i < delays.Length && delays[i] > 0f) ? delays[i] : 0.1f);
				i = (i + 1) % frames.Length;
				yield return (object)new WaitForSeconds(d);
			}
		}

		private void StopGifs()
		{
			try
			{
				for (int i = 0; i < _gifCoroutines.Count; i++)
				{
					try
					{
						MelonCoroutines.Stop(_gifCoroutines[i]);
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			_gifCoroutines.Clear();
		}

		private GameObject BuildFaidaPage(Transform parent)
		{
			//IL_001b: 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_0081: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("FaidaPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			_faidaTitleText = UIFactory.Text("FaidaTitle", "FAIDA", val.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)_faidaTitleText).color = _gold;
			Rect(((Graphic)_faidaTitleText).rectTransform, new Vector2(0.04f, 0.895f), new Vector2(0.545f, 0.961f));
			_faidaIntro = UIFactory.Text("FaidaIntro", "", val.transform, 13, (TextAnchor)0, (FontStyle)0);
			((Graphic)_faidaIntro).color = Color.white;
			_faidaIntro.horizontalOverflow = (HorizontalWrapMode)0;
			_faidaIntro.verticalOverflow = (VerticalWrapMode)1;
			Rect(((Graphic)_faidaIntro).rectTransform, new Vector2(0.042f, 0.76f), new Vector2(0.965f, 0.88f));
			Text val2 = UIFactory.Text("FaidaRivalLabel", "RIVAL POINTS", val.transform, 13, (TextAnchor)6, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.042f, 0.7f), new Vector2(0.545f, 0.758f));
			GameObject val3 = MakePanel("FaidaListHost", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.021f, 0.005f), (Vector2?)new Vector2(0.983f, 0.69f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_faidaList = UIFactory.ScrollableVerticalList("FaidaList", val3.transform, ref sr);
			UIFactory.FitContentHeight(_faidaList);
			HardenScrollClip(sr);
			return val;
		}

		private void RefreshFaida()
		{
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				MobFamily active = Active;
				string text = ((active != null) ? (active.FaidaTitle ?? "FAIDA") : "FAIDA");
				if ((Object)(object)_faidaTitleText != (Object)null)
				{
					_faidaTitleText.text = text;
				}
				if ((Object)(object)_faidaNavText != (Object)null)
				{
					_faidaNavText.text = text;
				}
				if ((Object)(object)_faidaIntro != (Object)null)
				{
					_faidaIntro.text = ((active != null) ? (active.FaidaIntro ?? "") : "");
				}
				if ((Object)(object)_faidaList == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(((Component)_faidaList).transform);
				if (active != null && !active.FaidaUnlocked)
				{
					Text val = UIFactory.Text("FaidaLocked", active.FaidaLockedText ?? "Locked.", (Transform)(object)_faidaList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					val.horizontalOverflow = (HorizontalWrapMode)0;
					val.verticalOverflow = (VerticalWrapMode)1;
					AddLayout(((Component)val).gameObject, 90f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_faidaList);
					return;
				}
				try
				{
					MobOperation mobOperation = active?.FaidaAction;
					if (mobOperation != null)
					{
						AddFaidaActionCard(mobOperation);
					}
				}
				catch
				{
				}
				IReadOnlyList<MobFaidaTarget> readOnlyList = active?.FaidaTargets;
				if (readOnlyList == null || readOnlyList.Count == 0)
				{
					Text val2 = UIFactory.Text("FaidaNone", (active != null) ? (active.FaidaEmptyText ?? "No rivals yet.") : "", (Transform)(object)_faidaList, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val2).color = LockedTxt;
					val2.horizontalOverflow = (HorizontalWrapMode)0;
					val2.verticalOverflow = (VerticalWrapMode)1;
					AddLayout(((Component)val2).gameObject, 70f);
					Rect(((Graphic)val2).rectTransform, Vector2.zero, Vector2.one);
					UIFactory.FitContentHeight(_faidaList);
					return;
				}
				for (int i = 0; i < readOnlyList.Count; i++)
				{
					MobFaidaTarget mobFaidaTarget = readOnlyList[i];
					if (mobFaidaTarget != null)
					{
						AddFaidaRow(mobFaidaTarget.Name ?? $"Rival {i}", mobFaidaTarget.Points, mobFaidaTarget.Detail ?? "");
					}
				}
				UIFactory.FitContentHeight(_faidaList);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshFaida: " + ex.Message);
			}
		}

		private void AddFaidaRow(string name, int points, string detail)
		{
			//IL_0027: 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_0093: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = (name ?? "").Replace(' ', '_');
				GameObject val = MakePanel("Faida_" + text, (Transform)(object)_faidaList, CardBg);
				AddLayout(val, 64f);
				Text val2 = UIFactory.Text(text + "_Name", name, val.transform, 16, (TextAnchor)3, (FontStyle)1);
				((Graphic)val2).color = Color.white;
				val2.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val2).rectTransform, new Vector2(0.09f, 0.46f), new Vector2(0.7f, 0.94f));
				Text val3 = UIFactory.Text(text + "_Detail", detail, val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val3).color = new Color(0.75f, 0.78f, 0.85f);
				val3.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val3).rectTransform, new Vector2(0.09f, 0.08f), new Vector2(0.7f, 0.44f));
				Text val4 = UIFactory.Text(text + "_Pts", points.ToString(), val.transform, 22, (TextAnchor)5, (FontStyle)1);
				((Graphic)val4).color = _gold;
				Rect(((Graphic)val4).rectTransform, new Vector2(0.72f, 0.2f), new Vector2(0.95f, 0.8f));
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] FaidaRow " + name + ": " + ex.Message);
			}
		}

		private void AddFaidaActionCard(MobOperation op)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (op == null)
				{
					return;
				}
				bool flag = false;
				try
				{
					flag = op.Available;
				}
				catch
				{
				}
				string text = op.Key ?? "faidaaction";
				GameObject val = MakePanel("FaidaAct_" + text, (Transform)(object)_faidaList, CardBg);
				AddLayout(val, 96f);
				Text val2 = UIFactory.Text(text + "_Name", op.QuestName ?? "DECLARE WAR", val.transform, 16, (TextAnchor)0, (FontStyle)1);
				((Graphic)val2).color = _gold;
				val2.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val2).rectTransform, new Vector2(0.06f, 0.62f), new Vector2(0.7f, 0.93f));
				Text val3 = UIFactory.Text(text + "_Desc", op.Description ?? "", val.transform, 12, (TextAnchor)0, (FontStyle)0);
				((Graphic)val3).color = new Color(0.8f, 0.82f, 0.88f);
				val3.horizontalOverflow = (HorizontalWrapMode)0;
				val3.verticalOverflow = (VerticalWrapMode)0;
				Rect(((Graphic)val3).rectTransform, new Vector2(0.06f, 0.07f), new Vector2(0.7f, 0.58f));
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(text + "_Go", op.QuestName ?? "WAR", val.transform, flag ? _accent : LockedBg, 0f, 34f, 13, flag ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				RectTransform component = item.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = new Vector2(0.72f, 0.3f);
					component.anchorMax = new Vector2(0.96f, 0.7f);
					component.offsetMin = Vector2.zero;
					component.offsetMax = Vector2.zero;
				}
				if (flag)
				{
					MobOperation picked = op;
					WireClick(item2, delegate
					{
						OnOperationTrigger(picked);
					});
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] FaidaActionCard: " + ex.Message);
			}
		}

		private void OnShopBuy(int price, Func<bool> give, string name)
		{
			try
			{
				if (!MobEconomy.TryChargeLocal(price, "Little Helper: " + name, out var message))
				{
					SetShopStatus(message, ok: false);
					return;
				}
				bool flag = false;
				try
				{
					flag = give?.Invoke() ?? false;
				}
				catch
				{
					flag = false;
				}
				if (!flag)
				{
					MobEconomy.RefundLocal(price, "Little Helper refund: " + name, out var _);
					SetShopStatus("Couldn't deliver — inventory full or item unavailable.", ok: false);
				}
				else
				{
					SetShopStatus("Delivered: " + name + ".", ok: true);
				}
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] OnShopBuy: " + ex.Message);
				SetShopStatus("Shop error.", ok: false);
			}
		}

		private void SetShopStatus(string msg, bool ok)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)_shopStatus == (Object)null))
				{
					_shopStatus.text = msg ?? "";
					((Graphic)_shopStatus).color = (ok ? _gold : ErrorTxt);
				}
			}
			catch
			{
			}
		}

		private GameObject BuildFurnishPage(Transform parent)
		{
			//IL_001b: 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_00a0: 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_00ca: 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_00fc: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: 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_0268: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("FurnishPage", parent, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			_furnishChooser = MakePanel("FurnChooser", val.transform, new Color(0f, 0f, 0f, 0f), null, null, fullAnchor: true);
			Text val2 = UIFactory.Text("FurnChooseTitle", "FURNISH", _furnishChooser.transform, 20, (TextAnchor)0, (FontStyle)1);
			((Graphic)val2).color = _gold;
			Rect(((Graphic)val2).rectTransform, new Vector2(0.05f, 0.898f), new Vector2(0.482f, 0.97f));
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("FurnChooseBack", "< REAL ESTATE", _furnishChooser.transform, _accent, 0f, 26f, 12, Color.white);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			Text item3 = valueTuple.Item3;
			RectTransform component = item.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.85f, 0.92f);
				component.anchorMax = new Vector2(0.985f, 0.975f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			WireClick(item2, delegate
			{
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
			});
			Text val3 = UIFactory.Text("FurnChooseSub", "Choose what to furnish.", _furnishChooser.transform, 14, (TextAnchor)0, (FontStyle)2);
			((Graphic)val3).color = new Color(0.7f, 0.75f, 0.85f);
			Rect(((Graphic)val3).rectTransform, new Vector2(0.0531f, 0.5491f), new Vector2(0.4685f, 0.9247f));
			_furnishChooseHost = MakePanel("FurnChooseList", _furnishChooser.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.024f, 0.6f), (Vector2?)new Vector2(0.381f, 0.715f), fullAnchor: false);
			UIFactory.VerticalLayoutOnGO(_furnishChooseHost, 12, new RectOffset(8, 8, 8, 8));
			_furnishEditor = MakePanel("FurnEditor", val.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(-0.015f, -0.032f), (Vector2?)new Vector2(1.018f, 0.982f), fullAnchor: false);
			_furnishTitle = UIFactory.Text("FurnTitle", "FURNISH", _furnishEditor.transform, 18, (TextAnchor)0, (FontStyle)1);
			((Graphic)_furnishTitle).color = _gold;
			Rect(((Graphic)_furnishTitle).rectTransform, new Vector2(0.04f, 0.876f), new Vector2(0.678f, 0.975f));
			ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.RoundedButtonWithLabel("FurnBack", "< BACK", _furnishEditor.transform, _accent, 0f, 26f, 13, Color.white);
			GameObject item4 = valueTuple2.Item1;
			Button item5 = valueTuple2.Item2;
			Text item6 = valueTuple2.Item3;
			RectTransform component2 = item4.GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.anchorMin = new Vector2(0.871f, 0.939f);
				component2.anchorMax = new Vector2(0.965f, 0.992f);
				component2.offsetMin = Vector2.zero;
				component2.offsetMax = Vector2.zero;
			}
			WireClick(item5, ReturnFromFurnish);
			_furnishTabsHost = MakePanel("FurnTabs", _furnishEditor.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.04f, 0.76f), (Vector2?)new Vector2(0.52f, 0.86f), fullAnchor: false);
			UIFactory.HorizontalLayoutOnGO(_furnishTabsHost, 8, 0, 0, 0, 0, (TextAnchor)4);
			GameObject val4 = MakePanel("FurnListHost", _furnishEditor.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)new Vector2(0.045f, 0.04f), (Vector2?)new Vector2(0.96f, 0.745f), fullAnchor: false);
			ScrollRect sr = default(ScrollRect);
			_furnishContent = UIFactory.ScrollableVerticalList("FurnList", val4.transform, ref sr);
			UIFactory.FitContentHeight(_furnishContent);
			HardenScrollClip(sr);
			_furnishEditor.SetActive(false);
			return val;
		}

		private void OpenFurnishFromRealEstate()
		{
			NDLog.Debug("[APP] FURNISH-Button geklickt -> Furnish-Seite.");
			GameObject activePage = GetActivePage();
			_furnishReturnPage = (((Object)(object)activePage != (Object)null && (Object)(object)activePage != (Object)(object)_furnishPage) ? activePage : _realEstatePage);
			SetActivePage(_furnishPage);
			ShowFurnishChooser();
		}

		private GameObject GetActivePage()
		{
			if (_pages == null)
			{
				return null;
			}
			for (int i = 0; i < _pages.Length; i++)
			{
				if ((Object)(object)_pages[i] != (Object)null && _pages[i].activeSelf)
				{
					return _pages[i];
				}
			}
			return null;
		}

		private void ReturnFromFurnish()
		{
			GameObject val = _furnishReturnPage;
			if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)_furnishPage)
			{
				val = _realEstatePage;
			}
			if ((Object)(object)val == (Object)(object)_realEstatePage)
			{
				SetActivePage(_realEstatePage);
				RefreshRealEstate();
			}
			else if ((Object)(object)val == (Object)(object)_homePage)
			{
				SetActivePage(_homePage, refreshHome: true);
			}
			else
			{
				SetActivePage(val);
			}
		}

		private void ShowFurnishChooser()
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_furnishEditor != (Object)null)
				{
					_furnishEditor.SetActive(false);
				}
				if ((Object)(object)_furnishChooser != (Object)null)
				{
					_furnishChooser.SetActive(true);
				}
				if ((Object)(object)_furnishChooseHost == (Object)null)
				{
					return;
				}
				UIFactory.ClearChildren(_furnishChooseHost.transform);
				MobFamily active = Active;
				IReadOnlyList<IMobFurnishTarget> readOnlyList = active?.FurnishTargets;
				bool flag = false;
				if (readOnlyList != null)
				{
					for (int i = 0; i < readOnlyList.Count; i++)
					{
						IMobFurnishTarget mobFurnishTarget = readOnlyList[i];
						if (mobFurnishTarget != null)
						{
							bool flag2 = false;
							try
							{
								flag2 = mobFurnishTarget.Available;
							}
							catch
							{
							}
							if (flag2)
							{
								flag = true;
								break;
							}
						}
					}
				}
				if (!flag)
				{
					Text val = UIFactory.Text("FurnNone", (active != null) ? active.FurnishEmptyText : "Nothing to furnish.", _furnishChooseHost.transform, 14, (TextAnchor)0, (FontStyle)0);
					((Graphic)val).color = LockedTxt;
					AddLayout(((Component)val).gameObject, 60f);
					Rect(((Graphic)val).rectTransform, Vector2.zero, Vector2.one);
					return;
				}
				for (int j = 0; j < readOnlyList.Count; j++)
				{
					IMobFurnishTarget mobFurnishTarget2 = readOnlyList[j];
					if (mobFurnishTarget2 != null)
					{
						bool enabled = false;
						try
						{
							enabled = mobFurnishTarget2.Available;
						}
						catch
						{
						}
						IMobFurnishTarget picked = mobFurnishTarget2;
						AddChooserButton($"FurnCh_{j}", mobFurnishTarget2.Name, enabled, delegate
						{
							OpenFurnish(picked);
						});
					}
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ShowFurnishChooser: " + ex.Message);
			}
		}

		private void AddChooserButton(string key, string label, bool enabled, Action onClick)
		{
			//IL_001a: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel(key, label, _furnishChooseHost.transform, enabled ? _accent : LockedBg, 0f, 50f, 16, enabled ? Color.white : LockedTxt);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement val = item.GetComponent<LayoutElement>();
				if ((Object)(object)val == (Object)null)
				{
					val = item.AddComponent<LayoutElement>();
				}
				val.minHeight = 50f;
				val.preferredHeight = 50f;
				val.flexibleWidth = 1f;
				if (enabled && onClick != null)
				{
					ButtonUtils.AddListener(item2, onClick);
					return;
				}
				try
				{
					((Selectable)item2).interactable = false;
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				NDLog.DebugWarn("[APP] ChooserButton " + key + ": " + ex.Message);
			}
		}

		private void OpenFurnish(IMobFurnishTarget target)
		{
			bool flag = false;
			try
			{
				flag = target?.Available ?? false;
			}
			catch
			{
			}
			if (!flag)
			{
				ShowFurnishChooser();
				return;
			}
			_furnishTarget = target;
			_furnishSurface = 0;
			if ((Object)(object)_furnishChooser != (Object)null)
			{
				_furnishChooser.SetActive(false);
			}
			if ((Object)(object)_furnishEditor != (Object)null)
			{
				_furnishEditor.SetActive(true);
			}
			RefreshFurnish();
		}

		private void RefreshFurnish()
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_furnishContent == (Object)null || (Object)(object)_furnishTabsHost == (Object)null)
				{
					return;
				}
				IMobFurnishTarget t = _furnishTarget;
				bool flag = false;
				try
				{
					flag = t != null && t.Available;
				}
				catch
				{
				}
				if (!flag)
				{
					ShowFurnishChooser();
					return;
				}
				if ((Object)(object)_furnishTitle != (Object)null)
				{
					_furnishTitle.text = "FURNISH — " + t.Name;
				}
				UIFactory.ClearChildren(_furnishTabsHost.transform);
				string[] array = new string[3] { "Floor", "Wall", "Ceiling" };
				for (int i = 0; i < array.Length; i++)
				{
					int sel = i;
					bool flag2 = _furnishSurface == i;
					AddChip(_furnishTabsHost, $"Tab_{i}", array[i], flag2 ? _gold : _accent, flag2 ? MainBg : Color.white, 30f, delegate
					{
						_furnishSurface = sel;
						RefreshFurnish();
					});
				}
				UIFactory.ClearChildren(((Component)_furnishContent).transform);
				int curMat = t.GetMat(_furnishSurface);
				int curCol = t.GetCol(_furnishSurface);
				AddSectionLabel(_furnishContent, "MATERIAL");
				BuildChipGrid(_furnishContent, "mat", FurnishCatalog.Materials.Length, 3, delegate(int num)
				{
					//IL_0049: 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_0058: 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)
					bool flag3 = num == curMat;
					return ((string label, Color bg, Color txt, Action onClick))(label: FurnishCatalog.Materials[num].Name, bg: flag3 ? _gold : CardBg, txt: flag3 ? MainBg : Color.white, onClick: delegate
					{
						t.SetMat(_furnishSurface, num);
						RefreshFurnish();
					});
				});
				AddSectionLabel(_furnishContent, "COLOR");
				BuildChipGrid(_furnishContent, "col", FurnishCatalog.Colors.Length, 3, delegate(int num)
				{
					//IL_0049: 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_0058: 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)
					bool flag3 = num == curCol;
					return ((string label, Color bg, Color txt, Action onClick))(label: FurnishCatalog.Colors[num].Name, bg: flag3 ? _gold : CardBg, txt: flag3 ? MainBg : Color.white, onClick: delegate
					{
						t.SetCol(_furnishSurface, num);
						RefreshFurnish();
					});
				});
				UIFactory.FitContentHeight(_furnishContent);
			}
			catch (Exception ex)
			{
				NDLog.Warn("[APP] RefreshFurnish: " + ex.Message);
			}
		}

		private GameObject AddFurnishRow(Transform content, float height)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePanel("FurnRow", content, new Color(0f, 0f, 0f, 0f));
			AddLayout(val, height);
			UIFactory.HorizontalLayoutOnGO(val, 6, 0, 0, 0, 0, (TextAnchor)4);
			return val;
		}

		private void AddChip(GameObject row, string key, string label, Color bg, Color txt, float height, Action onClick)
		{
			//IL_000a: 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)
			try
			{
				ValueTuple<Game