using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Timers;
using BepInEx;
using BepInEx.Logging;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("TootFloot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+465374bb01fe27fa657ebac4dc3237982ca675c6")]
[assembly: AssemblyProduct("TootFloot")]
[assembly: AssemblyTitle("TootFloot")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FrogtownRepoMods;
[BepInPlugin("tootfloot.frogtown.me", "Toot Floot", "0.1")]
public class TootFloot : BaseUnityPlugin
{
private class PatchPhysGrabberUpdate
{
[HarmonyPatch(typeof(PhysGrabber), "Update")]
[HarmonyPostfix]
private static void Update(PhysGrabber __instance)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)UpdateRunner.instance) || (Object)(object)__instance != (Object)(object)UpdateRunner.instance.trackedGrabber)
{
return;
}
float num = Time.time - UpdateRunner.instance.lastGrabRelease;
if (num < 0.05f)
{
PlayerAvatar playerAvatarScript = PlayerController.instance.playerAvatarScript;
PhysGrabber trackedGrabber = UpdateRunner.instance.trackedGrabber;
Transform transform = ((Component)trackedGrabber.physGrabPointPuller).transform;
if (Object.op_Implicit((Object)(object)transform))
{
transform.position = ((Component)playerAvatarScript).transform.position + UpdateRunner.instance.pullerOffset;
trackedGrabber.physGrabPointPullerPosition = transform.position;
}
Transform transform2 = ((Component)trackedGrabber.physGrabPointPlane).transform;
if (Object.op_Implicit((Object)(object)transform2))
{
transform2.position = ((Component)playerAvatarScript).transform.position + UpdateRunner.instance.planeOffset;
}
}
else if (num < 0.45f)
{
PlayerAvatar playerAvatarScript2 = PlayerController.instance.playerAvatarScript;
PhysGrabber trackedGrabber2 = UpdateRunner.instance.trackedGrabber;
Transform transform3 = ((Component)trackedGrabber2.physGrabPointPuller).transform;
if (Object.op_Implicit((Object)(object)transform3))
{
transform3.localPosition = Vector3.forward * 0.5f;
trackedGrabber2.physGrabPointPullerPosition = transform3.position;
}
Transform transform4 = ((Component)trackedGrabber2.physGrabPointPlane).transform;
if (Object.op_Implicit((Object)(object)transform4))
{
transform4.localPosition = Vector3.forward * 0.5f;
}
}
}
}
private class UpdateRunner : MonoBehaviour
{
public static UpdateRunner instance;
private float lastTimeChange;
public bool playing;
public bool tilted;
public float storedXRot;
public PhysGrabber trackedGrabber;
public Vector3 pullerOffset;
public Vector3 planeOffset;
public float lastGrabRelease;
private void Awake()
{
L.LogInfo((object)"Awake");
instance = this;
}
private void OnDestroy()
{
L.LogInfo((object)"OnDestroy");
instance = null;
}
private void Update()
{
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!SemiFunc.IsMultiplayer())
{
return;
}
CameraAim cameraAim = PlayerController.instance.cameraAim;
PlayerAvatar playerAvatarScript = PlayerController.instance.playerAvatarScript;
float num = -1f;
KeyCode[] array = new KeyCode[11];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
KeyCode[] array2 = (KeyCode[])(object)array;
float[] array3 = new float[11]
{
80f, 56.3f, 45.7f, 37.16f, 28.06f, 20.18f, 11.08f, 2.44f, 353.64f, 342.77f,
330f
};
bool flag = false;
trackedGrabber = playerAvatarScript.physGrabber;
if (Object.op_Implicit((Object)(object)trackedGrabber.grabbedObjectTransform) && ((Object)trackedGrabber.grabbedObjectTransform).name == "Valuable Ocarina(Clone)")
{
for (int i = 0; i < array2.Length; i++)
{
if (Input.GetKeyDown(array2[i]))
{
num = array3[i];
}
if (Input.GetKey(array2[i]))
{
flag = true;
if (num == -1f)
{
num = array3[i];
}
}
}
}
Quaternion rotation;
if (num > 0f)
{
if (!playing)
{
Transform transform = ((Component)instance.trackedGrabber.physGrabPointPuller).transform;
pullerOffset = transform.position - ((Component)playerAvatarScript).transform.position;
Transform transform2 = ((Component)instance.trackedGrabber.physGrabPointPlane).transform;
planeOffset = transform2.position - ((Component)playerAvatarScript).transform.position;
}
if (!tilted)
{
rotation = ((Component)cameraAim).transform.rotation;
storedXRot = ((Quaternion)(ref rotation)).eulerAngles.x;
}
tilted = true;
lastGrabRelease = Time.time;
Transform transform3 = ((Component)cameraAim).transform;
float num2 = num;
rotation = ((Component)cameraAim).transform.rotation;
float y = ((Quaternion)(ref rotation)).eulerAngles.y;
rotation = ((Component)cameraAim).transform.rotation;
transform3.rotation = Quaternion.Euler(num2, y, ((Quaternion)(ref rotation)).eulerAngles.z);
MethodInfo method = ((object)cameraAim).GetType().GetMethod("ResetPlayerAim", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(cameraAim, new object[1] { ((Component)cameraAim).transform.rotation });
if (!playing && (double)(Time.time - lastTimeChange) > 0.2)
{
playing = true;
playerAvatarScript.ChatMessageSend("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", false);
lastTimeChange = Time.time;
}
}
if (!flag && playing && (double)(Time.time - lastTimeChange) > 0.2)
{
playing = false;
playerAvatarScript.ChatMessageSend(".", false);
lastTimeChange = Time.time;
}
if (!flag && tilted)
{
tilted = false;
Transform transform4 = ((Component)cameraAim).transform;
float num3 = storedXRot;
rotation = ((Component)cameraAim).transform.rotation;
float y2 = ((Quaternion)(ref rotation)).eulerAngles.y;
rotation = ((Component)cameraAim).transform.rotation;
transform4.rotation = Quaternion.Euler(num3, y2, ((Quaternion)(ref rotation)).eulerAngles.z);
MethodInfo method2 = ((object)cameraAim).GetType().GetMethod("ResetPlayerAim", BindingFlags.Instance | BindingFlags.NonPublic);
method2.Invoke(cameraAim, new object[1] { ((Component)cameraAim).transform.rotation });
}
}
catch (Exception)
{
}
}
}
public static TootFloot instance;
public const string PLUGIN_GUID = "tootfloot.frogtown.me";
public const string PLUGIN_NAME = "Toot Floot";
public const string PLUGIN_VERSION = "0.1";
private static ManualLogSource L;
private static DateTime _lastRegenAttempt;
[Obsolete]
public static void RegenInstance(object sender, ElapsedEventArgs e)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
if (!(_lastRegenAttempt.AddSeconds(5.0) > DateTime.Now))
{
_lastRegenAttempt = DateTime.Now;
if (!Object.op_Implicit((Object)(object)UpdateRunner.instance))
{
GameObject val = new GameObject("UpdateRunner");
val.AddComponent<UpdateRunner>();
L.LogInfo((object)"Regenerated UpdateRunner");
}
}
}
public static void StartRegenThread()
{
Timer timer = new Timer(100.0);
timer.Elapsed += RegenInstance;
timer.AutoReset = true;
timer.Enabled = true;
}
private void Awake()
{
if (!((Object)(object)instance != (Object)null))
{
L = ((BaseUnityPlugin)this).Logger;
instance = this;
StartRegenThread();
Harmony.CreateAndPatchAll(typeof(PatchPhysGrabberUpdate), (string)null);
}
}
}