using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using DCDMapLoader;
using HarmonyLib;
using MelonLoader;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(MapLoader), "DCDMapLoader", "1.0.8", "RusticVoid", null)]
[assembly: MelonGame("Joseph Cook", "Ducks Can Drive")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DCDMapLoader")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+151d4fa7f6cf3d3a3b0fc79e7f75a2a9c84a9b86")]
[assembly: AssemblyProduct("DCDMapLoader")]
[assembly: AssemblyTitle("DCDMapLoader")]
[assembly: AssemblyVersion("1.0.0.0")]
public class TriggerHandler : MonoBehaviour
{
public event Action<GameObject> OnTriggered;
private void OnTriggerEnter(Collider other)
{
this.OnTriggered?.Invoke(((Component)other).gameObject);
}
}
namespace DCDMapLoader;
public class InfoData
{
public string Name;
public string Desc;
public string Author;
public bool isCity;
}
public class customTrack
{
public string name;
public Texture2D icon;
public string mapPath;
public string desc;
public bool isCity;
public customTrack(string name, string mapPath, string desc, Texture2D icon = null, bool isCity = false)
{
this.name = name;
this.mapPath = mapPath;
this.icon = icon;
this.desc = desc;
this.isCity = isCity;
}
}
public class customTrackLoader
{
public static int currentTrackId;
public static List<customTrack> customTracks = new List<customTrack>();
public static void LoadRace(int MapID)
{
if (PhotonNetwork.InRoom)
{
MelonLogger.Msg("Loading " + customTracks[MapID].name + "!");
currentTrackId = MapID;
PhotonNetwork.LoadLevel(Path.GetFileNameWithoutExtension(customTracks[MapID].mapPath));
}
}
public static void ToLastCheckPoint(GameObject other)
{
//IL_007a: 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_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_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_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
if (!((Component)other.GetComponent<Car>()).GetComponent<PhotonView>().IsMine)
{
return;
}
GameObject val = GameObject.Find("CheckpointManager");
int num = 0;
num = ((other.GetComponent<Car>().furthestCheckpointReached != 0) ? (other.GetComponent<Car>().furthestCheckpointReached - 1) : (val.GetComponent<CheckpointManager>().checkpoints.Length - 1));
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(0f, 20f, 0f);
Rigidbody[] componentsInChildren = other.GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody val3 in componentsInChildren)
{
val3.velocity = Vector3.zero;
val3.angularVelocity = Vector3.zero;
val3.isKinematic = true;
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).buildIndex == 3)
{
val3.position = val.GetComponent<CheckpointManager>().checkpoints[num].GetComponent<Transform>().position + val2;
}
else
{
activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).buildIndex > 3)
{
val3.position = val.GetComponent<CheckpointManager>().checkpoints[num].GetComponent<Transform>().position + val2;
}
}
val3.isKinematic = false;
}
other.GetComponent<Transform>().position = val.GetComponent<CheckpointManager>().checkpoints[num].GetComponent<Transform>().position + val2;
}
public static void InitCustomMaps()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
string[] directories = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory + "/Maps/", "*", SearchOption.TopDirectoryOnly);
for (int i = 0; i < directories.Length; i++)
{
string[] files = Directory.GetFiles(directories[i], "*", SearchOption.TopDirectoryOnly);
Texture2D val = new Texture2D(2, 2);
AssetBundle val2 = null;
InfoData infoData = null;
string[] array = files;
foreach (string text in array)
{
if (Path.GetExtension(text) == "")
{
val2 = AssetBundle.LoadFromFile(text);
}
else if (Path.GetExtension(text) == ".json")
{
infoData = JsonUtility.FromJson<InfoData>(File.ReadAllText(text));
}
else
{
ImageConversion.LoadImage(val, File.ReadAllBytes(text));
}
}
if ((Object)(object)val2 == (Object)null)
{
MelonLogger.Msg("Failed to load AssetBundle!");
MelonLogger.Msg("Is map already loaded?");
continue;
}
if (val2.GetAllScenePaths().Length == 0)
{
MelonLogger.Msg("No scenes found in AssetBundle!");
continue;
}
array = val2.GetAllScenePaths();
foreach (string text2 in array)
{
customTrack item = new customTrack(Path.GetFileNameWithoutExtension(text2), text2, "No Desc", val);
if (infoData != null)
{
item = new customTrack(infoData.Name + " By: " + infoData.Author, text2, infoData.Desc, val, infoData.isCity);
}
customTracks.Add(item);
}
}
if (customTracks.Count <= 0)
{
MelonLogger.Msg("No Custom Maps Found!");
return;
}
MelonLogger.Msg("Found Custom Maps: " + string.Join(", ", customTracks.Select((customTrack track) => track.name)));
}
public static void initCustomMapObjects(int buildIndex, string sceneName)
{
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: 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)
if (customTracks.FirstOrDefault((customTrack ct) => Path.GetFileNameWithoutExtension(ct.mapPath) == sceneName) == null || !PhotonNetwork.InRoom)
{
return;
}
GameObject[] array = Object.FindObjectsOfType<GameObject>();
MelonLogger.Msg("Initializing Spawns and Triggers!");
List<Transform> list = new List<Transform>();
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (((Object)val).name == "Spawn" || ((Object)val).name == "spawn")
{
list.Add(val.transform);
}
if ((((Object)val).name == "ToLastCheckpoint" || ((Object)val).name == "toLastCheckpoint") && (Object)(object)val.GetComponent<Collider>() != (Object)null)
{
val.AddComponent<TriggerHandler>().OnTriggered += ToLastCheckPoint;
}
}
if (list.Count == 0)
{
MelonLogger.Msg("INVALID MAP NO SPAWNS FOUND!");
MelonLogger.Msg("SPAWN SET TO 0,5,0 THIS MIGHT BREAK THINGS!");
Transform transform = new GameObject().transform;
transform.position = new Vector3(0f, 5f, 0f);
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
for (int j = 0; j < PhotonNetwork.CurrentRoom.PlayerCount; j++)
{
list.Add(transform);
}
}
Transform[] array3 = list.ToArray();
MelonLogger.Msg("Initializing Player!");
int num = PhotonNetwork.LocalPlayer.ActorNumber - 1;
if (buildIndex > 3)
{
PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "PlayerController"), array3[num].position, array3[num].rotation, (byte)0, (object[])null);
return;
}
GameObject val2 = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "PlayerController"), array3[num].position, array3[num].rotation, (byte)0, (object[])null);
Garage[] array4 = Object.FindObjectsOfType<Garage>();
for (int k = 0; k < array4.Length; k++)
{
array4[k].localPlayer = val2.GetComponent<Car>();
}
}
}
public class customTrackMenu
{
private static Vector2 scrollPosition = Vector2.zero;
public static bool CustomMapsOnly = false;
public static bool BaseGameMapsOnly = false;
public static void menu()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_005f: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00cb: 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_0188: 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_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
int num = 75;
int num2 = 365;
int num3 = 500;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor((float)(Screen.width - num2) - 20f, 20f);
GUI.Box(new Rect(val.x, val.y, (float)num2, (float)num3), "Custom Tracks");
int num4 = customTrackLoader.customTracks.Count * num + 10;
scrollPosition = GUI.BeginScrollView(new Rect(val.x, val.y + 25f, (float)num2, (float)(num3 - 55)), scrollPosition, new Rect(0f, 0f, (float)(num2 - 20), (float)num4));
Rect val2 = default(Rect);
Rect val3 = default(Rect);
for (int i = 0; i < customTrackLoader.customTracks.Count; i++)
{
customTrack customTrack2 = customTrackLoader.customTracks[i];
((Rect)(ref val2))..ctor(10f, (float)(num * i), (float)(num2 - 20), (float)num);
if (GUI.Button(val2, ""))
{
customTrackLoader.LoadRace(i);
}
((Rect)(ref val3))..ctor(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, (float)num, (float)num);
GUI.DrawTexture(val3, (Texture)(object)customTrack2.icon);
GUI.Label(new Rect(((Rect)(ref val2)).x + ((Rect)(ref val3)).width + 2f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width - (float)num, (float)num), customTrack2.name + "\n" + customTrack2.desc);
}
GUI.EndScrollView();
if (GUI.Button(new Rect(val.x + 10f, (float)(num3 - 10), 100f, 20f), "Refesh Maps"))
{
customTrackLoader.InitCustomMaps();
}
Vector2 val4 = default(Vector2);
((Vector2)(ref val4))..ctor(val.x, (float)(num3 + 20));
GUI.Box(new Rect(val4.x, val4.y, (float)num2, 70f), "Custom Tracks Options");
CustomMapsOnly = GUI.Toggle(new Rect(val4.x + 10f, val4.y + 20f, 200f, 20f), CustomMapsOnly, "Custom Maps Only");
if (CustomMapsOnly)
{
BaseGameMapsOnly = false;
}
BaseGameMapsOnly = GUI.Toggle(new Rect(val4.x + 10f, val4.y + 40f, 200f, 20f), BaseGameMapsOnly, "Base Game Maps Only");
if (BaseGameMapsOnly)
{
CustomMapsOnly = false;
}
}
}
[HarmonyPatch(typeof(Launcher), "OnJoinedRoom")]
public class Patch_lobbyCreated
{
private static void Postfix()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Lobby" && PhotonNetwork.IsMasterClient)
{
((MelonEventBase<LemonAction>)(object)MelonEvents.OnGUI).Subscribe(new LemonAction(customTrackMenu.menu), 100, false);
}
}
}
[HarmonyPatch(typeof(Launcher), "LeaveRoom")]
public class Patch_lobbyLeft
{
private static void Postfix()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
((MelonEventBase<LemonAction>)(object)MelonEvents.OnGUI).Unsubscribe(new LemonAction(customTrackMenu.menu));
}
}
public class MapLoader : MelonMod
{
public override void OnInitializeMelon()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
MelonLogger.Msg("DCDMapLoader loaded!");
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Maps");
if (!Directory.Exists(path))
{
MelonLogger.Msg("No maps folder found! Creating one now.");
Directory.CreateDirectory(path);
}
customTrackLoader.InitCustomMaps();
new Harmony("com.rusticvoid.dcdmaploader").PatchAll();
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
((MelonEventBase<LemonAction>)(object)MelonEvents.OnGUI).Unsubscribe(new LemonAction(customTrackMenu.menu));
customTrackLoader.initCustomMapObjects(buildIndex, sceneName);
}
public override void OnUpdate()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0063: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Lobby" && PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && !PhotonNetwork.CurrentRoom.IsVisible)
{
((MelonEventBase<LemonAction>)(object)MelonEvents.OnGUI).Subscribe(new LemonAction(customTrackMenu.menu), 100, false);
}
else
{
((MelonEventBase<LemonAction>)(object)MelonEvents.OnGUI).Unsubscribe(new LemonAction(customTrackMenu.menu));
}
}
}
[HarmonyPatch(typeof(RoundTimer), "LoadRace")]
public class Patch_LoadRace
{
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public string[] baseTracks;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_1
{
public int index;
public <>c__DisplayClass1_0 CS$<>8__locals1;
internal void <CustomLoadRace>b__0()
{
PhotonNetwork.LoadLevel(CS$<>8__locals1.baseTracks[index]);
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_2
{
public int index;
internal void <CustomLoadRace>b__1()
{
customTrackLoader.LoadRace(index);
}
}
[CompilerGenerated]
private sealed class <CustomLoadRace>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public RoundTimer instance;
private <>c__DisplayClass1_0 <>8__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CustomLoadRace>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass1_0();
AccessTools.Field(typeof(RoundTimer), "loadingRace").SetValue(instance, true);
<>2__current = (object)new WaitForSeconds(2.5f);
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
FieldInfo fieldInfo = AccessTools.Field(typeof(RoundTimer), "tracks");
<>8__1.baseTracks = (string[])fieldInfo.GetValue(instance);
List<Action> list = new List<Action>();
if (!customTrackMenu.CustomMapsOnly)
{
for (int i = 0; i < <>8__1.baseTracks.Length; i++)
{
list.Add(new <>c__DisplayClass1_1
{
CS$<>8__locals1 = <>8__1,
index = i
}.<CustomLoadRace>b__0);
}
}
if (!customTrackMenu.BaseGameMapsOnly)
{
for (int j = 0; j < customTrackLoader.customTracks.Count; j++)
{
<>c__DisplayClass1_2 CS$<>8__locals0 = new <>c__DisplayClass1_2
{
index = j
};
if (!customTrackLoader.customTracks[j].isCity)
{
list.Add(delegate
{
customTrackLoader.LoadRace(CS$<>8__locals0.index);
});
}
}
}
if (list.Count == 0)
{
return false;
}
int index = Random.Range(0, list.Count);
list[index]();
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static bool Prefix(RoundTimer __instance, ref IEnumerator __result)
{
if (customTrackMenu.BaseGameMapsOnly)
{
return true;
}
__result = CustomLoadRace(__instance);
return false;
}
[IteratorStateMachine(typeof(<CustomLoadRace>d__1))]
private static IEnumerator CustomLoadRace(RoundTimer instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CustomLoadRace>d__1(0)
{
instance = instance
};
}
}
[HarmonyPatch(typeof(Car), "Start")]
public class Patch_CarStart
{
private static bool Prefix(Car __instance)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (!customTrackLoader.customTracks[customTrackLoader.currentTrackId].isCity)
{
return true;
}
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != Path.GetFileNameWithoutExtension(customTrackLoader.customTracks[customTrackLoader.currentTrackId].mapPath))
{
return true;
}
CustomStart(__instance);
return false;
}
private static void CustomStart(Car __instance)
{
object? value = AccessTools.Field(typeof(Car), "pv").GetValue(__instance);
object? obj = ((value is PhotonView) ? value : null);
object? value2 = AccessTools.Field(typeof(Car), "rb").GetValue(__instance);
Rigidbody val = (Rigidbody)((value2 is Rigidbody) ? value2 : null);
object value3 = AccessTools.Field(typeof(Car), "arcadeVehicleController").GetValue(__instance);
object? value4 = AccessTools.Field(typeof(Car), "moneyText").GetValue(__instance);
Text val2 = (Text)((value4 is Text) ? value4 : null);
object value5 = AccessTools.Field(typeof(Car), "rankBar").GetValue(__instance);
object? value6 = AccessTools.Field(typeof(Car), "exitButton").GetValue(__instance);
GameObject val3 = (GameObject)((value6 is GameObject) ? value6 : null);
object? value7 = AccessTools.Field(typeof(Car), "playerCamera").GetValue(__instance);
GameObject val4 = (GameObject)((value7 is GameObject) ? value7 : null);
MethodInfo methodInfo = AccessTools.Method(typeof(Car), "UpdateDarkMode", (Type[])null, (Type[])null);
if (!((PhotonView)obj).IsMine)
{
Object.Destroy((Object)(object)val);
return;
}
if (customTrackLoader.customTracks[customTrackLoader.currentTrackId].isCity)
{
methodInfo.Invoke(__instance, null);
FieldInfo fieldInfo = AccessTools.Field(value3.GetType(), "onRoadSpeed");
FieldInfo fieldInfo2 = AccessTools.Field(value3.GetType(), "accelaration");
FieldInfo fieldInfo3 = AccessTools.Field(value3.GetType(), "offRoadMultiplier");
FieldInfo fieldInfo4 = AccessTools.Field(value3.GetType(), "boostForce");
FieldInfo fieldInfo5 = AccessTools.Field(value3.GetType(), "turn");
fieldInfo.SetValue(value3, 100f);
fieldInfo2.SetValue(value3, 20f);
fieldInfo3.SetValue(value3, 0.5f);
fieldInfo4.SetValue(value3, 50f);
fieldInfo5.SetValue(value3, 5f);
AccessTools.Method(AccessTools.TypeByName("SaveSystem"), "SaveCar", (Type[])null, (Type[])null).Invoke(null, new object[1] { value3 });
((Component)val2).gameObject.SetActive(true);
}
else
{
methodInfo.Invoke(__instance, null);
AccessTools.Field(typeof(Car), "raceStarted").SetValue(__instance, false);
object obj2 = AccessTools.Method(AccessTools.TypeByName("SaveSystem"), "LoadCar", (Type[])null, (Type[])null).Invoke(null, null);
if (obj2 != null)
{
FieldInfo fieldInfo6 = AccessTools.Field(value3.GetType(), "onRoadSpeed");
FieldInfo fieldInfo7 = AccessTools.Field(value3.GetType(), "accelaration");
FieldInfo fieldInfo8 = AccessTools.Field(value3.GetType(), "offRoadMultiplier");
FieldInfo fieldInfo9 = AccessTools.Field(value3.GetType(), "boostForce");
FieldInfo fieldInfo10 = AccessTools.Field(value3.GetType(), "turn");
fieldInfo6.SetValue(value3, AccessTools.Field(obj2.GetType(), "onRoadSpeed").GetValue(obj2));
fieldInfo7.SetValue(value3, AccessTools.Field(obj2.GetType(), "acceleration").GetValue(obj2));
fieldInfo8.SetValue(value3, AccessTools.Field(obj2.GetType(), "offRoadMultiplier").GetValue(obj2));
fieldInfo9.SetValue(value3, AccessTools.Field(obj2.GetType(), "boostForce").GetValue(obj2));
fieldInfo10.SetValue(value3, AccessTools.Field(obj2.GetType(), "handling").GetValue(obj2));
}
}
AccessTools.Method(value5.GetType(), "LoadRank", (Type[])null, (Type[])null).Invoke(value5, null);
AccessTools.Field(typeof(RoomManager), "Instance").GetValue(null);
RoomManager.Instance.raceStarted = true;
val3.SetActive(true);
((MonoBehaviour)__instance).StartCoroutine("Quack");
val4.SetActive(true);
AccessTools.Field(typeof(Car), "goldMedals").SetValue(__instance, PlayerPrefs.GetInt("Wins", 0));
AccessTools.Field(typeof(Car), "silverMedals").SetValue(__instance, PlayerPrefs.GetInt("Seconds", 0));
AccessTools.Field(typeof(Car), "bronzeMedals").SetValue(__instance, PlayerPrefs.GetInt("Thirds", 0));
}
}
[HarmonyPatch(typeof(Car), "FixedUpdate")]
public class Patch_CarFixedUpdate
{
private static bool Prefix(Car __instance)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (!customTrackLoader.customTracks[customTrackLoader.currentTrackId].isCity)
{
return true;
}
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != Path.GetFileNameWithoutExtension(customTrackLoader.customTracks[customTrackLoader.currentTrackId].mapPath))
{
return true;
}
CustomFixedUpdate(__instance);
return false;
}
private static void CustomFixedUpdate(Car __instance)
{
//IL_02b2: 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_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
object? value = AccessTools.Field(typeof(Car), "pv").GetValue(__instance);
PhotonView val = (PhotonView)((value is PhotonView) ? value : null);
bool flag = (bool)AccessTools.Field(typeof(Car), "raceFinished").GetValue(__instance);
FieldInfo fieldInfo = AccessTools.Field(typeof(Car), "shownFinished");
object? value2 = AccessTools.Field(typeof(Car), "resetButton").GetValue(__instance);
GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null);
object? value3 = AccessTools.Field(typeof(Car), "duckTransform").GetValue(__instance);
Transform val3 = (Transform)((value3 is Transform) ? value3 : null);
object? value4 = AccessTools.Field(typeof(Car), "racePositionText").GetValue(__instance);
Text val4 = (Text)((value4 is Text) ? value4 : null);
object? value5 = AccessTools.Field(typeof(Car), "finishText").GetValue(__instance);
Text val5 = (Text)((value5 is Text) ? value5 : null);
object? value6 = AccessTools.Field(typeof(Car), "nameTag").GetValue(__instance);
object? obj = ((value6 is GameObject) ? value6 : null);
AccessTools.Field(typeof(Car), "arcadeVehicleController").GetValue(__instance);
AccessTools.Field(typeof(Car), "playerCamera").GetValue(__instance);
FieldInfo fieldInfo2 = AccessTools.Field(typeof(Car), "timer");
bool flag2 = (bool)AccessTools.Field(typeof(Car), "raceStarted").GetValue(__instance);
MethodInfo methodInfo = AccessTools.Method(typeof(Car), "ResetPosition", (Type[])null, (Type[])null);
AccessTools.Method(typeof(Car), "FixedUpdate", (Type[])null, (Type[])null);
float num = (float)fieldInfo2.GetValue(__instance);
if (!customTrackLoader.customTracks[customTrackLoader.currentTrackId].isCity && flag2 && val.IsMine)
{
num += Time.deltaTime;
((Component)val4).gameObject.SetActive(true);
if (num > 600f)
{
PhotonNetwork.SendAllOutgoingCommands();
PhotonNetwork.Disconnect();
}
fieldInfo2.SetValue(__instance, num);
}
bool flag3 = (bool)fieldInfo.GetValue(__instance);
if (flag && !flag3)
{
val5.text = string.Concat(str2: LanguageManager.Instance.currentLang["FINISHED!"], str0: val.Controller.NickName, str1: " ");
((Component)val5).gameObject.SetActive(true);
((Component)val4).gameObject.SetActive(false);
fieldInfo.SetValue(__instance, true);
}
else if (!flag)
{
((Component)val5).gameObject.SetActive(false);
}
((GameObject)obj).SetActive(true);
if (val.IsMine)
{
val3.localRotation = Quaternion.Euler(0f, 0f, 35f * Input.GetAxis("Horizontal") * -1f);
if (!flag2)
{
val2.SetActive(false);
((Component)__instance).GetComponent<Rigidbody>().velocity = Vector3.zero;
AccessTools.Field(typeof(Car), "arcadeVehicleController").SetValue(__instance, LayerMask.GetMask(new string[1] { "" }));
}
else
{
AccessTools.Field(typeof(Car), "arcadeVehicleController").SetValue(__instance, LayerMask.GetMask(new string[1] { "drivable" }));
val2.SetActive(true);
}
Vector3 position = ((Component)__instance).transform.position;
if (position.x < -2000f || position.x > 2000f || position.y < -10f || position.y > 100f || position.z < -2000f || position.z > 2000f)
{
methodInfo.Invoke(__instance, null);
}
}
}
}
[HarmonyPatch(typeof(Compass), "Update")]
public class Patch_CompassUpdate
{
private static bool Prefix(Compass __instance)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (!customTrackLoader.customTracks[customTrackLoader.currentTrackId].isCity)
{
return true;
}
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != Path.GetFileNameWithoutExtension(customTrackLoader.customTracks[customTrackLoader.currentTrackId].mapPath))
{
return true;
}
CustomUpdate(__instance);
return false;
}
private static void CustomUpdate(Compass __instance)
{
//IL_0159: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: 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)
object? value = AccessTools.Field(typeof(Compass), "pv").GetValue(__instance);
PhotonView val = (PhotonView)((value is PhotonView) ? value : null);
object? value2 = AccessTools.Field(typeof(Compass), "compass").GetValue(__instance);
GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null);
object? value3 = AccessTools.Field(typeof(Compass), "compassBG").GetValue(__instance);
GameObject val3 = (GameObject)((value3 is GameObject) ? value3 : null);
object? value4 = AccessTools.Field(typeof(Compass), "arrow").GetValue(__instance);
Transform val4 = (Transform)((value4 is Transform) ? value4 : null);
object? value5 = AccessTools.Field(typeof(Compass), "compassImage").GetValue(__instance);
RawImage val5 = (RawImage)((value5 is RawImage) ? value5 : null);
List<QuestMarker> list = AccessTools.Field(typeof(Compass), "questMarkers").GetValue(__instance) as List<QuestMarker>;
float num = (float)AccessTools.Field(typeof(Compass), "maxDistance").GetValue(__instance);
MethodInfo methodInfo = AccessTools.Method(typeof(Compass), "GameStart", (Type[])null, (Type[])null);
if (customTrackLoader.customTracks[customTrackLoader.currentTrackId].isCity)
{
if (!val2.activeSelf && val.IsMine)
{
val2.SetActive(true);
val3.SetActive(true);
((Component)val4).gameObject.SetActive(true);
methodInfo.Invoke(__instance, null);
}
if (!val.IsMine)
{
return;
}
val5.uvRect = new Rect(((Component)__instance).transform.localEulerAngles.y / 360f, 0f, 1f, 1f);
float num2 = float.PositiveInfinity;
{
foreach (QuestMarker item in list)
{
((Graphic)item.image).rectTransform.anchoredPosition = (Vector2)(((??)(AccessTools.Method(typeof(Compass), "GetPosOnCompass", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { item }) as Vector2?)) ?? Vector2.zero);
float num3 = Vector2.Distance(new Vector2(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.z), item.position);
float num4 = 0f;
if (num3 < num2)
{
num2 = num3;
val4.LookAt(((Component)item).transform.position);
}
if (num3 < num)
{
num4 = 1f - num3 / num;
}
((Transform)((Graphic)item.image).rectTransform).localScale = Vector3.one * num4;
}
return;
}
}
((Component)val4).gameObject.SetActive(false);
val2.SetActive(false);
val3.SetActive(false);
}
}