using System;
using System.Collections;
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.Logging;
using CW_Test_Mod.Keybinds;
using CW_Test_Mod.Patches;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour.HookGen;
using On;
using UnityEngine;
using Zorro.Core;
using Zorro.Settings;
[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")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ElectricSteve.cwtestmod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d96075996231be7912e56b91b6c8e71640f4a399")]
[assembly: AssemblyProduct("CW Test Mod")]
[assembly: AssemblyTitle("ElectricSteve.cwtestmod")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 CW_Test_Mod
{
[ContentWarningPlugin("ElectricSteve.cwtestmod", "1.0.0", false)]
[BepInPlugin("ElectricSteve.cwtestmod", "CW Test Mod", "1.0.0")]
public class CW_Test_Mod : BaseUnityPlugin
{
public static bool JustKilledPlayer;
public static CW_Test_Mod Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
HookAll();
Logger.LogInfo((object)"ElectricSteve.cwtestmod v1.0.0 has loaded!");
}
internal static void HookAll()
{
Logger.LogDebug((object)"Hooking...");
GlobalInputHandlerPatch.init();
Logger.LogDebug((object)"Finished Hooking!");
}
internal static void UnhookAll()
{
Logger.LogDebug((object)"Unhooking...");
HookEndpointManager.RemoveAllOwnedBy((object)Assembly.GetExecutingAssembly());
Logger.LogDebug((object)"Finished Unhooking!");
}
private void Update()
{
if (GlobalInputHandlerPatch.KillKey.GetKeyDown() && SurfaceNetworkHandler.HasStarted)
{
JustKilledPlayer = true;
Logger.LogDebug((object)"Killing Player");
Player.localPlayer.CallDie();
if (PhotonGameLobbyHandler.IsSurface)
{
((MonoBehaviour)this).StartCoroutine(WaitAndRevive(2f));
}
}
}
private IEnumerator WaitAndRevive(float waitTime)
{
yield return (object)new WaitForSeconds(waitTime);
RetrievableResourceSingleton<TransitionHandler>.Instance.TransitionToBlack(0f, (Action)delegate
{
//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)
Player.localPlayer.Teleport(((Component)Hospital.instance).transform.position, Vector3.back);
Player.localPlayer.data.fallTime = 0f;
RetrievableResourceSingleton<TransitionHandler>.Instance.FadeOut((Action)delegate
{
}, 1f);
}, 0f);
yield return (object)new WaitForSeconds(1f);
Logger.LogDebug((object)"Reviving player...");
Player.localPlayer.CallRevive();
Logger.LogDebug((object)"Healing player...");
float healAmount = PlayerData.maxHealth - Player.localPlayer.data.health;
Player.localPlayer.CallHeal(healAmount);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ElectricSteve.cwtestmod";
public const string PLUGIN_NAME = "CW Test Mod";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CW_Test_Mod.Keybinds
{
public class KillKeybindSetting : KeyCodeSetting, IExposedSetting
{
protected override KeyCode GetDefaultKey()
{
return (KeyCode)107;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)2;
}
public string GetDisplayName()
{
return "Kill Key";
}
}
}
namespace CW_Test_Mod.Patches
{
public class GlobalInputHandlerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnCreated <0>__GlobalInputHandlerOnOnCreated;
public static hook_ctor <1>__SettingsHandlerInit;
public static hook_CheckForAllDead <2>__PhotonGameLobbyHandlerOnCheckForAllDead;
}
public static InputKey KillKey = new InputKey();
internal static void init()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
object obj = <>O.<0>__GlobalInputHandlerOnOnCreated;
if (obj == null)
{
hook_OnCreated val = GlobalInputHandlerOnOnCreated;
<>O.<0>__GlobalInputHandlerOnOnCreated = val;
obj = (object)val;
}
GlobalInputHandler.OnCreated += (hook_OnCreated)obj;
object obj2 = <>O.<1>__SettingsHandlerInit;
if (obj2 == null)
{
hook_ctor val2 = SettingsHandlerInit;
<>O.<1>__SettingsHandlerInit = val2;
obj2 = (object)val2;
}
SettingsHandler.ctor += (hook_ctor)obj2;
object obj3 = <>O.<2>__PhotonGameLobbyHandlerOnCheckForAllDead;
if (obj3 == null)
{
hook_CheckForAllDead val3 = PhotonGameLobbyHandlerOnCheckForAllDead;
<>O.<2>__PhotonGameLobbyHandlerOnCheckForAllDead = val3;
obj3 = (object)val3;
}
PhotonGameLobbyHandler.CheckForAllDead += (hook_CheckForAllDead)obj3;
}
private static void PhotonGameLobbyHandlerOnCheckForAllDead(orig_CheckForAllDead orig, PhotonGameLobbyHandler self)
{
if (CW_Test_Mod.JustKilledPlayer & PhotonGameLobbyHandler.IsSurface)
{
CW_Test_Mod.Logger.LogDebug((object)"Player just killed, returning");
CW_Test_Mod.JustKilledPlayer = false;
}
else
{
CW_Test_Mod.Logger.LogDebug((object)"Check for all dead");
orig.Invoke(self);
}
}
private static void GlobalInputHandlerOnOnCreated(orig_OnCreated orig, GlobalInputHandler self)
{
orig.Invoke(self);
KillKey.SetKeybind((KeyCodeSetting)(object)GameHandler.Instance.SettingsHandler.GetSetting<KillKeybindSetting>());
}
private static void SettingsHandlerInit(orig_ctor orig, SettingsHandler self)
{
orig.Invoke(self);
KillKeybindSetting killKeybindSetting = new KillKeybindSetting();
((Setting)killKeybindSetting).Load(self._settingsSaveLoad);
((Setting)killKeybindSetting).ApplyValue();
self.settings.Add((Setting)(object)killKeybindSetting);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}