-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMetroTrainAIDetour.cs
66 lines (63 loc) · 2.06 KB
/
MetroTrainAIDetour.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
using MetroOverhaul.Redirection;
using MetroOverhaul.Redirection.Attributes;
namespace MetroOverhaul.Detours
{
[TargetType(typeof(MetroTrainAI))]
public class MetroTrainAIDetour : PassengerTrainAI
{
public static void ChangeDeployState(bool state)
{
if (!Util.IsGameMode())
{
return;
}
if (state)
{
Redirector<MetroTrainAIDetour>.Deploy();
}
else
{
Redirector<MetroTrainAIDetour>.Revert();
}
}
[RedirectMethod]
public override void CreateVehicle(ushort vehicleID, ref Vehicle data)
{
base.CreateVehicle(vehicleID, ref data);
//begin mod
if (vehicleID > 0)
{
var position = VehicleManager.instance.m_vehicles.m_buffer[vehicleID].m_frame0.m_position;
if (position.y < TerrainManager.instance.SampleDetailHeightSmooth(position.x, position.z))
//how about sunken stations?
{
data.m_flags |= Vehicle.Flags.Underground;
}
else
{
data.m_flags &= ~Vehicle.Flags.Underground;
}
}
//end mod
}
[RedirectMethod]
public override void LoadVehicle(ushort vehicleID, ref Vehicle data)
{
base.LoadVehicle(vehicleID, ref data);
//begin mod
if (vehicleID > 0)
{
var position = VehicleManager.instance.m_vehicles.m_buffer[vehicleID].m_frame0.m_position;
if (position.y < TerrainManager.instance.SampleDetailHeightSmooth(position.x, position.z)) //how about sunken stations?
{
data.m_flags |= Vehicle.Flags.Underground;
}
else
{
data.m_flags &= ~Vehicle.Flags.Underground;
}
}
//end mod
}
}
}