using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JustLandAlready")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Slowpokes begone")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4630844fcff623b3afca91e59c5b1859684dd76e")]
[assembly: AssemblyProduct("JustLandAlready")]
[assembly: AssemblyTitle("JustLandAlready")]
[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 JustLandAlready
{
public class Config
{
public ConfigEntry<float> GenerateMapMaxWaitTime { get; } = file.Bind<float>("Timeouts", "GenerateMapMaxWaitTime", 30f, "The maximum time to wait for other players to generate the dungeon");
public ConfigEntry<float> RevivePlayersMaxWaitTime { get; } = file.Bind<float>("Timeouts", "RevivePlayersMaxWaitTime", 5f, "The maximum time to wait for other players to be revived until allowing the ship to land again");
public Config(ConfigFile file)
{
}
}
public static class Logger
{
private static ManualLogSource logSource;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetSource(ManualLogSource logger)
{
logSource = logger;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Log(object message)
{
logSource.LogInfo(message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogInfo(object message)
{
logSource.LogInfo(message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(object message)
{
logSource.LogWarning(message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogError(object message)
{
logSource.LogError(message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogDebug(object message)
{
logSource.LogDebug(message);
}
}
[HarmonyPatch]
internal static class JustLandAlreadyPatches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> PlayersFiredGameOverPatch(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(StartOfRound), "playersRevived"), (string)null)
}).Advance(5).SetOperandAndAdvance((object)AccessTools.Constructor(typeof(WaitUntilRevived), new Type[1] { typeof(Func<bool>) }, false))
.InstructionEnumeration();
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> EndOfGamePatch(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(StartOfRound), "playersRevived"), (string)null)
}).Advance(5).SetOperandAndAdvance((object)AccessTools.Constructor(typeof(WaitUntilRevived), new Type[1] { typeof(Func<bool>) }, false))
.InstructionEnumeration();
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> LoadNewLevelWaitPatch(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: 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_0027: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Players finished generating the new floor", (string)null)
}).Advance(-10).SetOperandAndAdvance((object)AccessTools.Constructor(typeof(WaitUntilGenerated), new Type[1] { typeof(Func<bool>) }, false))
.InstructionEnumeration();
}
}
[BepInPlugin("io.daxcess.justlandalready", "JustLandAlready", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "io.daxcess.justlandalready";
private const string PLUGIN_NAME = "JustLandAlready";
private const string PLUGIN_VERSION = "1.0.0";
public static Config Config { get; private set; }
private void Awake()
{
Logger.SetSource(((BaseUnityPlugin)this).Logger);
Config = new Config(((BaseUnityPlugin)this).Config);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"I don't wanna wait!");
}
}
public class WaitUntilTimeout : CustomYieldInstruction
{
[CompilerGenerated]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private Func<bool> <predicate>P;
[CompilerGenerated]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private float <timeout>P;
private readonly float timeStarted;
public override bool keepWaiting => !<predicate>P() && Time.realtimeSinceStartup - timeStarted < <timeout>P;
public WaitUntilTimeout(Func<bool> predicate, float timeout)
{
<predicate>P = predicate;
<timeout>P = timeout;
timeStarted = Time.realtimeSinceStartup;
((CustomYieldInstruction)this)..ctor();
}
}
public class WaitUntilGenerated : WaitUntilTimeout
{
public WaitUntilGenerated(Func<bool> predicate)
: base(predicate, Plugin.Config.GenerateMapMaxWaitTime.Value)
{
}
}
public class WaitUntilRevived : WaitUntilTimeout
{
public WaitUntilRevived(Func<bool> predicate)
: base(predicate, Plugin.Config.RevivePlayersMaxWaitTime.Value)
{
}
}
}