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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UISystem;
using WildSkies.Gameplay.Building;
using WildSkies.Gameplay.Items;
using WildSkies.Mediators;
using WildSkies.ShipParts;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ContinuousPlacement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ContinuousPlacement")]
[assembly: AssemblyTitle("ContinuousPlacement")]
[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 ContinuousPlacement
{
[BepInPlugin("ContinuousPlacement", "ContinuousPlacement", "1.0.0")]
public class Plugin : BasePlugin
{
private class ContinuousPlacementSimpleChatCommands
{
public static string Toggle()
{
ContinuousPlacement_Enable.Value = !ContinuousPlacement_Enable.Value;
return "Continuous placement " + (ContinuousPlacement_Enable.Value ? "enabled" : "disabled") + ".";
}
}
internal static ManualLogSource Log;
internal static Harmony harmonyInstance;
private static ConfigEntry<bool> ContinuousPlacement_Enable;
private static bool ShipPartPlacementLoaded;
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ContinuousPlacement");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
ContinuousPlacement_Enable = ((BasePlugin)this).Config.Bind<bool>("ContinuousPlacement", "Enable", true, "ContinuousPlacement.Enable");
harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
}
public override bool Unload()
{
Harmony obj = harmonyInstance;
if (obj != null)
{
obj.UnpatchSelf();
}
return true;
}
[HarmonyPatch(typeof(Bootstrap), "OnAllServicesReady")]
[HarmonyPostfix]
private static void Bootstrap_OnAllServicesReady(Bootstrap __instance)
{
string copyright = typeof(Plugin).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
ShipPartPlacementLoaded = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Any((KeyValuePair<string, PluginInfo> x) => x.Value.Instance?.GetType().GetTypeInfo().Assembly.GetCustomAttribute<AssemblyCopyrightAttribute>()?.Copyright == copyright && x.Key.Equals("ShipPartPlacement", StringComparison.OrdinalIgnoreCase));
}
[HarmonyPatch(typeof(BuildingMediator), "ShowAssetBuiltNotification")]
[HarmonyPrefix]
public static bool BuildingMediator_ShowAssetBuiltNotification(BuildingMediator __instance, BuildableItemDefinition assetPlaced)
{
//IL_0012: 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)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (!ContinuousPlacement_Enable.Value || (int)__instance._buildingService.CurrentBuildMode != 0)
{
return true;
}
if (!assetPlaced.ContinuousPlacement)
{
if (!ShipPartPlacementLoaded)
{
ShipPartPlacementCategories[] array = new ShipPartPlacementCategories[3];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
if (((IEnumerable<ShipPartPlacementCategories>)(object)array).Contains(assetPlaced.PlacementCategory))
{
goto IL_0048;
}
}
((Il2CppArrayBase<Object>)(object)__instance._notificationArgumentsAux)[0] = (Object)(object)assetPlaced.ItemName;
__instance._uiService.HUDManager.ShowHudElementAsync((UIHudType)14, ((Il2CppObjectBase)new NotificationHudPayload(assetPlaced.Icon, (LocalisedStringID)4, false, (InventoryRarityType)1, "", "", false, __instance._notificationArgumentsAux)).Cast<IPayload>(), (Action)null);
return false;
}
goto IL_0048;
IL_0048:
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ContinuousPlacement";
public const string PLUGIN_NAME = "ContinuousPlacement";
public const string PLUGIN_VERSION = "1.0.0";
}
}