using System;
using System.Collections;
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 CTNOriginals.ContentWarning.DevelopmentStartup.Patches;
using CTNOriginals.ContentWarning.DevelopmentStartup.Utilities;
using Microsoft.CodeAnalysis;
using On;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.ctnoriginals.cw.developmentstartup")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Skip all the useless startup menus and jump right into a game! Tool for developers.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+d70fc7925f2cc372ff65606e8cd9271618d9744f")]
[assembly: AssemblyProduct("DevelopmentStartup")]
[assembly: AssemblyTitle("com.ctnoriginals.cw.developmentstartup")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 CTNOriginals.ContentWarning.DevelopmentStartup
{
public class Config
{
public enum MapName
{
Random,
Factory,
Harbour,
Mines
}
public static ConfigFile Configurations = new ConfigFile(Paths.ConfigPath + "\\" + Plugin.PluginGUID + ".cfg", true);
public static ConfigEntry<string> SaveGameIndex;
public static ConfigEntry<bool> OldWorldModal;
public static ConfigEntry<MapName> MapToTeleportTo;
public void LoadFile()
{
SaveGameIndex = Configurations.Bind<string>("General", "SaveGameIndex", "1", "The number of the saved game to load on startup (a number between 1 and 3)");
OldWorldModal = Configurations.Bind<bool>("General", "OldWorldModal", true, "Whether or not to show a prompt to teleport to old world with a Camera when spawning in.");
MapToTeleportTo = Configurations.Bind<MapName>("General", "MapToTeleportTo", MapName.Random, "The map to teleport to when teleporting to the old world.");
CLogger.LogInfo("SaveGameIndex: " + SaveGameIndex.Value);
CLogger.LogInfo($"OldWorldModal: {OldWorldModal.Value}");
CLogger.LogInfo($"MapToTeleportTo: {MapToTeleportTo.Value}");
Configurations.Save();
}
}
[BepInPlugin("com.ctnoriginals.cw.developmentstartup", "DevelopmentStartup", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource ManualLog;
public static string PluginGUID = "com.ctnoriginals.cw.developmentstartup";
public static string PluginName = "DevelopmentStartup";
public static string PluginVersion = "1.1.0";
public static bool DebugMode = false;
public static bool OutputDebugLogs = false;
public static Config ConfigFile = new Config();
private void Awake()
{
ManualLog = ((BaseUnityPlugin)this).Logger;
ManualLog.LogInfo((object)("Plugin " + PluginName + " is loaded! Version: " + PluginVersion + " (" + (DebugMode ? "Debug" : "Release") + ")"));
ConfigFile.LoadFile();
MainMenuHandlerPatch.Patch();
}
}
}
namespace CTNOriginals.ContentWarning.DevelopmentStartup.Utilities
{
public static class CLogger
{
public static void Log(string message)
{
SendLog(message, "Log");
}
public static void LogInfo(string message)
{
SendLog(message, "LogInfo");
}
public static void LogError(string message)
{
SendLog(message, "LogError");
}
public static void LogWarning(string message)
{
SendLog(message, "LogWarning");
}
public static void LogDebug(string message)
{
SendLog(message, "LogDebug");
}
public static void LogFatal(string message)
{
SendLog(message, "LogFatal");
}
public static void LogMessage(string message)
{
SendLog(message, "LogMessage");
}
private static void SendLog(string message, string level = null)
{
if (!Plugin.DebugMode && (level == "LogDebug" || level == "LogInfo"))
{
return;
}
switch (level)
{
case "LogInfo":
Plugin.ManualLog.LogInfo((object)message);
return;
case "LogError":
Plugin.ManualLog.LogError((object)message);
return;
case "LogWarning":
Plugin.ManualLog.LogWarning((object)message);
return;
case "LogDebug":
Plugin.ManualLog.LogDebug((object)message);
return;
case "LogFatal":
Plugin.ManualLog.LogFatal((object)message);
return;
case "LogMessage":
Plugin.ManualLog.LogMessage((object)message);
return;
}
if (level != "Log")
{
Debug.Log((object)("[" + level + "]: " + message));
}
else
{
Debug.Log((object)message);
}
}
}
}
namespace CTNOriginals.ContentWarning.DevelopmentStartup.Patches
{
public class MainMenuHandlerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_CheckConnected <0>__CheckConnectedPatch;
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_SpawnLocalPlayer <>9__0_0;
public static Action <>9__4_2;
public static Action <>9__4_0;
public static Action <>9__4_1;
internal void <Patch>b__0_0(orig_SpawnLocalPlayer orig, SpawnHandler self, Spawns state)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, state);
if (PhotonNetwork.IsMasterClient && PhotonGameLobbyHandler.IsSurface && !(((object)PhotonGameLobbyHandler.CurrentObjective).GetType() != typeof(InviteFriendsObjective)) && Config.OldWorldModal.Value)
{
ShowOurModal();
}
}
internal void <ShowOurModal>b__4_0()
{
PlayerInventory val = default(PlayerInventory);
Item val2 = default(Item);
if (Player.localPlayer.TryGetInventory(ref val) && ItemDatabase.TryGetItemFromID((byte)1, ref val2))
{
InventorySlot val3 = default(InventorySlot);
if (!val.TryGetSlotWithItemType((ItemType)0, ref val3))
{
Item.EquipItem(val2);
}
RetrievableSingleton<PersistentObjectsHolder>.Instance.FindPersistantSurfaceObjects();
RetrievableResourceSingleton<TransitionHandler>.Instance.TransitionToBlack(2f, (Action)delegate
{
PhotonNetwork.LoadLevel(Config.MapToTeleportTo.Value switch
{
Config.MapName.Factory => "Factory",
Config.MapName.Harbour => "Harbour",
Config.MapName.Mines => "Mines",
_ => new List<string> { "FactoryScene", "MinesScene", "HarbourScene" }[SurfaceNetworkHandler.RoomStats.LevelToPlay],
});
}, 0f);
}
}
internal void <ShowOurModal>b__4_2()
{
PhotonNetwork.LoadLevel(Config.MapToTeleportTo.Value switch
{
Config.MapName.Factory => "Factory",
Config.MapName.Harbour => "Harbour",
Config.MapName.Mines => "Mines",
_ => new List<string> { "FactoryScene", "MinesScene", "HarbourScene" }[SurfaceNetworkHandler.RoomStats.LevelToPlay],
});
}
internal void <ShowOurModal>b__4_1()
{
Config.OldWorldModal.Value = false;
}
}
private static readonly string errorLogEnd = "\nPlease correct this in the config (" + Paths.ConfigPath + "\\" + Plugin.PluginGUID + ".cfg).";
private static bool hasConnected = false;
public static void Patch()
{
//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_001b: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
object obj = <>O.<0>__CheckConnectedPatch;
if (obj == null)
{
hook_CheckConnected val = CheckConnectedPatch;
<>O.<0>__CheckConnectedPatch = val;
obj = (object)val;
}
MainMenuHandler.CheckConnected += (hook_CheckConnected)obj;
object obj2 = <>c.<>9__0_0;
if (obj2 == null)
{
hook_SpawnLocalPlayer val2 = delegate(orig_SpawnLocalPlayer orig, SpawnHandler self, Spawns state)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, state);
if (PhotonNetwork.IsMasterClient && PhotonGameLobbyHandler.IsSurface && !(((object)PhotonGameLobbyHandler.CurrentObjective).GetType() != typeof(InviteFriendsObjective)) && Config.OldWorldModal.Value)
{
ShowOurModal();
}
};
<>c.<>9__0_0 = val2;
obj2 = (object)val2;
}
SpawnHandler.SpawnLocalPlayer += (hook_SpawnLocalPlayer)obj2;
}
private static IEnumerator CheckConnectedPatch(orig_CheckConnected orig, MainMenuHandler self)
{
IEnumerator origEnum = orig.Invoke(self);
while (origEnum.MoveNext())
{
yield return origEnum.Current;
}
if (hasConnected)
{
yield break;
}
hasConnected = true;
CLogger.LogInfo("MainMenuHandler.CheckConnectedPatch()");
if (int.TryParse(Config.SaveGameIndex.Value, out var result))
{
if ((result < 1 || result > 3) ? true : false)
{
CLogger.LogError($"Config.SaveGameIndex is set to {result} and is out of range (1 - 3), defaulting to 1.{errorLogEnd}");
result = 1;
}
self.Host(result - 1);
}
else
{
CLogger.LogError("Config.SaveGameIndex was not able to be parsed to an integer, value: (" + Config.SaveGameIndex.Value + ")." + errorLogEnd);
self.Host(0);
}
}
private static void ShowOurModal()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
ModalOption[] array = (ModalOption[])(object)new ModalOption[3]
{
new ModalOption("Yes", (Action)delegate
{
PlayerInventory val = default(PlayerInventory);
Item val2 = default(Item);
if (Player.localPlayer.TryGetInventory(ref val) && ItemDatabase.TryGetItemFromID((byte)1, ref val2))
{
InventorySlot val3 = default(InventorySlot);
if (!val.TryGetSlotWithItemType((ItemType)0, ref val3))
{
Item.EquipItem(val2);
}
RetrievableSingleton<PersistentObjectsHolder>.Instance.FindPersistantSurfaceObjects();
RetrievableResourceSingleton<TransitionHandler>.Instance.TransitionToBlack(2f, (Action)delegate
{
PhotonNetwork.LoadLevel(Config.MapToTeleportTo.Value switch
{
Config.MapName.Factory => "Factory",
Config.MapName.Harbour => "Harbour",
Config.MapName.Mines => "Mines",
_ => new List<string> { "FactoryScene", "MinesScene", "HarbourScene" }[SurfaceNetworkHandler.RoomStats.LevelToPlay],
});
}, 0f);
}
}),
new ModalOption("No", (Action)null),
new ModalOption("No\nDon't Show Again", (Action)delegate
{
Config.OldWorldModal.Value = false;
})
};
Modal.Show("Teleport to Old World", "Would you like to teleport to the old world? You will receive a camera, providing you don't already have one.", array, (Action)null);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}