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 ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.atomic.betterkick")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3+e40ab8ee284de233aabb55682340699b689b177c")]
[assembly: AssemblyProduct("com.atomic.betterkick")]
[assembly: AssemblyTitle("BetterKick")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.3.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BetterKick
{
[BepInPlugin("com.atomic.betterkick", "BetterKick", "0.1.3")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <FadeAlertUI>d__10 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CanvasGroup group;
public GameObject fullCanvas;
private float <elapsed>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeAlertUI>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<elapsed>5__2 = 0f;
goto IL_0073;
case 1:
<>1__state = -1;
goto IL_0073;
case 2:
<>1__state = -1;
<elapsed>5__2 = 0f;
break;
case 3:
{
<>1__state = -1;
break;
}
IL_0073:
if (<elapsed>5__2 < 0.3f)
{
<elapsed>5__2 += Time.deltaTime;
group.alpha = <elapsed>5__2 / 0.3f;
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = (object)new WaitForSeconds(2.5f);
<>1__state = 2;
return true;
}
if (<elapsed>5__2 < 0.3f)
{
<elapsed>5__2 += Time.deltaTime;
group.alpha = 1f - <elapsed>5__2 / 0.3f;
<>2__current = null;
<>1__state = 3;
return true;
}
Object.Destroy((Object)(object)fullCanvas);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static ConfigEntry<KeyCode> kickKeybind;
public const string MOD_KEY = "BetterKick_Installed";
public const string Id = "com.atomic.betterkick";
internal static ManualLogSource Log { get; private set; }
public static string Name => "BetterKick";
public static string Version => "0.1.3";
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("com.atomic.betterkick");
val.PatchAll();
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
kickKeybind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Kick Keybind", (KeyCode)118, "The keybind for kicking.");
}
public static void SetModStatus()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0025: Expected O, but got Unknown
if (PhotonNetwork.InRoom && PhotonNetwork.LocalPlayer != null)
{
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"BetterKick_Installed", (object)true);
Hashtable val2 = val;
PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
Log.LogInfo((object)"Sent BetterKick status to the room.");
}
}
public static bool AllPlayersHaveMod()
{
if (!PhotonNetwork.InRoom)
{
return true;
}
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player val in playerList)
{
if (!val.IsLocal && (val.CustomProperties == null || !((Dictionary<object, object>)(object)val.CustomProperties).ContainsKey((object)"BetterKick_Installed")))
{
Log.LogWarning((object)("Player " + val.NickName + " is missing the mod."));
return false;
}
}
return true;
}
public static void ShowWarning(string message)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
GUIManager val = Object.FindFirstObjectByType<GUIManager>();
if (!((Object)(object)val == (Object)null))
{
GameObject val2 = new GameObject("BetterKick_Canvas");
Canvas val3 = val2.AddComponent<Canvas>();
val3.renderMode = (RenderMode)0;
val3.sortingOrder = 999;
CanvasScaler val4 = val2.AddComponent<CanvasScaler>();
val4.uiScaleMode = (ScaleMode)1;
val4.referenceResolution = new Vector2(1920f, 1080f);
GameObject val5 = new GameObject("BetterKickContainer");
val5.transform.SetParent(val2.transform, false);
CanvasGroup group = val5.AddComponent<CanvasGroup>();
RectTransform val6 = val5.AddComponent<RectTransform>();
val6.anchorMin = new Vector2(0.5f, 0f);
val6.anchorMax = new Vector2(0.5f, 0f);
val6.pivot = new Vector2(0.5f, 0f);
val6.anchoredPosition = new Vector2(0f, 70f);
val6.sizeDelta = new Vector2(800f, 100f);
GameObject val7 = new GameObject("WarningText");
val7.transform.SetParent(val5.transform, false);
TextMeshProUGUI val8 = val7.AddComponent<TextMeshProUGUI>();
((TMP_Text)val8).text = message.ToUpper();
((TMP_Text)val8).font = ((TMP_Text)val.heroDayText).font;
((TMP_Text)val8).fontSize = 32f;
((TMP_Text)val8).alignment = (TextAlignmentOptions)514;
((Graphic)val8).color = new Color(1f, 0.3f, 0.3f);
((MonoBehaviour)val).StartCoroutine(FadeAlertUI(group, val2));
}
}
[IteratorStateMachine(typeof(<FadeAlertUI>d__10))]
private static IEnumerator FadeAlertUI(CanvasGroup group, GameObject fullCanvas)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeAlertUI>d__10(0)
{
group = group,
fullCanvas = fullCanvas
};
}
}
[HarmonyPatch]
public static class BetterKickPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(MonoBehaviourPunCallbacks), "OnJoinedRoom")]
public static void OnJoinedRoom()
{
Plugin.SetModStatus();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MonoBehaviourPunCallbacks), "OnPlayerEnteredRoom")]
public static void OnPlayerEnteredRoom(Player newPlayer)
{
Plugin.SetModStatus();
Plugin.Log.LogInfo((object)(newPlayer.NickName + " joined. Re-syncing mod status."));
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CharacterGrabbing), "Update")]
public static void Character_Update_Postfix(CharacterGrabbing __instance)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.character.IsLocal || GUIManager.instance.windowBlockingInput)
{
return;
}
if (Input.GetKeyDown(Plugin.kickKeybind.Value) && !__instance.character.data.isKicking)
{
if (Plugin.AllPlayersHaveMod())
{
if (((MonoBehaviourPun)__instance.character).photonView.IsMine)
{
Character character = __instance.character;
if (!character.data.isClimbingAnything && character.data.isGrounded && !character.OutOfRegularStamina())
{
character.data.isKicking = true;
__instance._kickTime = 0f;
((MonoBehaviourPun)character).photonView.RPC("RPCA_Kick", (RpcTarget)0, Array.Empty<object>());
}
}
}
else
{
Plugin.ShowWarning("Cannot kick: Someone is missing the BetterKick mod.");
}
}
if (!__instance.isKickMode && __instance.character.data.isKicking)
{
__instance._kickTime += Time.deltaTime;
if (__instance._kickTime > 1f)
{
__instance.character.data.isKicking = false;
__instance._kickTime = 0f;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}