using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PlatformTypeChanger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlatformTypeChanger")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d7483a83-5296-446a-bdc6-9c7d9b349e37")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PlatformTypeChanger;
[BepInPlugin("com.000diggity000.PlatformTypeChanger", "Platform Type Changer", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
internal static ConfigEntry<float> PlatformTypeConfig;
internal static ConfigEntry<bool> CustomFeaturesConfig;
internal static ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "PlatformTypeConfig.cfg"), true);
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"PlatformTypeChanger Loaded");
Harmony val = new Harmony("com.000diggity000.PlatformTypeChanger");
val.PatchAll(typeof(Patches));
MethodInfo methodInfo = AccessTools.Method(typeof(StickyRoundedRectangle), "Awake", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), "Awake_Platform_Plug", (Type[])null, (Type[])null);
val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
PlatformTypeConfig = config.Bind<float>("Platform Type Changer", "Platform Type", 0f, "0 for Default, 1 for Grass, 2 for Ice, 3 for Snow, 4 for Space, 5 for Slime. Disclaimer: Some types may not do anything, but that is not my fault, because Zapray did not implmenent features for the platformtypes.");
CustomFeaturesConfig = config.Bind<bool>("Platform Type Changer", "Custom Features", false, "I have made some custom features for these PlatformTypes, set true or false to enable or disable.");
config.Save();
}
}
public class Patches
{
[HarmonyPatch(typeof(PlayerPhysics), "Move")]
[HarmonyPrefix]
public static void PatchMove(PlayerPhysics __instance, ref StickyRoundedRectangle ___attachedGround, ref Fix ___maxSpeed, ref Fix ___PlatformSlipperyness01)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Invalid comparison between Unknown and I4
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Invalid comparison between Unknown and I4
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)___attachedGround != (Object)null && Plugin.CustomFeaturesConfig.Value)
{
if ((int)___attachedGround.platformType == 4)
{
__instance.jumpStrength = (Fix)25L;
___maxSpeed = (Fix)13L;
}
else if ((int)___attachedGround.platformType == 3)
{
__instance.jumpStrength = (Fix)35L;
__instance.gravity_modifier = (Fix)0.5f;
}
else if ((int)___attachedGround.platformType == 1)
{
__instance.jumpStrength = (Fix)28L;
___PlatformSlipperyness01 = (Fix)0.87f;
}
}
}
public static bool Awake_Platform_Plug(StickyRoundedRectangle __instance)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.PlatformTypeConfig.Value == 0f)
{
return true;
}
if (Plugin.PlatformTypeConfig.Value == 1f)
{
__instance.platformType = (PlatformType)0;
}
else if (Plugin.PlatformTypeConfig.Value == 2f)
{
__instance.platformType = (PlatformType)2;
}
else if (Plugin.PlatformTypeConfig.Value == 3f)
{
__instance.platformType = (PlatformType)1;
}
else if (Plugin.PlatformTypeConfig.Value == 4f)
{
__instance.platformType = (PlatformType)3;
}
else if (Plugin.PlatformTypeConfig.Value == 5f)
{
__instance.platformType = (PlatformType)4;
}
else
{
Logger.CreateLogSource("Platform_Type_Changer").LogError((object)"Invalid Type");
}
return true;
}
}