using System;
using System.Collections;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SuperFantasyKingdom;
using SuperFantasyKingdom.Buildings;
using SuperFantasyKingdom.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("AWSSDK.CognitoIdentity")]
[assembly: IgnoresAccessChecksTo("AWSSDK.CognitoSync")]
[assembly: IgnoresAccessChecksTo("AWSSDK.Core")]
[assembly: IgnoresAccessChecksTo("AWSSDK.Kinesis")]
[assembly: IgnoresAccessChecksTo("AWSSDK.SecurityToken")]
[assembly: IgnoresAccessChecksTo("com.games-farm.platforms.wingdk.public.runtime")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("FMODUnity")]
[assembly: IgnoresAccessChecksTo("FMODUnityResonance")]
[assembly: IgnoresAccessChecksTo("GalaxyCSharp")]
[assembly: IgnoresAccessChecksTo("GamesFarm.Platforms.WinGDK.Private.Core")]
[assembly: IgnoresAccessChecksTo("GamesFarm.Platforms.WinGDK.Private.Runtime")]
[assembly: IgnoresAccessChecksTo("I18N.CJK")]
[assembly: IgnoresAccessChecksTo("I18N")]
[assembly: IgnoresAccessChecksTo("I18N.MidEast")]
[assembly: IgnoresAccessChecksTo("I18N.Other")]
[assembly: IgnoresAccessChecksTo("I18N.Rare")]
[assembly: IgnoresAccessChecksTo("I18N.West")]
[assembly: IgnoresAccessChecksTo("Mono.Security")]
[assembly: IgnoresAccessChecksTo("netstandard")]
[assembly: IgnoresAccessChecksTo("Newtonsoft.Json")]
[assembly: IgnoresAccessChecksTo("PrimeTween.Runtime")]
[assembly: IgnoresAccessChecksTo("Textus.SerializeReferenceUI")]
[assembly: IgnoresAccessChecksTo("UniTask.Addressables")]
[assembly: IgnoresAccessChecksTo("UniTask")]
[assembly: IgnoresAccessChecksTo("UniTask.DOTween")]
[assembly: IgnoresAccessChecksTo("UniTask.Linq")]
[assembly: IgnoresAccessChecksTo("UniTask.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Animation.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Common.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.IK.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.PixelPerfect")]
[assembly: IgnoresAccessChecksTo("Unity.2D.SpriteShape.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Tilemap.Extras")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.001")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Microsoft.GDK")]
[assembly: IgnoresAccessChecksTo("Unity.Microsoft.GDK.Tools")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AccessibilityModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AndroidJNIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AnimationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClothModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterInputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterRendererModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CrashReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DirectorModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DSPGraphModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GameCenterModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GridModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.HotReloadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ImageConversionModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputLegacyModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.JSONSerializeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.LocalizationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ParticleSystemModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PerformanceReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.Physics2DModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ProfilerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ScreenCaptureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SharedInternalsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteMaskModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteShapeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.StreamingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubstanceModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubsystemsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainPhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreFontEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreTextEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextRenderingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TilemapModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TLSModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsNativeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UmbraModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UNETModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsCommonModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityConnectModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityCurlModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityTestProtocolModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestTextureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestWWWModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VehiclesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VFXModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VideoModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VirtualTexturingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VRModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.WindModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XRModule")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("DemolishAll")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6a67d0ce5409d2853ac0dc6ebad088994109919e")]
[assembly: AssemblyProduct("Ability to demolish any building")]
[assembly: AssemblyTitle("DemolishAll")]
[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 DemolishAll
{
[BepInPlugin("com.sfkbutter.demolishany", "SFK Demolish Any", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.sfkbutter.demolishany";
public const string PLUGIN_NAME = "SFK Demolish Any";
public const string PLUGIN_VERSION = "1.0.0";
internal static ManualLogSource Logger;
private Harmony _harmony = new Harmony("com.sfkbutter.demolishany");
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin com.sfkbutter.demolishany is loaded!");
_harmony.PatchAll();
}
}
}
namespace DemolishAll.Patches
{
[HarmonyPatch(typeof(BuildingCity), "Demolish")]
public static class Patch_HouseDemolish_DespawnWorkers
{
private static void Postfix(BuildingCity __instance)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
List<Worker> worker = JobManager.Instance.GetWorker();
if (worker == null)
{
return;
}
foreach (Worker item in worker.ToList())
{
if (!((Object)(object)item == (Object)null) && (Object)(object)__instance == (Object)(object)item.GetHome())
{
JobManager.Instance.UnregisterWorker(item);
Object.Destroy((Object)(object)((Component)item).gameObject);
}
}
}
}
[HarmonyPatch(typeof(UIBuildingOverlayElementDemolish), "Select")]
public static class Patch_DemolishSelectGuard
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__0_0;
internal void <Prefix>b__0_0()
{
OverlayManager.Instance.Cancel(true);
}
}
private static bool Prefix(UIBuildingOverlayElementDemolish __instance)
{
//IL_0033: 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_003e: Expected O, but got Unknown
//IL_006c: 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_00a8: Expected O, but got Unknown
OverlayManager.Instance.CloseOverlay(false);
UIOverlayMessage val = OverlayManager.Instance.OverlayMessage(true);
object obj = <>c.<>9__0_0;
if (obj == null)
{
UnityAction val2 = delegate
{
OverlayManager.Instance.Cancel(true);
};
<>c.<>9__0_0 = val2;
obj = (object)val2;
}
val.SetCancel("", (UnityAction)obj);
string message = "Demolish this building?";
LocalizedString stringMessage = __instance.stringMessage;
if (stringMessage != null)
{
message = stringMessage.GetLocalizedString();
}
val.SetMessage(message);
? val3 = val;
ResourceAmount val4 = new ResourceAmount((ResourceType)31, 1);
Delegate @delegate = AccessTools.Method(((object)__instance).GetType(), "Callback", (Type[])null, (Type[])null).CreateDelegate(typeof(UnityAction), __instance);
((UIOverlayMessage)val3).SetAccept(val4, new UnityAction(((UnityAction)((@delegate is UnityAction) ? @delegate : null)).Invoke));
return false;
}
}
[HarmonyPatch(typeof(UIBuildingOverlay), "Open")]
public static class Patch_Demolish
{
[CompilerGenerated]
private sealed class <MoveNextFrame>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private GameObject <selection>5__1;
private Transform <demolishRoot>5__2;
private RectTransform <rt>5__3;
private Vector2 <p>5__4;
private Vector3 <lp>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MoveNextFrame>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<selection>5__1 = null;
<demolishRoot>5__2 = null;
<rt>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: 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_0117: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
<selection>5__1 = GameObject.Find("Canvas/UICanvasPP/Overlay/SizeSelection/Panel/Selection");
if ((Object)(object)<selection>5__1 == (Object)null)
{
Plugin.Logger.LogInfo((object)"Selection container not found.");
return false;
}
<demolishRoot>5__2 = (from Transform t in (IEnumerable)<selection>5__1.transform
where ((Object)t).name.StartsWith("OverlayElementDemolish")
select t).LastOrDefault();
if ((Object)(object)<demolishRoot>5__2 == (Object)null)
{
Plugin.Logger.LogInfo((object)"OverlayElementDemolish(Clone) not found.");
return false;
}
ref RectTransform reference = ref <rt>5__3;
Transform obj = <demolishRoot>5__2;
reference = (RectTransform)(object)((obj is RectTransform) ? obj : null);
if (<rt>5__3 != null)
{
<p>5__4 = <rt>5__3.anchoredPosition;
<p>5__4.y -= Y_OFFSET;
<rt>5__3.anchoredPosition = <p>5__4;
Plugin.Logger.LogInfo((object)$"Moved {((Object)<demolishRoot>5__2).name} down by {Y_OFFSET}");
}
else
{
<lp>5__5 = <demolishRoot>5__2.localPosition;
<lp>5__5.y -= 0.2f;
<demolishRoot>5__2.localPosition = <lp>5__5;
}
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static UIBuildingOverlayElementDemolish _element;
private static float Y_OFFSET = 50f;
private static void Prefix(UIBuildingOverlay __instance, bool force)
{
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Expected O, but got Unknown
Building building = __instance.building;
if ((Object)(object)building == (Object)null || !(building is BuildingCity) || building is BuildingCastle)
{
return;
}
Plugin.Logger.LogInfo((object)"Demolish Prefix");
List<UIBuildingOverlayElement> list = __instance.buttons;
if (list == null)
{
list = (__instance.buttons = new List<UIBuildingOverlayElement>());
}
if (list.Any((UIBuildingOverlayElement b) => b is UIBuildingOverlayElementDemolish))
{
return;
}
if (_element == null)
{
UIBuildingOverlay[] array = Object.FindObjectsOfType<UIBuildingOverlay>(true);
foreach (UIBuildingOverlay val in array)
{
List<UIBuildingOverlayElement> buttons = val.buttons;
if (buttons != null)
{
UIBuildingOverlayElement? obj = ((IEnumerable<UIBuildingOverlayElement>)buttons).FirstOrDefault((Func<UIBuildingOverlayElement, bool>)((UIBuildingOverlayElement e) => e is UIBuildingOverlayElementDemolish));
_element = (UIBuildingOverlayElementDemolish)(object)((obj is UIBuildingOverlayElementDemolish) ? obj : null);
if (_element != null)
{
break;
}
}
}
}
if (_element != null)
{
Plugin.Logger.LogInfo((object)"Adding Demolish (Cloned)");
UIBuildingOverlayElementDemolish item = ClassExtensions.Clone<UIBuildingOverlayElementDemolish>(_element);
list.Add((UIBuildingOverlayElement)(object)item);
}
else
{
Plugin.Logger.LogInfo((object)"No Element Demolish");
list.Add((UIBuildingOverlayElement)new UIBuildingOverlayElementDemolish());
}
}
private static void Postfix(UIBuildingOverlay __instance, bool force)
{
((MonoBehaviour)OverlayManager.Instance).StartCoroutine(MoveNextFrame());
}
[IteratorStateMachine(typeof(<MoveNextFrame>d__4))]
private static IEnumerator MoveNextFrame()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MoveNextFrame>d__4(0);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}