using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
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("FreeCamMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FreeCamMod")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("93ce73f8-73d3-4730-a780-7f261f657e54")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FreeCamMod;
[BepInPlugin("com.appwal.gkfr.miscmods", "Walrus GKFR Mods", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
private Harmony h;
public static bool run = true;
private void Awake()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
FileLog.Reset();
h = new Harmony("com.appwal.gkfr.miscmods");
h.PatchAll(Assembly.GetExecutingAssembly());
}
private void Update()
{
if (Input.GetKeyDown((KeyCode)286))
{
run = !run;
}
}
private void OnDestroy()
{
h.UnpatchSelf();
}
}
[HarmonyPatch(typeof(RcVehiclePhysic), "Init")]
public class AttachFreecam
{
public static int index = -1;
public static FreeCam friKamm = null;
public static void Postfix(RcVehiclePhysic __instance)
{
StatsModifiers component = ((Component)__instance).GetComponent<StatsModifiers>();
if (component.Driver.IsLocal && !component.Driver.IsAi)
{
index = component.Driver.Id;
friKamm = ((Component)__instance).gameObject.AddComponent<FreeCam>();
friKamm.body = __instance.GetVehicleBody();
friKamm.driver = component.Driver;
}
}
}
[HarmonyPatch(typeof(Kart), "Respawn")]
public class TurnOffRespawn
{
public static bool Prefix(Kart __instance)
{
if (Plugin.run && ((Component)__instance).GetComponentInParent<Driver>().LocalHumanId == 0)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(RcRespawnChecker), "CheckRespawn")]
public class TurnOffRespawnCheck
{
public static bool Prefix(RcVehicle pVehicle, ref bool __result)
{
if (!Plugin.run || ((Component)pVehicle).GetComponentInParent<Driver>().LocalHumanId != 0)
{
return true;
}
__result = false;
return false;
}
}
[HarmonyPatch(typeof(GkNetTransformSync), "OnPhotonSerializeView")]
public class RemoveKartServer
{
public static bool Prefix(GkNetTransformSync __instance, PhotonStream stream, PhotonMessageInfo info, ComponentToSynchronize ___m_componentToSynchronize, Rigidbody ___m_rigidBody, Transform ___m_transform, Vector3 ___m_velocity)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((Component)__instance).gameObject.GetComponent<Driver>() == (Object)null)
{
return true;
}
if (!Plugin.run || ((Component)__instance).gameObject.GetComponent<Driver>().LocalHumanId != 0 || !((Behaviour)__instance).enabled || !stream.IsWriting)
{
return true;
}
if ((int)___m_componentToSynchronize == 1)
{
stream.SendNext((object)new Vector3(300f, 300f, 300f));
stream.SendNext((object)___m_rigidBody.velocity);
stream.SendNext((object)___m_rigidBody.rotation);
return false;
}
AccessTools.Method(typeof(GkNetTransformSync), "UpdatePreviousPositionAndVelocityFromTransform", (Type[])null, (Type[])null).Invoke(__instance, new object[0]);
stream.SendNext((object)new Vector3(300f, 300f, 300f));
stream.SendNext((object)___m_velocity);
stream.SendNext((object)___m_transform.rotation);
return false;
}
}
[HarmonyPatch(typeof(GkNetTransformSync), "MoveTowardsFuturePosition")]
internal class SmoothFollower
{
private static bool Prefix(GkNetTransformSync __instance, double interpolationTime, Transform ___m_transform, Vector3 ___m_velocity, Rigidbody ___m_rigidBody, int ___m_sceneryLayerMask, ComponentToSynchronize ___m_componentToSynchronize)
{
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Invalid comparison between Unknown and I4
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((Component)__instance).GetComponentInParent<Driver>() == (Object)null)
{
return true;
}
Driver componentInParent = ((Component)__instance).GetComponentInParent<Driver>();
if (componentInParent.LocalHumanId == 0 || (!GkNetMgr.Instance.IsMasterClient && AttachFreecam.friKamm.following != componentInParent.Id - 1) || (GkNetMgr.Instance.IsMasterClient && !componentInParent.IsAi && AttachFreecam.friKamm.following != componentInParent.LocalId))
{
return true;
}
float value = GamePreferences.NetNewSyncExtrapolationTime.Value;
double num = interpolationTime + (double)value;
float num2 = Time.fixedDeltaTime / value;
object obj = AccessTools.Method(typeof(GkNetTransformSync), "ComputeState", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { num });
IEnumerable<FieldInfo> runtimeFields = obj.GetType().GetRuntimeFields();
double num3 = (double)runtimeFields.ElementAt(0).GetValue(obj);
Vector3 val = (Vector3)runtimeFields.ElementAt(1).GetValue(obj);
Vector3 val2 = (Vector3)runtimeFields.ElementAt(2).GetValue(obj);
Quaternion val3 = (Quaternion)runtimeFields.ElementAt(3).GetValue(obj);
Vector3 val4 = Vector3.Lerp(___m_transform.position, val, num2);
Quaternion rotation = Quaternion.Slerp(___m_transform.rotation, val3, num2);
Vector3 val5 = Vector3.Lerp(___m_velocity, val2, num2);
Vector3 position = Vector3.Lerp(((Component)AttachFreecam.friKamm.body).transform.position, val, num2);
Quaternion rotation2 = Quaternion.Slerp(((Component)AttachFreecam.friKamm.body).transform.rotation, val3, num2);
((Component)AttachFreecam.friKamm.body).transform.position = position;
((Component)AttachFreecam.friKamm.body).transform.rotation = rotation2;
AttachFreecam.friKamm.body.position = position;
AttachFreecam.friKamm.body.rotation = rotation2;
AttachFreecam.friKamm.body.velocity = Vector3.Lerp(AttachFreecam.friKamm.body.velocity, val2, num2);
if ((Object)(object)___m_rigidBody != (Object)null)
{
Vector3 val6 = val4 - ___m_transform.position;
RaycastHit val7 = default(RaycastHit);
if (___m_rigidBody.SweepTest(val6, ref val7, ((Vector3)(ref val6)).magnitude, (QueryTriggerInteraction)1) && ((1 << ((Component)((RaycastHit)(ref val7)).collider).gameObject.layer) & ___m_sceneryLayerMask) != 0)
{
Vector3 normal = ((RaycastHit)(ref val7)).normal;
float num4 = 0f - Vector3.Dot(val6, normal);
val4 += normal * num4;
}
}
if ((int)___m_componentToSynchronize == 1)
{
___m_rigidBody.position = val4;
___m_rigidBody.rotation = rotation;
___m_rigidBody.velocity = val5;
}
else
{
___m_transform.position = val4;
___m_transform.rotation = rotation;
}
___m_velocity = val5;
return false;
}
}
[HarmonyPatch(typeof(KartFxMgr), "Update")]
public class ClientRemoveLocalKartFX
{
private static bool Prefix(KartFxMgr __instance, ref Kart ___m_pKart, ref List<PipeFx> ___m_smokePipes)
{
if ((Object)(object)___m_pKart == (Object)null)
{
return false;
}
if (___m_pKart.Driver.LocalHumanId == 0 && Plugin.run)
{
AccessTools.Method(typeof(KartFxMgr), "StopPipesFx", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { ___m_smokePipes });
__instance.StopAllFX();
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PlayerBuilder), "Build")]
public class ClientRemoveLocalKart
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilg)
{
List<CodeInstruction> instrs = new List<CodeInstruction>(instructions);
CodeMatcher matcher = new CodeMatcher(instructions, (ILGenerator)null);
matcher.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "GetKartObject"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "Instantiate"), (string)null)
});
int gameobject1 = (instrs[matcher.Pos + 1].operand as LocalBuilder).LocalIndex;
FileLog.Log(gameobject1.ToString());
matcher.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldstr && (string)i.operand == "Kart_FX"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Newobj && ((ConstructorInfo)i.operand).Name == AccessTools.Constructor(typeof(GameObject), (Type[])null, false).Name && ((ConstructorInfo)i.operand).ReflectedType == typeof(GameObject)), (string)null)
});
int gameobject2 = (instrs[matcher.Pos + 1].operand as LocalBuilder).LocalIndex;
FileLog.Log(gameobject2.ToString());
matcher.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "GetCharacterObject"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "Instantiate"), (string)null)
});
int gameobject3 = (instrs[matcher.Pos + 1].operand as LocalBuilder).LocalIndex;
FileLog.Log(gameobject3.ToString());
Label label = ilg.DefineLabel();
LocalBuilder localvector = ilg.DeclareLocal(typeof(Vector3));
bool flag2 = false;
for (int j = 0; j < instrs.Count; j++)
{
CodeInstruction instruction = instrs[j];
yield return instruction;
FileLog.Log(((object)instruction).ToString());
int num;
if (instruction.opcode == OpCodes.Stloc_S)
{
LocalBuilder obj = instruction.operand as LocalBuilder;
num = ((obj != null && obj.LocalIndex == 13) ? 1 : 0);
}
else
{
num = 0;
}
if (num != 0)
{
flag2 = true;
FileLog.Log("Injection point found in PlayerBuilder.Build");
yield return new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Plugin), "run"));
yield return new CodeInstruction(OpCodes.Brfalse_S, (object)label);
yield return new CodeInstruction(OpCodes.Ldarg, (object)7);
yield return new CodeInstruction(OpCodes.Brtrue, (object)label);
yield return new CodeInstruction(OpCodes.Ldloca_S, (object)localvector.LocalIndex);
yield return new CodeInstruction(OpCodes.Ldc_R4, (object)0f);
yield return new CodeInstruction(OpCodes.Ldc_R4, (object)0f);
yield return new CodeInstruction(OpCodes.Ldc_R4, (object)0f);
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Constructor(typeof(Vector3), new Type[3]
{
typeof(float),
typeof(float),
typeof(float)
}, false));
yield return new CodeInstruction(OpCodes.Ldloc, (object)gameobject1);
yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(GameObject), "transform"));
yield return new CodeInstruction(OpCodes.Ldloc, (object)localvector);
yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Transform), "localScale"));
yield return new CodeInstruction(OpCodes.Ldloc, (object)gameobject2);
yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(GameObject), "transform"));
yield return new CodeInstruction(OpCodes.Ldloc, (object)localvector);
yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Transform), "localScale"));
yield return new CodeInstruction(OpCodes.Ldloc, (object)gameobject3);
yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(GameObject), "transform"));
yield return new CodeInstruction(OpCodes.Ldloc, (object)localvector);
yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Transform), "localScale"));
yield return new CodeInstruction(OpCodes.Nop, (object)null)
{
labels = { label }
};
}
}
if (object.Equals(false, flag2))
{
throw new ArgumentException("Injection point not found in PlayerBuilder.Build or F5 clicked");
}
}
}
[HarmonyPatch(typeof(Kart), "FixedUpdate")]
internal class RemoveSomeHUD
{
private static FieldRef<MenuHDPlayerRaceHUD, HUDBonusHD> hudbonus = (FieldRef<MenuHDPlayerRaceHUD, HUDBonusHD>)(object)AccessTools.FieldRefAccess<HUDBonusHD>(typeof(MenuHDPlayerRaceHUD), "m_hudBonus");
private static FieldRef<MenuHDPlayerRaceHUD, HUDLapCounterHD> hudlap = (FieldRef<MenuHDPlayerRaceHUD, HUDLapCounterHD>)(object)AccessTools.FieldRefAccess<HUDLapCounterHD>(typeof(MenuHDPlayerRaceHUD), "m_hudLapCounter");
private static FieldRef<MenuHDPlayerRaceHUD, HUDPositionHD> hudpos = (FieldRef<MenuHDPlayerRaceHUD, HUDPositionHD>)(object)AccessTools.FieldRefAccess<HUDPositionHD>(typeof(MenuHDPlayerRaceHUD), "m_hudPosition");
private static FieldRef<MenuHDPlayerRaceHUD, HUDRadarHD> hudrad = (FieldRef<MenuHDPlayerRaceHUD, HUDRadarHD>)(object)AccessTools.FieldRefAccess<HUDRadarHD>(typeof(MenuHDPlayerRaceHUD), "m_hudRadar");
private static void Postfix(Kart __instance)
{
if (Plugin.run && __instance.Driver.LocalHumanId == 0)
{
__instance.Hud.Position.WrongWay = false;
((Component)hudbonus.Invoke(__instance.Hud)).gameObject.SetActive(false);
((Component)hudlap.Invoke(__instance.Hud)).gameObject.SetActive(false);
((Component)hudpos.Invoke(__instance.Hud)).gameObject.SetActive(false);
}
}
}
[HarmonyPatch(typeof(CamStateRear), "Update")]
public class RearCamIsInfactTheFrontCam
{
private static void Postfix(CamStateRear __instance, ref Transform ___m_rearTarget, float ___m_distance, float ___m_height, float ___m_leanAngle)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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)
if (Plugin.run && FreeCam.friKamera)
{
___m_rearTarget.localPosition = new Vector3(0f, 0.75f, 0f - (___m_distance + 0.5f));
___m_rearTarget.localRotation = Quaternion.Euler(0f, 0f, 0f);
}
else if (Plugin.run && !FreeCam.friKamera)
{
___m_rearTarget.localPosition = new Vector3(0f, 1f, 0f - (___m_distance + 2f));
___m_rearTarget.localRotation = Quaternion.Euler(0f, 0f, 0f);
}
else
{
___m_rearTarget.localPosition = new Vector3(0f, ___m_height, 0f - ___m_distance);
___m_rearTarget.localRotation = Quaternion.Euler(0f - ___m_leanAngle, 180f, 0f);
}
}
}
[HarmonyPatch(typeof(RcVehicle), "FixedUpdate")]
public class PermaRearCam
{
private static FieldRef<RcVehiclePhysic, StatsModifiers> statmod = (FieldRef<RcVehiclePhysic, StatsModifiers>)(object)AccessTools.FieldRefAccess<StatsModifiers>(typeof(RcVehiclePhysic), "statsModifiers");
private static void Postfix(RcVehicle __instance, RcVehiclePhysic ___m_pVehiclePhysic)
{
int localHumanId = statmod.Invoke(___m_pVehiclePhysic).Driver.LocalHumanId;
if (Plugin.run && localHumanId == 0 && FreeCam.friKamera)
{
((Component)__instance.AttachedCamera).GetComponent<CameraBase>().SwitchCamera((ECamState)1, (ECamState)7);
}
else if (Plugin.run && localHumanId == 0)
{
((Component)__instance.AttachedCamera).GetComponent<CameraBase>().SwitchCamera((ECamState)0, (ECamState)7);
}
}
}
[HarmonyPatch(typeof(HUDMiniMapHD), "Update")]
public class AlwaysShowNames
{
private static bool Prefix(ref bool ___m_showNickname)
{
___m_showNickname = true;
return true;
}
}
public class FreeCam : MonoBehaviour
{
private static FieldRef<CameraBase, Transform> camtransform = (FieldRef<CameraBase, Transform>)(object)AccessTools.FieldRefAccess<Transform>(typeof(CameraBase), "m_pTransform");
public float movementSpeed = 45f;
public Driver[] drivers;
public float fastMovementSpeed = 75f;
public Rigidbody body;
public Driver driver;
public int following = -1;
public float freeLookSensitivity = 2f;
public float zoomSensitivity = 10f;
public float fastZoomSensitivity = 20f;
private bool looking = false;
private bool running = false;
public static bool freeCamLockOn = false;
public Driver freeCamLockOnTarget = null;
public static bool followLockOn = false;
public static bool friKamera = true;
private void Awake()
{
}
private void Update()
{
//IL_0055: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
//IL_0414: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: Unknown result type (might be due to invalid IL or missing references)
//IL_0445: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Unknown result type (might be due to invalid IL or missing references)
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_0478: Unknown result type (might be due to invalid IL or missing references)
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
//IL_04da: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0504: Unknown result type (might be due to invalid IL or missing references)
//IL_0506: Unknown result type (might be due to invalid IL or missing references)
//IL_050b: Unknown result type (might be due to invalid IL or missing references)
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Unknown result type (might be due to invalid IL or missing references)
//IL_0525: Unknown result type (might be due to invalid IL or missing references)
//IL_053e: Unknown result type (might be due to invalid IL or missing references)
//IL_0543: Unknown result type (might be due to invalid IL or missing references)
//IL_0547: Unknown result type (might be due to invalid IL or missing references)
//IL_056b: Unknown result type (might be due to invalid IL or missing references)
//IL_0570: Unknown result type (might be due to invalid IL or missing references)
//IL_0574: Unknown result type (might be due to invalid IL or missing references)
//IL_0594: Unknown result type (might be due to invalid IL or missing references)
//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0600: Unknown result type (might be due to invalid IL or missing references)
//IL_0607: Unknown result type (might be due to invalid IL or missing references)
//IL_060c: Unknown result type (might be due to invalid IL or missing references)
//IL_0611: Unknown result type (might be due to invalid IL or missing references)
//IL_067d: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.run && !running)
{
return;
}
running = true;
body.detectCollisions = false;
body.useGravity = false;
body.isKinematic = false;
body.velocity = Vector3.zero;
body.angularVelocity = Vector3.zero;
driver.SetInvulnerabilityActive(true);
bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
float num = (flag ? fastMovementSpeed : movementSpeed);
Vector3 position = ((Component)this).transform.position;
if (drivers == null)
{
drivers = (Driver[])(object)new Driver[Singleton<GameManager>.Instance.GameMode.DriversCount];
if (GkNetMgr.Instance.IsDisconnectedOrMasterClient)
{
foreach (Driver value in Singleton<GameManager>.Instance.GameMode.Drivers.Values)
{
drivers[value.LocalId] = value;
}
}
else
{
foreach (Driver value2 in Singleton<GameManager>.Instance.GameMode.Drivers.Values)
{
drivers[value2.Id - 1] = value2;
}
}
}
if (Input.GetKeyDown((KeyCode)49))
{
following = 0;
}
else if (Input.GetKeyDown((KeyCode)50))
{
following = 1;
}
else if (Input.GetKeyDown((KeyCode)51))
{
following = 2;
}
else if (Input.GetKeyDown((KeyCode)52))
{
following = 3;
}
else if (Input.GetKeyDown((KeyCode)53))
{
following = 4;
}
else if (Input.GetKeyDown((KeyCode)54))
{
following = 5;
}
else if (Input.GetKeyDown((KeyCode)55))
{
following = 6;
}
else if (Input.GetKeyDown((KeyCode)56))
{
following = 7;
}
else if (Input.GetKeyDown((KeyCode)57) || Input.GetKeyDown((KeyCode)48))
{
following = -1;
}
if ((following >= 0 && drivers[following].LocalHumanId == 0) || following < 0)
{
friKamera = true;
}
else
{
friKamera = false;
}
checkMouse();
position = updateLocalFollow(position);
if (Input.GetKey((KeyCode)97) || Input.GetKey((KeyCode)276))
{
position += -((Component)this).transform.right * num * Time.deltaTime;
}
if (Input.GetKey((KeyCode)100) || Input.GetKey((KeyCode)275))
{
position += ((Component)this).transform.right * num * Time.deltaTime;
}
Vector3 val;
if (Input.GetKey((KeyCode)119) || Input.GetKey((KeyCode)273))
{
Vector3 forward = ((Component)this).transform.forward;
val = Vector3.ProjectOnPlane(forward, Vector3.up);
forward = ((Vector3)(ref val)).normalized;
position += forward * num * Time.deltaTime;
}
if (Input.GetKey((KeyCode)115) || Input.GetKey((KeyCode)274))
{
Vector3 forward2 = ((Component)this).transform.forward;
val = Vector3.ProjectOnPlane(forward2, Vector3.up);
forward2 = ((Vector3)(ref val)).normalized;
position += -forward2 * num * Time.deltaTime;
}
if (Input.GetKey((KeyCode)113))
{
position += ((Component)this).transform.up * num * Time.deltaTime;
}
if (Input.GetKey((KeyCode)101))
{
position += -((Component)this).transform.up * num * Time.deltaTime;
}
if (Input.GetKey((KeyCode)114) || Input.GetKey((KeyCode)280) || Input.GetKey((KeyCode)32))
{
position += Vector3.up * num * Time.deltaTime;
}
if (Input.GetKey((KeyCode)102) || Input.GetKey((KeyCode)281))
{
position += -Vector3.up * num * Time.deltaTime;
}
if (looking)
{
Quaternion rotation = body.rotation;
float num2 = ((Quaternion)(ref rotation)).eulerAngles.y + Input.GetAxisRaw("Mouse X") * freeLookSensitivity;
rotation = body.rotation;
float num3 = ((Quaternion)(ref rotation)).eulerAngles.x - Input.GetAxisRaw("Mouse Y") * freeLookSensitivity;
Quaternion rotation2 = default(Quaternion);
((Quaternion)(ref rotation2)).eulerAngles = new Vector3(num3, num2, 0f);
body.rotation = rotation2;
}
float axis = Input.GetAxis("Mouse ScrollWheel");
if (axis != 0f)
{
float num4 = (flag ? fastZoomSensitivity : zoomSensitivity);
position += ((Component)this).transform.forward * axis * num4;
}
if (Input.GetKeyDown((KeyCode)324))
{
StartLooking();
}
else if (Input.GetKeyUp((KeyCode)324))
{
StopLooking();
}
if (following == -1 || drivers[following].LocalHumanId == 0)
{
((Component)body).transform.position = position;
}
}
public Vector3 updateLocalFollow(Vector3 vector)
{
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00a9: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
if (following > -1 && following < drivers.Length && GkNetMgr.Instance.IsDisconnectedOrMasterClient && drivers[following].IsAi)
{
vector = ((Component)drivers[following]).transform.position;
Quaternion rotation = ((Component)drivers[following]).transform.rotation;
Vector3 localVelocity = ((RcVehicle)drivers[following].Kart).GetLocalVelocity();
body.MovePosition(Vector3.Lerp(body.position, vector, Time.deltaTime * 3.5f));
body.rotation = Quaternion.Lerp(body.rotation, rotation, Time.deltaTime * 3.5f);
body.velocity = Vector3.Lerp(body.velocity, localVelocity, Time.deltaTime * 3.5f);
}
return vector;
}
public void checkMouse()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: 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)
if (Input.GetKeyDown((KeyCode)323) && !freeCamLockOn)
{
Driver val = null;
float num = 10000000f;
for (int i = 0; i < drivers.Length; i++)
{
if (drivers[i].LocalHumanId != 0)
{
Vector3 val2 = ((Component)drivers[i]).gameObject.transform.position - ((Component)driver).gameObject.transform.position;
float magnitude = ((Vector3)(ref val2)).magnitude;
val2 = ((Vector3)(ref val2)).normalized;
Vector3 forward = ((Component)driver).gameObject.transform.forward;
float num2 = Vector3.Angle(forward, val2);
if (num2 < num && magnitude < 100f)
{
num = num2;
val = drivers[i];
}
}
}
if ((Object)(object)val != (Object)null)
{
freeCamLockOnTarget = val;
freeCamLockOn = true;
}
}
else if (Input.GetKeyDown((KeyCode)323) && freeCamLockOn)
{
freeCamLockOn = false;
freeCamLockOnTarget = null;
}
else if (Input.GetKeyDown((KeyCode)325) && !followLockOn)
{
int num3 = -1;
float num4 = 10000000f;
for (int j = 0; j < drivers.Length; j++)
{
if (drivers[j].LocalHumanId != 0)
{
Vector3 val3 = ((Component)drivers[j]).gameObject.transform.position - ((Component)driver).gameObject.transform.position;
float magnitude2 = ((Vector3)(ref val3)).magnitude;
val3 = ((Vector3)(ref val3)).normalized;
Vector3 forward2 = ((Component)driver).gameObject.transform.forward;
float num5 = Vector3.Angle(forward2, val3);
if (num5 < num4 && magnitude2 < 100f)
{
num4 = num5;
num3 = j;
}
}
}
if (num3 != -1)
{
following = num3;
followLockOn = true;
friKamera = false;
}
}
else if (Input.GetKeyDown((KeyCode)325) && followLockOn)
{
followLockOn = false;
following = -1;
friKamera = true;
}
if (freeCamLockOn && (Object)(object)freeCamLockOnTarget != (Object)null)
{
Quaternion val4 = Quaternion.LookRotation(((Component)freeCamLockOnTarget).transform.position - ((Component)driver).transform.position);
((Component)driver).transform.rotation = Quaternion.Lerp(((Component)driver).transform.rotation, val4, Time.deltaTime * 3f);
}
}
private void OnDisable()
{
StopLooking();
}
public void StartLooking()
{
looking = true;
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)1;
}
public void StopLooking()
{
looking = false;
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
}
}