using System;
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 CG;
using CG.Game;
using CG.Ship.Hull;
using CG.Space;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;
[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: AssemblyCompany("FasterShards")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FasterShards")]
[assembly: AssemblyTitle("FasterShards")]
[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 FasterShards
{
internal static class MyPluginInfo
{
internal const string PLUGIN_GUID = "id107.fastershards";
internal const string PLUGIN_NAME = "FasterShards";
internal const string PLUGIN_VERSION = "0.1.0";
}
[BepInPlugin("id107.fastershards", "FasterShards", "0.1.0")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BepinPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Configs.Load(this);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "id107.fastershards");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.fastershards is loaded!");
}
}
[HarmonyPatch(typeof(CarryablesSocket))]
internal class CarryablesSocketPatch
{
[HarmonyPrefix]
[HarmonyPatch("SetUseExternalSocketClear")]
private static void SetUseExternalSocketClear(CarryablesSocket __instance, ref float preDestroyTimer, ref float postDestroyTimer)
{
if (((Object)__instance).name == "GalaxyMapTerminal_SingleSocket")
{
preDestroyTimer = Mathf.Max(Configs.PreDestroyDelayConfig.Value, 0.01f);
postDestroyTimer = Mathf.Max(Configs.PostDestroyDelayConfig.Value, 0f);
}
}
public static void UpdateSocketClearTimers(float preDestroyTimer, float postDestroyTimer)
{
ClientGame current = ClientGame.Current;
object obj;
if (current == null)
{
obj = null;
}
else
{
AbstractPlayerControlledShip playerShip = current.PlayerShip;
if (playerShip == null)
{
obj = null;
}
else
{
GameObject gameObject = ((AbstractCloneStarObject)playerShip).GameObject;
obj = ((gameObject == null) ? null : gameObject.GetComponentsInChildren<CarryablesSocket>()?.FirstOrDefault((Func<CarryablesSocket, bool>)((CarryablesSocket socket) => ((Object)socket).name == "GalaxyMapTerminal_SingleSocket"))?.customSocketClearOperation);
}
}
SocketClearOperation val = (SocketClearOperation)obj;
if (val != null)
{
val.preDestroyTimer = Mathf.Max(preDestroyTimer, 0.01f);
val.postDestroyTime = Mathf.Max(postDestroyTimer, 0f);
}
}
}
internal class Configs
{
internal static ConfigEntry<float> PreDestroyDelayConfig;
internal static ConfigEntry<float> PostDestroyDelayConfig;
internal static void Load(BepinPlugin plugin)
{
PreDestroyDelayConfig = ((BaseUnityPlugin)plugin).Config.Bind<float>("FasterShards", "PreDestroyDelay", 4.5f, (ConfigDescription)null);
PreDestroyDelayConfig.SettingChanged += delegate
{
if (PreDestroyDelayConfig.Value < 0.01f)
{
PreDestroyDelayConfig.Value = 0.01f;
}
};
PostDestroyDelayConfig = ((BaseUnityPlugin)plugin).Config.Bind<float>("FasterShards", "PostDestroyDelay", 0f, (ConfigDescription)null);
PostDestroyDelayConfig.SettingChanged += delegate
{
if (PostDestroyDelayConfig.Value < 0f)
{
PostDestroyDelayConfig.Value = 0f;
}
};
}
}
internal class GUI : ModSettingsMenu
{
public override string Name()
{
return "Faster Shards";
}
public override void Draw()
{
if (GUITools.DrawTextField<float>("Delay before destroying shard", ref Configs.PreDestroyDelayConfig, 80f))
{
CarryablesSocketPatch.UpdateSocketClearTimers(Configs.PreDestroyDelayConfig.Value, Configs.PostDestroyDelayConfig.Value);
}
if (GUITools.DrawTextField<float>("Delay after destroying shard", ref Configs.PostDestroyDelayConfig, 80f))
{
CarryablesSocketPatch.UpdateSocketClearTimers(Configs.PreDestroyDelayConfig.Value, Configs.PostDestroyDelayConfig.Value);
}
}
}
public class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)4;
public override string Author => "18107";
public override string Description => "Makes data shards process faster";
}
}