using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PurrNet;
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("On-Together_sodaRush")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("On-Together_sodaRush")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8661e440-e445-4ce1-8d5f-6508a32eaa2e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace On_Together_sodaRush;
[BepInPlugin("wan7.OnTogether.BetterMove", "On-Together BetterMove", "1.0.0")]
public class SodaRushPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("wan7.OnTogether.BetterMove").PatchAll();
Log.LogInfo((object)"[BetterMove] Loaded. Ctrl = Sneak | Shift = Sprint");
}
}
internal static class SodaRushState
{
public static bool IsCtrlPopsicle;
}
[HarmonyPatch(typeof(PlayerMovementController), "Update")]
public static class Patch_SodaRush_Input
{
private static void Prefix(PlayerMovementController __instance)
{
if (!((Object)(object)__instance == (Object)null) && ((NetworkIdentity)__instance).isOwner)
{
bool flag = (Object)(object)MonoSingleton<InputManager>.I != (Object)null && MonoSingleton<InputManager>.I.IsShiftKey;
bool flag2 = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
__instance.IsTurbo = flag;
SodaRushState.IsCtrlPopsicle = flag2 && !flag;
}
}
}
[HarmonyPatch(typeof(PlayerAnimationController), "SetWalk")]
public static class Patch_PopsicleWalk_AnimInject
{
private static void Prefix(PlayerAnimationController __instance)
{
if (((NetworkIdentity)__instance).isOwner && SodaRushState.IsCtrlPopsicle)
{
object? value = AccessTools.Field(typeof(PlayerAnimationController), "_playerFXController").GetValue(__instance);
PlayerFXController val = (PlayerFXController)((value is PlayerFXController) ? value : null);
if (!((Object)(object)val == (Object)null))
{
val.IsPopsicleDouble = true;
val.IsFreeze = false;
SodaRushPlugin.Log.LogDebug((object)"[SodaRush] PopsicleWalk injected");
}
}
}
private static void Postfix(PlayerAnimationController __instance)
{
if (((NetworkIdentity)__instance).isOwner && SodaRushState.IsCtrlPopsicle)
{
object? value = AccessTools.Field(typeof(PlayerAnimationController), "_playerFXController").GetValue(__instance);
PlayerFXController val = (PlayerFXController)((value is PlayerFXController) ? value : null);
if (!((Object)(object)val == (Object)null))
{
val.IsPopsicleDouble = false;
val.IsFreeze = false;
}
}
}
}
[HarmonyPatch(typeof(PlayerFXController), "SetPopsicle")]
public static class Patch_BlockFakePopsicleOnly
{
private static bool Prefix()
{
if (SodaRushState.IsCtrlPopsicle)
{
SodaRushPlugin.Log.LogDebug((object)"[SodaRush] Blocked fake popsicle FX");
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PlayerMovementController), "MovePlayer")]
public static class Patch_PopsicleSpeed_MovePlayer
{
private static void Prefix(PlayerMovementController __instance)
{
if (!((Object)(object)__instance == (Object)null) && ((NetworkIdentity)__instance).isOwner && SodaRushState.IsCtrlPopsicle)
{
PlayerFXController component = ((Component)__instance).GetComponent<PlayerFXController>();
if (!((Object)(object)component == (Object)null))
{
component.IsPopsicleDouble = true;
component.IsFreeze = false;
}
}
}
private static void Postfix(PlayerMovementController __instance)
{
if (!((Object)(object)__instance == (Object)null) && ((NetworkIdentity)__instance).isOwner && SodaRushState.IsCtrlPopsicle)
{
PlayerFXController component = ((Component)__instance).GetComponent<PlayerFXController>();
if (!((Object)(object)component == (Object)null))
{
component.IsPopsicleDouble = false;
component.IsFreeze = false;
}
}
}
}