Decompiled source of MoreHotkeys v1.0.0

MoreHotkeys.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Eremite;
using Eremite.Buildings;
using Eremite.Buildings.UI;
using Eremite.Buildings.UI.Trade;
using Eremite.Characters;
using Eremite.Characters.Behaviours;
using Eremite.Characters.Villagers;
using Eremite.Controller;
using Eremite.MapObjects;
using Eremite.Services;
using Eremite.View;
using Eremite.View.Popups;
using Eremite.View.UI.Wiki;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
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(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("MoreHotkeys")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("MoreHotkeys")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d6ada77561ccfe85ca4c2c807fd24c8c3fc0d51c")]
[assembly: AssemblyProduct("MoreHotkeys")]
[assembly: AssemblyTitle("MoreHotkeys")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoreHotkeys
{
	public static class CopyBuildingsHotkey
	{
		public static void OnUpdate()
		{
			//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)
			if (!GameController.IsGameActive || ShouldIgnoreInput())
			{
				return;
			}
			IInputService inputService = MB.InputService;
			DefaultActions inputConfig = MB.InputConfig;
			if (inputService.WasTriggered(((DefaultActions)(ref inputConfig)).CopyBuilding, false))
			{
				IMapObject value = GameMB.GameInputService.MouseoverObject.Value;
				if (value != null)
				{
					TryCopyBuildingFor(value);
				}
			}
		}

		private static bool ShouldIgnoreInput()
		{
			return (Object)(object)BuildingPanel.currentBuilding != (Object)null || !GameMB.ModeService.Idle.Value || MB.InputService.IsOverUI();
		}

		private static void TryCopyBuildingFor(IMapObject obj)
		{
			//IL_012d: 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)
			ResourceDeposit val = (ResourceDeposit)(object)((obj is ResourceDeposit) ? obj : null);
			if (val != null)
			{
				if (!val.State.isAvailable || !GameMB.DepositsService.HutsMatrix.ContainsKey(val.Model))
				{
					return;
				}
				foreach (GathererHutModel item in GameMB.DepositsService.HutsMatrix[val.Model])
				{
					if (BuildConditional((BuildingModel)(object)item))
					{
						return;
					}
				}
			}
			NaturalResource val2 = (NaturalResource)(object)((obj is NaturalResource) ? obj : null);
			if (val2 != null && val2.State.isAvailable)
			{
				BuildConditional(MB.Settings.GetBuilding("Woodcutters Camp"));
				return;
			}
			Spring val3 = (Spring)(object)((obj is Spring) ? obj : null);
			if (val3 != null && val3.State.isAvailable)
			{
				BuildConditional((BuildingModel)(object)MB.Settings.rainpunkConfig.extractor);
				return;
			}
			Field val4 = (Field)(object)((obj is Field) ? obj : null);
			if (val4 != null)
			{
				if (!GameMB.OreService.HasAvailableOre(val4.Pos))
				{
					return;
				}
				Ore ore = GameMB.OreService.GetOre(val4.Pos);
				foreach (MineModel item2 in GameMB.OreService.MinesMatrix[ore.Model.refGood.Name])
				{
					if (BuildConditional((BuildingModel)(object)item2))
					{
						return;
					}
				}
			}
			Lake val5 = (Lake)(object)((obj is Lake) ? obj : null);
			if (val5 != null)
			{
				if (val5.State.isAvailable && !BuildConditional(MB.Settings.GetBuilding("Fishing Hut")))
				{
					BuildConditional(MB.Settings.GetBuilding("Primitive Fishing Hut"));
				}
			}
			else if (obj is Ore)
			{
				BuildConditional(MB.Settings.GetBuilding("Mine"));
			}
		}

		private static bool BuildConditional(BuildingModel building)
		{
			if (GameMB.GameContentService.IsUnlocked(building) && GameMB.ConstructionService.CanConstruct(building))
			{
				GameMB.GameBlackboardService.BuildingConstructionRequested.OnNext(building);
				return true;
			}
			return false;
		}
	}
	public static class CycleUnbuiltBuildingsHotkey
	{
		private static bool cyclingMode;

		private static List<BuildingModel> unbuilt;

		private static int index;

		public static void OnUpdate(KeyboardShortcut forwardKey, KeyboardShortcut backwardKey)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!GameController.IsGameActive || MB.InputService.IsLocked())
			{
				return;
			}
			if (((KeyboardShortcut)(ref forwardKey)).IsDown())
			{
				if (!cyclingMode)
				{
					EnterMode();
				}
				else
				{
					CycleNext();
				}
			}
			else if (((KeyboardShortcut)(ref backwardKey)).IsDown())
			{
				if (!cyclingMode)
				{
					EnterMode();
				}
				else
				{
					CyclePrev();
				}
			}
			else if (cyclingMode)
			{
				IInputService inputService = MB.InputService;
				DefaultActions inputConfig = MB.InputConfig;
				if (inputService.WasTriggered(((DefaultActions)(ref inputConfig)).Cancel, false))
				{
					ExitMode();
				}
			}
		}

		private static void EnterMode()
		{
			unbuilt = GetUnbuiltBuildings();
			if (unbuilt.Count == 0)
			{
				MoreHotkeysPlugin.Log.LogInfo((object)"No unbuilt buildings available.");
				return;
			}
			cyclingMode = true;
			index = 0;
			ShowBuilding(unbuilt[index]);
		}

		private static void ExitMode()
		{
			cyclingMode = false;
			unbuilt = null;
			index = 0;
		}

		private static void RefreshList()
		{
			List<BuildingModel> unbuiltBuildings = GetUnbuiltBuildings();
			if (unbuiltBuildings.Count != unbuilt.Count)
			{
				unbuilt = unbuiltBuildings;
				if (unbuilt.Count == 0)
				{
					ExitMode();
				}
				else
				{
					index = Mathf.Clamp(index, 0, unbuilt.Count - 1);
				}
			}
		}

		private static void CycleNext()
		{
			RefreshList();
			if (cyclingMode && unbuilt.Count != 0)
			{
				index = (index + 1) % unbuilt.Count;
				ShowBuilding(unbuilt[index]);
			}
		}

		private static void CyclePrev()
		{
			RefreshList();
			if (cyclingMode && unbuilt.Count != 0)
			{
				index = (index - 1 + unbuilt.Count) % unbuilt.Count;
				ShowBuilding(unbuilt[index]);
			}
		}

		private static void ShowBuilding(BuildingModel model)
		{
			if (GameMB.GameContentService.IsUnlocked(model) && GameMB.ConstructionService.CanConstruct(model))
			{
				GameMB.GameBlackboardService.BuildingConstructionRequested.OnNext(model);
			}
		}

		private static List<BuildingModel> GetUnbuiltBuildings()
		{
			List<BuildingModel> value = GameMB.GameContentService.Buildings.Value;
			HashSet<string> builtNames = new HashSet<string>(GameMB.BuildingsService.Buildings.Values.Select((Building b) => ((Object)b.BuildingModel).name));
			BuildingCategoryModel decorationCategory = ((IEnumerable<BuildingCategoryModel>)MB.Settings.BuildingCategories).FirstOrDefault((Func<BuildingCategoryModel, bool>)((BuildingCategoryModel c) => ((SO)c).Name.ToLower().Contains("decor")));
			BuildingCategoryModel resourceCategory = ((IEnumerable<BuildingCategoryModel>)MB.Settings.BuildingCategories).FirstOrDefault((Func<BuildingCategoryModel, bool>)((BuildingCategoryModel c) => ((SO)c).Name.ToLower().Contains("resource")));
			IEnumerable<BuildingModel> source = value.Where((BuildingModel model) => (Object)(object)model != (Object)null && (Object)(object)model.category != (Object)null && model.category.isOnHUD && ((Object)(object)decorationCategory == (Object)null || (Object)(object)model.category != (Object)(object)decorationCategory) && ((Object)(object)resourceCategory == (Object)null || (Object)(object)model.category != (Object)(object)resourceCategory) && GameMB.ConstructionService.ShouldShowInShop(model) && GameMB.GameContentService.IsUnlocked(model) && GameMB.ConstructionService.CanConstruct(model) && !builtNames.Contains(((Object)model).name) && (model.tags == null || !model.tags.Any((BuildingTagModel t) => t.iconTag == "Decoration" || t.iconTag == "Road" || t.iconTag == "Pipe" || t.iconTag == "Resource")) && !((SO)model).Name.Contains("Shrine") && !((SO)model).Name.Contains("Fence") && !((SO)model).Name.Contains("Garden") && !((SO)model).Name.Contains("Park") && !((SO)model).Name.Contains("Bush") && !((SO)model).Name.Contains("Sign") && !((SO)model).Name.Contains("Pipe") && !((SO)model).Name.Contains("Camp") && !((SO)model).Name.Contains("Hut"));
			return (from m in source
				orderby m.category.order, m.order, ((SO)m).Name
				select m).ToList();
		}
	}
	[HarmonyPatch(typeof(RecipesOverlaysManager), "OnHighlightStarted")]
	public static class DisableRecipeOverlayWhenWorkplaceOverlayOpen
	{
		private static bool Prefix()
		{
			BuildingWorkersOverlay val = Object.FindObjectOfType<BuildingWorkersOverlay>();
			if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	public static class FarmerLeave
	{
		private static readonly FieldInfo WorkersToUnassignField = typeof(WorkerLeave).GetField("workersToUnassign", BindingFlags.Static | BindingFlags.NonPublic);

		private static readonly FieldInfo ActorField = typeof(ActorTask).GetField("actor", BindingFlags.Instance | BindingFlags.NonPublic);

		private static HashSet<int> WorkersToUnassign => WorkersToUnassignField?.GetValue(null) as HashSet<int>;

		private static Actor GetActor(object instance)
		{
			if (instance == null || ActorField == null)
			{
				return null;
			}
			object? value = ActorField.GetValue(instance);
			return (Actor)((value is Actor) ? value : null);
		}

		private static bool TryConsumeQueuedWorker(int id)
		{
			return WorkersToUnassign?.Remove(id) ?? false;
		}

		private static void UnassignFarmer(Actor actor)
		{
			if ((Object)(object)actor == (Object)null)
			{
				return;
			}
			int id = actor.Id;
			if (!TryConsumeQueuedWorker(id))
			{
				return;
			}
			IVillagersService villagersService = GameMB.VillagersService;
			if (villagersService != null)
			{
				Villager villager = villagersService.GetVillager(id);
				if ((Object)(object)villager != (Object)null)
				{
					villagersService.ReleaseFromProfession(villager, false);
				}
			}
		}

		[HarmonyPatch(typeof(Plow), "OnComplete")]
		[HarmonyPostfix]
		public static void Plow_OnComplete(Plow __instance)
		{
			UnassignFarmer(GetActor(__instance));
		}

		[HarmonyPatch(typeof(Plant), "OnComplete")]
		[HarmonyPostfix]
		public static void Plant_OnComplete(Plant __instance)
		{
			UnassignFarmer(GetActor(__instance));
		}

		[HarmonyPatch(typeof(Harvest), "OnComplete")]
		[HarmonyPostfix]
		public static void Harvest_OnComplete(Harvest __instance)
		{
			Actor actor = GetActor(__instance);
			if (!((Object)(object)actor == (Object)null))
			{
				UnassignFarmer(actor);
			}
		}
	}
	[HarmonyPatch]
	public static class HotkeyManager
	{
		public static ConfigEntry<KeyboardShortcut> KeyGeneral;

		public static ConfigEntry<KeyboardShortcut> KeyBuildings;

		public static ConfigEntry<KeyboardShortcut> KeyCornerstones;

		public static ConfigEntry<KeyboardShortcut> KeyTraders;

		public static ConfigEntry<KeyboardShortcut> KeySpecies;

		public static ConfigEntry<KeyboardShortcut> KeyTradingPost;

		public static ConfigEntry<KeyboardShortcut> KeyCycleUnbuiltForward;

		public static ConfigEntry<KeyboardShortcut> KeyCycleUnbuiltBackward;

		private static WikiPopup wikiPopup;

		private static WikiBasicPanel panelGeneral;

		private static WikiBuildingsPanel panelBuildings;

		private static WikiEffectsPanel panelCornerstones;

		private static WikiTradersPanel panelTraders;

		private static WikiRacesPanel panelSpecies;

		static HotkeyManager()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			ConfigFile configFile = MoreHotkeysPlugin.ConfigFile;
			KeyGeneral = configFile.Bind<KeyboardShortcut>("Hotkeys", "EncyclopediaGeneral", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "Open Encyclopedia → General");
			KeyBuildings = configFile.Bind<KeyboardShortcut>("Hotkeys", "EncyclopediaBuildings", new KeyboardShortcut((KeyCode)283, Array.Empty<KeyCode>()), "Open Encyclopedia → Buildings");
			KeyCornerstones = configFile.Bind<KeyboardShortcut>("Hotkeys", "EncyclopediaCornerstones", new KeyboardShortcut((KeyCode)284, Array.Empty<KeyCode>()), "Open Encyclopedia → Cornerstones");
			KeyTraders = configFile.Bind<KeyboardShortcut>("Hotkeys", "EncyclopediaTraders", new KeyboardShortcut((KeyCode)285, Array.Empty<KeyCode>()), "Open Encyclopedia → Traders");
			KeySpecies = configFile.Bind<KeyboardShortcut>("Hotkeys", "EncyclopediaSpecies", new KeyboardShortcut((KeyCode)286, Array.Empty<KeyCode>()), "Open Encyclopedia → Species");
			KeyTradingPost = configFile.Bind<KeyboardShortcut>("Hotkeys", "OpenTradingPost", new KeyboardShortcut((KeyCode)106, Array.Empty<KeyCode>()), "Toggle the Trading Post window");
			KeyCycleUnbuiltForward = configFile.Bind<KeyboardShortcut>("Hotkeys", "CycleUnbuiltForward", new KeyboardShortcut((KeyCode)99, Array.Empty<KeyCode>()), "Cycle forward through unbuilt buildings");
			KeyCycleUnbuiltBackward = configFile.Bind<KeyboardShortcut>("Hotkeys", "CycleUnbuiltBackward", new KeyboardShortcut((KeyCode)120, Array.Empty<KeyCode>()), "Cycle backward through unbuilt buildings");
		}

		[HarmonyPatch(typeof(WikiPopup), "SetUp")]
		[HarmonyPostfix]
		private static void WikiPopup_SetUp(WikiPopup __instance)
		{
			wikiPopup = __instance;
			WikiCategoryPanel[] panels = __instance.panels;
			foreach (WikiCategoryPanel val in panels)
			{
				WikiBasicPanel val2 = (WikiBasicPanel)(object)((val is WikiBasicPanel) ? val : null);
				if (val2 != null)
				{
					panelGeneral = val2;
					continue;
				}
				WikiBuildingsPanel val3 = (WikiBuildingsPanel)(object)((val is WikiBuildingsPanel) ? val : null);
				if (val3 != null)
				{
					panelBuildings = val3;
					continue;
				}
				WikiEffectsPanel val4 = (WikiEffectsPanel)(object)((val is WikiEffectsPanel) ? val : null);
				if (val4 != null)
				{
					panelCornerstones = val4;
					continue;
				}
				WikiTradersPanel val5 = (WikiTradersPanel)(object)((val is WikiTradersPanel) ? val : null);
				if (val5 != null)
				{
					panelTraders = val5;
					continue;
				}
				WikiRacesPanel val6 = (WikiRacesPanel)(object)((val is WikiRacesPanel) ? val : null);
				if (val6 != null)
				{
					panelSpecies = val6;
				}
			}
		}

		public static void OnUpdate()
		{
			//IL_0023: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0088: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (GameController.IsGameActive && !MB.InputService.IsLocked())
			{
				KeyboardShortcut value = KeyGeneral.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleWiki((WikiCategoryPanel)(object)panelGeneral);
				}
				value = KeyBuildings.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleWiki((WikiCategoryPanel)(object)panelBuildings);
				}
				value = KeyCornerstones.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleWiki((WikiCategoryPanel)(object)panelCornerstones);
				}
				value = KeyTraders.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleWiki((WikiCategoryPanel)(object)panelTraders);
				}
				value = KeySpecies.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ToggleWiki((WikiCategoryPanel)(object)panelSpecies);
				}
				value = KeyTradingPost.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					TryOpenTradingPost();
				}
				CopyBuildingsHotkey.OnUpdate();
				CycleUnbuiltBuildingsHotkey.OnUpdate(KeyCycleUnbuiltForward.Value, KeyCycleUnbuiltBackward.Value);
			}
		}

		private static void ToggleWiki(WikiCategoryPanel panel)
		{
			if (!((Object)(object)panel == (Object)null) && !((Object)(object)wikiPopup == (Object)null))
			{
				if (((Popup)wikiPopup).IsShown() && (Object)(object)wikiPopup.current == (Object)(object)panel)
				{
					((Popup)wikiPopup).Hide();
				}
				else
				{
					wikiPopup.OnCategoryRequested(panel);
				}
			}
		}

		private static void TryOpenTradingPost()
		{
			if ((Object)(object)SimplePanel.Instance != (Object)null && ((PreviewPanel)SimplePanel.Instance).IsActive())
			{
				((PreviewPanel)SimplePanel.Instance).Hide();
				return;
			}
			if ((Object)(object)TraderPanel.Instance != (Object)null && ((Popup)TraderPanel.Instance).IsShown())
			{
				((Popup)TraderPanel.Instance).Hide();
				return;
			}
			IBuildingsService buildingsService = GameMB.BuildingsService;
			Dictionary<int, Building> dictionary = ((buildingsService != null) ? buildingsService.Buildings : null);
			if (dictionary == null)
			{
				return;
			}
			foreach (KeyValuePair<int, Building> item in dictionary)
			{
				Building value = item.Value;
				TradingPost val = (TradingPost)(object)((value is TradingPost) ? value : null);
				if (val != null)
				{
					GameMB.GameInputService.Pick((IMapObject)(object)val);
					break;
				}
			}
		}
	}
	[BepInPlugin("MoreHotkeys", "More Hotkeys", "1.0.0")]
	public class MoreHotkeysPlugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		public static ConfigFile ConfigFile;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ConfigFile = ((BaseUnityPlugin)this).Config;
			Harmony val = new Harmony("MoreHotkeys");
			val.PatchAll();
			Log.LogInfo((object)"MoreHotkeys loaded successfully.");
		}

		private void Update()
		{
			HotkeyManager.OnUpdate();
		}
	}
	[HarmonyPatch]
	public static class WorkerLeave
	{
		private static readonly string MARKER_NAME = "WorkerLeaveMarker";

		private static Sprite markerSprite = null;

		private static readonly HashSet<int> workersToUnassign = new HashSet<int>();

		[HarmonyPatch(typeof(BuildingWorkerSlot), "OnRightClick")]
		[HarmonyPrefix]
		public static bool BuildingWorkerSlot_OnRightClick_Prefix(BuildingWorkerSlot __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			IInputService inputService = MB.InputService;
			DefaultActions inputConfig = MB.InputConfig;
			if (inputService != null && inputService.IsTriggering(((DefaultActions)(ref inputConfig)).InputModifierControl))
			{
				QueueToggleUnassign(__instance);
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(BuildingWorkerSlot), "SetUpActor")]
		[HarmonyPrefix]
		public static void BuildingWorkerSlot_SetUpActor_Prefix(BuildingWorkerSlot __instance)
		{
			PutMarkerIn(__instance);
		}

		[HarmonyPatch(typeof(WorkerStatusSlot), "SetUpActor")]
		[HarmonyPrefix]
		public static void WorkerStatusSlot_SetUpActor_Prefix(WorkerStatusSlot __instance)
		{
			UpdateMarkerStatus(__instance);
		}

		[HarmonyPatch(typeof(ProductionBuilding), "DispatchProductionFinished")]
		[HarmonyPostfix]
		public static void ProductionBuilding_DispatchProductionFinished_Postfix(ProductionBuilding __instance, ProductionState production)
		{
			if (production != null && !(__instance is Farm))
			{
				TryUnassign(production);
			}
		}

		[HarmonyPatch(typeof(VillagersService), "RemoveFromProfession")]
		[HarmonyPostfix]
		public static void VillagersService_RemoveFromProfession_Postfix(Villager villager)
		{
			if ((Object)(object)villager != (Object)null)
			{
				Remove(villager);
			}
		}

		private static void QueueToggleUnassign(BuildingWorkerSlot slot)
		{
			PutMarkerIn(slot);
			int id = slot.actor.Id;
			if (!workersToUnassign.Remove(id))
			{
				workersToUnassign.Add(id);
			}
		}

		private static void TryUnassign(ProductionState production)
		{
			int worker = production.worker;
			if (!workersToUnassign.Remove(worker))
			{
				return;
			}
			IVillagersService villagersService = GameMB.VillagersService;
			if (villagersService != null)
			{
				Villager villager = villagersService.GetVillager(worker);
				if ((Object)(object)villager != (Object)null)
				{
					villagersService.ReleaseFromProfession(villager, false);
				}
			}
		}

		private static void Remove(Villager villager)
		{
			int id = ((Actor)villager).Id;
			workersToUnassign.Remove(id);
		}

		private static void PutMarkerIn(BuildingWorkerSlot slot)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)slot).transform.Find("StatusIcon");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = val.Find(MARKER_NAME);
			if ((Object)(object)val2 != (Object)null)
			{
				return;
			}
			GameObject val3 = new GameObject(MARKER_NAME);
			val3.transform.SetParent(val, false);
			val3.SetActive(false);
			val3.transform.localPosition = new Vector3(-10f, 10f, 0f);
			TransformExtensions.SetScale(val3.transform, 0.2f);
			Image val4 = val3.AddComponent<Image>();
			if ((Object)(object)markerSprite == (Object)null)
			{
				GameObject val5 = GameObject.Find("/HUD/GoodsHUD/SacrificeMarker/Content");
				if ((Object)(object)val5 != (Object)null)
				{
					Image component = val5.GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						markerSprite = component.sprite;
					}
				}
			}
			val4.sprite = markerSprite;
		}

		private static bool UpdateMarkerStatus(WorkerStatusSlot slot)
		{
			Transform val = ((Component)slot).transform.Find("StatusIcon/" + MARKER_NAME);
			if ((Object)(object)val == (Object)null || (Object)(object)slot.actor == (Object)null)
			{
				return false;
			}
			bool flag = workersToUnassign.Contains(slot.actor.Id);
			ComponentExtensions.SetActive((Component)(object)val, flag);
			return flag;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MoreHotkeys";

		public const string PLUGIN_NAME = "MoreHotkeys";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}