-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.cs
85 lines (83 loc) · 3.25 KB
/
data.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Il2CppSystem.Reflection;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace vehiclemod
{
public static class data
{
public static GameObject LoadObject(string name)
{
GameObject i = null;
foreach (AssetBundle lb in main.lb)
{
if (lb.LoadAsset<GameObject>(name)) { i = lb.LoadAsset<GameObject>(name); break; };
}
return i;
}
public static void UpdateCarData(int carid, bool allowdrive, bool allowsit, bool isDrive, bool sound, bool light, float fuel, string playername)
{
GetObj(carid).GetComponent<VehComponent>().UpdateMainCarData(carid, allowdrive, allowsit, isDrive, sound, light, fuel, playername);
}
public static void UpdateSound(int carid, bool state)
{
GetObj(carid).GetComponent<VehComponent>().UpdateSound(state);
}
public static void UpdateLight(int carid, bool state)
{
GetObj(carid).GetComponent<VehComponent>().UpdateLight(state);
}
public static void UpdateDriver(int CarID, bool state)
{
GetObj(CarID).GetComponent<VehComponent>().UpdateDriver(state);
}
public static bool isDrive(int ID)
{
return GetObj(ID).GetComponent<VehComponent>().isDrive();
}
public static GameObject GetObj(int ID)
{
if (main.vehicles.Count <= 0) return null;
main.vehicles.TryGetValue(ID, out GameObject g);
return g;
}
public static int CountPassangers(int CarID)
{
return GetObj(CarID).GetComponent<VehComponent>().CountPassanger();
}
public static void UpdatePassanger(int CarID, int Number, int from)
{
if (Number == -1)
GetObj(CarID).GetComponent<VehComponent>().DeletePassanger(from);
else
GetObj(CarID).GetComponent<VehComponent>().AddPassanger(from, Number);
}
public static Component CopyComponent(Component which, GameObject to)
{
Component added = to.AddComponent(which.GetIl2CppType());
FieldInfo[] fields = which.GetIl2CppType().GetFields();
foreach (FieldInfo field in fields)
{
field.SetValue(to.GetComponent(which.GetIl2CppType()), field.GetValue(which));
if (field.Name == "volumeTrigger") return added;
}
return added;
}
public static String GetInfo(string addon, string what)
{
MenuControll.addonData.TryGetValue(addon, out KeyValuePair<string, string>[] keyvals);
foreach (var ff in keyvals)
{
if (what == ff.Key) { return ff.Value; };
}
return "NaN";
}
public static void UpdateCar(int CarID, Vector3 Position, Quaternion Rotation)
{
GetObj(CarID).GetComponent<VehComponent>().byNet = true;
InfoMain data = GetObj(CarID).GetComponent<VehComponent>().vehicleData;
data.m_Position = Position;
data.m_Rotation = Rotation;
}
}
}