forked from bloodypenguin/Skylines-MetroOverhaulMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrainTrackAIMetro.cs
59 lines (58 loc) · 2.04 KB
/
TrainTrackAIMetro.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
using ColossalFramework;
namespace MetroOverhaul {
class TrainTrackAIMetro : TrainTrackAI
{
public override void UpdateNodeFlags(ushort nodeID, ref NetNode data)
{
base.UpdateNodeFlags(nodeID, ref data);
NetNode.Flags flags = data.m_flags & ~(NetNode.Flags.Transition | NetNode.Flags.LevelCrossing | NetNode.Flags.TrafficLights);
int num = 0;
int num2 = 0;
uint num3 = 0u;
int num4 = 0;
NetManager instance = Singleton<NetManager>.instance;
for (int i = 0; i < 8; i++)
{
ushort segment = data.GetSegment(i);
if (segment != 0)
{
NetInfo info = instance.m_segments.m_buffer[(int)segment].Info;
if (info != null)
{
uint num8 = 1u << (int)info.m_class.m_level;
if ((num3 & num8) == 0u)
{
num3 |= num8;
num4++;
}
if (info.m_createPavement)
{
flags |= NetNode.Flags.Transition;
}
if (info.m_class.m_service == ItemClass.Service.Road)
{
num++;
}
else if (info.m_class.m_service == ItemClass.Service.PublicTransport)
{
num2++;
}
}
}
}
if (num2 >= 2 && num >= 1)
{
flags |= (NetNode.Flags.LevelCrossing | NetNode.Flags.TrafficLights);
}
if (num2 >= 2 && num4 >= 2)
{
flags |= NetNode.Flags.Transition;
}
else
{
flags &= ~NetNode.Flags.Transition;
}
data.m_flags = flags;
}
}
}