using System; using System.Collections.Generic; using System.Diagnostics; 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.Characters; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; 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("WorkplaceOverhaul")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Example Mod for Against The Storm")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d6ada77561ccfe85ca4c2c807fd24c8c3fc0d51c")] [assembly: AssemblyProduct("WorkplaceOverhaul")] [assembly: AssemblyTitle("WorkplaceOverhaul")] [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 WorkplaceOverhaul { public class OverlayClickOpener : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public ProductionBuilding Building; public void OnPointerClick(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)eventData.button <= 0 && (Object)(object)Building != (Object)null) { GameMB.GameInputService.Pick((IMapObject)(object)Building); } } } [HarmonyPatch(typeof(BuildingWorkersOverlay), "SetUp")] public static class WorkersOverlay_Clickable_Patch { private static void Postfix(BuildingWorkersOverlay __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown ProductionBuilding val = (ProductionBuilding)AccessTools.Field(typeof(BuildingWorkersOverlay), "building").GetValue(__instance); if (!((Object)(object)val == (Object)null)) { OverlayClickOpener overlayClickOpener = ((Component)__instance).gameObject.GetComponent() ?? ((Component)__instance).gameObject.AddComponent(); overlayClickOpener.Building = val; } } } [HarmonyPatch(typeof(BuildingRainpunkOverlay), "SetUp")] public static class RainpunkOverlay_Clickable_Patch { private static void Postfix(BuildingRainpunkOverlay __instance) { object? value = AccessTools.Field(typeof(BuildingRainpunkOverlay), "workshop").GetValue(__instance); Workshop val = (Workshop)((value is Workshop) ? value : null); if (!((Object)(object)val == (Object)null)) { ProductionBuilding component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null)) { OverlayClickOpener overlayClickOpener = ((Component)__instance).gameObject.GetComponent() ?? ((Component)__instance).gameObject.AddComponent(); overlayClickOpener.Building = component; } } } } [HarmonyPatch(typeof(BuildingRecipesOverlay), "SetUp")] public static class RecipesOverlay_Clickable_Patch { private static void Postfix(BuildingRecipesOverlay __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown ProductionBuilding val = (ProductionBuilding)AccessTools.Field(typeof(BuildingRecipesOverlay), "building").GetValue(__instance); if (!((Object)(object)val == (Object)null)) { OverlayClickOpener overlayClickOpener = ((Component)__instance).gameObject.GetComponent() ?? ((Component)__instance).gameObject.AddComponent(); overlayClickOpener.Building = val; } } } [HarmonyPatch(typeof(BuildingWorkersOverlay), "SetUp")] public static class WorkersOverlay_Scale_Patch { private static void Postfix(BuildingWorkersOverlay __instance) { WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.WorkplaceScale.Value); } } [HarmonyPatch(typeof(BuildingWorkersOverlay), "UpdatePositon")] public static class WorkersOverlay_Position_Scale_Patch { private static void Postfix(BuildingWorkersOverlay __instance) { WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.WorkplaceScale.Value); } } [HarmonyPatch(typeof(BuildingRainpunkOverlay), "SetUp")] public static class RainpunkOverlay_Scale_Patch { private static void Postfix(BuildingRainpunkOverlay __instance) { WorkplaceOverhaulPlugin.ActiveRainpunkOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.RainpunkScale.Value); } } [HarmonyPatch(typeof(BuildingRainpunkOverlay), "UpdatSlots")] public static class RainpunkOverlay_UpdateSlots_Scale_Patch { private static void Postfix(BuildingRainpunkOverlay __instance) { WorkplaceOverhaulPlugin.ActiveRainpunkOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.RainpunkScale.Value); } } [HarmonyPatch(typeof(BuildingRainpunkOverlay), "UpdatePosition")] public static class RainpunkOverlay_Position_Scale_Patch { private static void Postfix(BuildingRainpunkOverlay __instance) { WorkplaceOverhaulPlugin.ActiveRainpunkOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.RainpunkScale.Value); } } [HarmonyPatch(typeof(BuildingRecipesOverlay), "SetUp")] public static class RecipesOverlay_Scale_Patch { private static void Postfix(BuildingRecipesOverlay __instance) { WorkplaceOverhaulPlugin.ActiveRecipesOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.RecipesScale.Value); } } [HarmonyPatch(typeof(BuildingRecipesOverlay), "UpdatePosition")] public static class RecipesOverlay_Position_Scale_Patch { private static void Postfix(BuildingRecipesOverlay __instance) { WorkplaceOverhaulPlugin.ActiveRecipesOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.RecipesScale.Value); } } public class OverlayScaler : MonoBehaviour { private const float Step = 0.05f; private bool showIndicator = false; private float currentScale = 1f; private float MinScale => WorkplaceOverhaulPlugin.MinScaleCfg.Value; private float MaxScale => WorkplaceOverhaulPlugin.MaxScaleCfg.Value; private void Update() { //IL_0114: Unknown result type (might be due to invalid IL or missing references) Transform val = null; float num = 1f; if ((Object)(object)WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay != (Object)null && ((Component)WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay).gameObject.activeInHierarchy) { val = ((Component)WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay).transform; num = WorkplaceOverhaulPlugin.WorkplaceScale.Value; } else if ((Object)(object)WorkplaceOverhaulPlugin.ActiveRainpunkOverlay != (Object)null && ((Component)WorkplaceOverhaulPlugin.ActiveRainpunkOverlay).gameObject.activeInHierarchy) { val = ((Component)WorkplaceOverhaulPlugin.ActiveRainpunkOverlay).transform; num = WorkplaceOverhaulPlugin.RainpunkScale.Value; } else { if (!((Object)(object)WorkplaceOverhaulPlugin.ActiveRecipesOverlay != (Object)null) || !((Component)WorkplaceOverhaulPlugin.ActiveRecipesOverlay).gameObject.activeInHierarchy) { showIndicator = false; return; } val = ((Component)WorkplaceOverhaulPlugin.ActiveRecipesOverlay).transform; num = WorkplaceOverhaulPlugin.RecipesScale.Value; } if (Mouse.current == null || !Mouse.current.middleButton.isPressed) { showIndicator = false; return; } showIndicator = true; float x = ((InputControl)(object)((Pointer)Mouse.current).delta).ReadValue().x; if (Mathf.Abs(x) < 0.01f) { currentScale = num; return; } num += ((x > 0f) ? 0.05f : (-0.05f)); num = Mathf.Clamp(num, MinScale, MaxScale); Transform obj = val; BuildingWorkersOverlay activeWorkplaceOverlay = WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay; if ((Object)(object)obj == (Object)(object)((activeWorkplaceOverlay != null) ? ((Component)activeWorkplaceOverlay).transform : null)) { WorkplaceOverhaulPlugin.WorkplaceScale.Value = num; } else { Transform obj2 = val; BuildingRainpunkOverlay activeRainpunkOverlay = WorkplaceOverhaulPlugin.ActiveRainpunkOverlay; if ((Object)(object)obj2 == (Object)(object)((activeRainpunkOverlay != null) ? ((Component)activeRainpunkOverlay).transform : null)) { WorkplaceOverhaulPlugin.RainpunkScale.Value = num; } else { Transform obj3 = val; BuildingRecipesOverlay activeRecipesOverlay = WorkplaceOverhaulPlugin.ActiveRecipesOverlay; if ((Object)(object)obj3 == (Object)(object)((activeRecipesOverlay != null) ? ((Component)activeRecipesOverlay).transform : null)) { WorkplaceOverhaulPlugin.RecipesScale.Value = num; } } } WorkplaceOverhaulPlugin.ApplyScale(val, num); currentScale = num; } private void OnGUI() { //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_002b: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_004a: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (showIndicator) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 18 }; val.normal.textColor = Color.white; val.alignment = (TextAnchor)4; GUIStyle val2 = val; Vector2 mousePosition = Event.current.mousePosition; GUI.Label(new Rect(mousePosition.x + 20f, mousePosition.y - 20f, 150f, 30f), $"Scale {currentScale:0.00}x", val2); } } } [BepInPlugin("WorkplaceOverhaul", "Workplace Overhaul", "1.0.3")] public class WorkplaceOverhaulPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static Harmony HarmonyInstance; internal static ConfigEntry WorkplaceScale; internal static ConfigEntry RainpunkScale; internal static ConfigEntry RecipesScale; internal static ConfigEntry MinScaleCfg; internal static ConfigEntry MaxScaleCfg; internal static BuildingWorkersOverlay ActiveWorkplaceOverlay; internal static BuildingRainpunkOverlay ActiveRainpunkOverlay; internal static BuildingRecipesOverlay ActiveRecipesOverlay; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; HarmonyInstance = new Harmony("workplaceoverhaul"); HarmonyInstance.PatchAll(); WorkplaceScale = ((BaseUnityPlugin)this).Config.Bind("Overlay Scales", "WorkplaceScale", 0.8f, (ConfigDescription)null); RainpunkScale = ((BaseUnityPlugin)this).Config.Bind("Overlay Scales", "RainpunkScale", 1f, (ConfigDescription)null); RecipesScale = ((BaseUnityPlugin)this).Config.Bind("Overlay Scales", "RecipesScale", 1f, (ConfigDescription)null); MinScaleCfg = ((BaseUnityPlugin)this).Config.Bind("Overlay Scales", "MinScale", 0.5f, (ConfigDescription)null); MaxScaleCfg = ((BaseUnityPlugin)this).Config.Bind("Overlay Scales", "MaxScale", 1f, (ConfigDescription)null); ((Component)this).gameObject.AddComponent(); } internal static void ApplyScale(Transform t, float scale) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); if (val != null) { ((Transform)val).localScale = new Vector3(scale, scale, 1f); } } } [HarmonyPatch(typeof(WorkshopRecipesOverlay), "OnToggleClicked")] public static class RecipesOverlay_RealTimeUpdate_Patch { private static void Postfix() { if ((Object)(object)WorkshopPanel.Instance != (Object)null) { AccessTools.Method(typeof(WorkshopPanel), "SetUpRecipesButtons", (Type[])null, (Type[])null)?.Invoke(WorkshopPanel.Instance, null); } } } public class WorkplaceOverlayStatusTag : MonoBehaviour { public WorkerStatusSlot StatusSlot; public RectTransform PortraitRect; public RectTransform StatusRect; public bool Initialized; } internal static class WorkerStatusTemplateHolder { public static WorkerStatusSlot Template; } [HarmonyPatch(typeof(BuildingWorkerSlot), "SetUp")] public static class WorkerSlot_TemplateCapture_Patch { private static void Postfix(BuildingWorkerSlot __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown try { if (!((Object)(object)WorkerStatusTemplateHolder.Template != (Object)null)) { WorkerStatusSlot val = (WorkerStatusSlot)AccessTools.Field(typeof(BuildingWorkerSlot), "statusSlot").GetValue(__instance); if ((Object)(object)val != (Object)null) { WorkerStatusTemplateHolder.Template = val; WorkplaceOverhaulPlugin.Log.LogInfo((object)"[WorkplaceOverhaul] Captured WorkerStatusSlot template."); } } } catch (Exception arg) { WorkplaceOverhaulPlugin.Log.LogError((object)$"Error capturing template: {arg}"); } } } [HarmonyPatch(typeof(BuildingWorkersOverlay), "UpdatSlots")] public static class WorkerOverlay_StatusInjection_Patch { private static void Postfix(BuildingWorkersOverlay __instance) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown try { WorkerStatusSlot template = WorkerStatusTemplateHolder.Template; if ((Object)(object)template == (Object)null) { return; } List list = (List)AccessTools.Field(typeof(BuildingWorkersOverlay), "slots").GetValue(__instance); ProductionBuilding val = (ProductionBuilding)AccessTools.Field(typeof(BuildingWorkersOverlay), "building").GetValue(__instance); if (list == null || (Object)(object)val == (Object)null) { return; } WorkplaceOverhaulPlugin.ActiveWorkplaceOverlay = __instance; WorkplaceOverhaulPlugin.ApplyScale(((Component)__instance).transform, WorkplaceOverhaulPlugin.WorkplaceScale.Value); for (int i = 0; i < list.Count; i++) { BuildingWorkerSlot val2 = list[i]; if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy) { int num = val.Workers[i]; Actor actor = ((num == 0) ? null : GameMB.ActorsService.GetActor(num)); HandleSlot(val2, actor); } } } catch (Exception arg) { WorkplaceOverhaulPlugin.Log.LogError((object)$"Error in overlay patch: {arg}"); } } private static void HandleSlot(BuildingWorkerSlot slot, Actor actor) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Image val = (Image)AccessTools.Field(typeof(BuildingWorkerSlot), "raceIcon").GetValue(slot); if ((Object)(object)val == (Object)null) { return; } RectTransform rectTransform = ((Graphic)val).rectTransform; WorkplaceOverlayStatusTag workplaceOverlayStatusTag = ((Component)slot).GetComponentInChildren(true); if ((Object)(object)actor == (Object)null) { if ((Object)(object)workplaceOverlayStatusTag != (Object)null && (Object)(object)workplaceOverlayStatusTag.StatusSlot != (Object)null) { workplaceOverlayStatusTag.StatusSlot.Hide(); } return; } if ((Object)(object)workplaceOverlayStatusTag == (Object)null) { workplaceOverlayStatusTag = CreateInjectedStatusSlot(slot, rectTransform); if ((Object)(object)workplaceOverlayStatusTag == (Object)null) { return; } } if (!workplaceOverlayStatusTag.Initialized) { InitializeScaling(workplaceOverlayStatusTag); } val.sprite = actor.GetRoundIcon(); ((Graphic)val).material = null; workplaceOverlayStatusTag.StatusSlot.SetUp(actor); } private static WorkplaceOverlayStatusTag CreateInjectedStatusSlot(BuildingWorkerSlot slot, RectTransform portraitRect) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) WorkerStatusSlot template = WorkerStatusTemplateHolder.Template; if ((Object)(object)template == (Object)null) { return null; } GameObject val = Object.Instantiate(((Component)template).gameObject, (Transform)(object)portraitRect); ((Object)val).name = "OverlayWorkerStatus"; Transform val2 = val.transform.Find("WorkerIcon"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } WorkerStatusSlot component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return null; } WorkplaceOverlayStatusTag workplaceOverlayStatusTag = val.AddComponent(); workplaceOverlayStatusTag.StatusSlot = component; workplaceOverlayStatusTag.PortraitRect = portraitRect; workplaceOverlayStatusTag.StatusRect = val.GetComponent(); RectTransform statusRect = workplaceOverlayStatusTag.StatusRect; statusRect.anchorMin = new Vector2(0.5f, 0.5f); statusRect.anchorMax = new Vector2(0.5f, 0.5f); statusRect.pivot = new Vector2(0.5f, 0.5f); statusRect.anchoredPosition = Vector2.zero; ((Transform)statusRect).localRotation = Quaternion.identity; return workplaceOverlayStatusTag; } private static void InitializeScaling(WorkplaceOverlayStatusTag tag) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_00bb: Unknown result type (might be due to invalid IL or missing references) Rect rect = tag.PortraitRect.rect; Vector2 size = ((Rect)(ref rect)).size; rect = tag.StatusRect.rect; Vector2 size2 = ((Rect)(ref rect)).size; if (size.x <= 0f || size2.x <= 0f) { return; } float num = size.x / size2.x; ((Transform)tag.StatusRect).localScale = new Vector3(num, num, 1f); Transform val = ((Transform)tag.StatusRect).Find("ProgressBar"); if ((Object)(object)val != (Object)null) { RectTransform component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.sizeDelta *= 0.95f; } } tag.Initialized = true; } } public static class PluginInfo { public const string PLUGIN_GUID = "WorkplaceOverhaul"; public const string PLUGIN_NAME = "WorkplaceOverhaul"; 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) { } } }