using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnboundLib;
using UnboundLib.Networking;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[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.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 PlayerSizePatch
{
internal class ConfigMenu
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__1_0;
public static UnityAction<float> <>9__2_0;
internal void <RegisterMenu>b__1_0()
{
}
internal void <CreateMenu>b__2_0(float value)
{
CapPlayerSizePatch.Value = value;
}
}
public static ConfigEntry<float> CapPlayerSizePatch;
public static void RegisterMenu()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
CapPlayerSizePatch = ((BaseUnityPlugin)PlayerSizePatch.instance).Config.Bind<float>("Player Size Patch", "CapPlayerSizePatch", 10f, "Cap the player size to this value, 0 is no cap");
object obj = <>c.<>9__1_0;
if (obj == null)
{
UnityAction val = delegate
{
};
<>c.<>9__1_0 = val;
obj = (object)val;
}
Unbound.RegisterMenu("Player Size Patch", (UnityAction)obj, (Action<GameObject>)CreateMenu, (GameObject)null, false);
}
private static void CreateMenu(GameObject menu)
{
TextMeshProUGUI val = default(TextMeshProUGUI);
MenuHandler.CreateText("<b>Player Size Patch</b>", menu, ref val, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
AddBlank(menu, 50);
Slider val2 = default(Slider);
MenuHandler.CreateSlider("Cap Player Size", menu, 30, 0f, 25f, CapPlayerSizePatch.Value, (UnityAction<float>)delegate(float value)
{
CapPlayerSizePatch.Value = value;
}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
MenuHandler.CreateText("Tip: Set the value to 0 to disable the cap", menu, ref val, 20, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
}
private static void AddBlank(GameObject menu, int size = 30)
{
TextMeshProUGUI val = default(TextMeshProUGUI);
MenuHandler.CreateText(" ", menu, ref val, size, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.aalund13.rounds.playersizepatch", "Player Size Patch", "1.0.1")]
[BepInProcess("Rounds.exe")]
public class PlayerSizePatch : BaseUnityPlugin
{
private const string modId = "com.aalund13.rounds.playersizepatch";
internal const string modName = "Player Size Patch";
internal const string modInitials = "PSP";
internal static PlayerSizePatch instance;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
instance = this;
new Harmony("com.aalund13.rounds.playersizepatch").PatchAll();
Unbound.RegisterHandshake("com.aalund13.rounds.playersizepatch", (Action)HandshakeCompleted);
Debug.Log("Player Size Patch loaded!");
}
private void Start()
{
ConfigMenu.RegisterMenu();
Debug.Log("Player Size Patch started!");
}
private static void HandshakeCompleted()
{
if (PhotonNetwork.IsMasterClient || PhotonNetwork.OfflineMode)
{
NetworkingManager.RPC(typeof(PlayerSizePatch), "SyncSettings", new object[1] { ConfigMenu.CapPlayerSizePatch.Value });
}
}
[UnboundRPC]
private static void SyncSettings(float capPlayerSize)
{
ConfigMenu.CapPlayerSizePatch.Value = capPlayerSize;
}
}
}
namespace PlayerSizePatch.Patches
{
[HarmonyPatch(typeof(CharacterStatModifiers), "ConfigureMassAndSize")]
internal class ConfigureMassAndSizePatch
{
private static void Postfix(CharacterStatModifiers __instance)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
CharacterData val = (CharacterData)Traverse.Create((object)__instance).Field("data").GetValue();
float num = (float)Traverse.Create((object)__instance).Field("sizeMultiplier").GetValue();
((Component)__instance).transform.localScale = Vector3.one * Mathf.Clamp(1.2f * Mathf.Pow(val.maxHealth / 100f * 1.2f, 0.2f) * num, 0.3f, ConfigMenu.CapPlayerSizePatch.Value);
float num2 = (float)ExtensionMethods.GetFieldValue((object)val.playerVel, "mass");
ExtensionMethods.SetFieldValue((object)val.playerVel, "mass", (object)Mathf.Clamp(num2, 0.3f, 1E+32f));
}
}
}