Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Commit 872253d

Browse files
committed
2 parents 51ccdac + 3078a5c commit 872253d

File tree

4 files changed

+113
-69
lines changed

4 files changed

+113
-69
lines changed

Transit.Addon.RoadExtensions/Roads/Highways/Common/HighwayHelper.cs

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static NetInfo.Lane SetHighwayRightShoulder(this NetInfo hwInfo, NetInfo
108108
return rightHwLane;
109109
}
110110

111-
public static IEnumerable<NetInfo.Lane> SetHighwayVehicleLanes(this NetInfo hwInfo, int lanesToAdd = 0)
111+
public static IEnumerable<NetInfo.Lane> SetHighwayVehicleLanes(this NetInfo hwInfo, int lanesToAdd = 0, bool isTwoWay = false)
112112
{
113113
if (lanesToAdd < 0)
114114
{
@@ -145,7 +145,7 @@ public static NetInfo.Lane SetHighwayRightShoulder(this NetInfo hwInfo, NetInfo
145145
var nbLanes = vehicleLanes.Count();
146146
var positionStart = laneWidth * ((1f - nbLanes) / 2f);
147147

148-
for (var i = 0; i < vehicleLanes.Length; i++)
148+
for (var i = 0; i < nbLanes; i++)
149149
{
150150
var l = vehicleLanes[i];
151151
l.m_stopType = VehicleInfo.VehicleType.None;
@@ -159,6 +159,17 @@ public static NetInfo.Lane SetHighwayRightShoulder(this NetInfo hwInfo, NetInfo
159159
{
160160
prop.m_position = new Vector3(0, 0, 0);
161161
}
162+
if (isTwoWay)
163+
{
164+
if (l.m_position < 0.0f)
165+
{
166+
l.m_direction = NetInfo.Direction.Backward;
167+
}
168+
else
169+
{
170+
l.m_direction = NetInfo.Direction.Forward;
171+
}
172+
}
162173
}
163174

164175
return vehicleLanes;
@@ -325,26 +336,30 @@ public static void SetHighwayRightLights(this ICollection<NetLaneProps.Prop> pro
325336
public static void AddLeftWallLights(this ICollection<NetLaneProps.Prop> props, int xPos = 0)
326337
{
327338
var wallLightPropInfo = Prefabs.Find<PropInfo>("Wall Light Orange");
328-
var wallLightProp = new NetLaneProps.Prop();
329-
wallLightProp.m_prop = wallLightPropInfo.ShallowClone();
330-
wallLightProp.m_probability = 100;
331-
wallLightProp.m_repeatDistance = 20;
332-
wallLightProp.m_segmentOffset = 0;
333-
wallLightProp.m_angle = 270;
334-
wallLightProp.m_position = new Vector3(xPos, 1.5f, 0);
339+
var wallLightProp = new NetLaneProps.Prop
340+
{
341+
m_prop = wallLightPropInfo.ShallowClone(),
342+
m_probability = 100,
343+
m_repeatDistance = 20,
344+
m_segmentOffset = 0,
345+
m_angle = 270,
346+
m_position = new Vector3(xPos, 1.5f, 0)
347+
};
335348
props.Add(wallLightProp);
336349
}
337350

338351
public static void AddRightWallLights(this ICollection<NetLaneProps.Prop> props, int xPos = 0)
339352
{
340353
var wallLightPropInfo = Prefabs.Find<PropInfo>("Wall Light Orange");
341-
var wallLightProp = new NetLaneProps.Prop();
342-
wallLightProp.m_prop = wallLightPropInfo.ShallowClone();
343-
wallLightProp.m_probability = 100;
344-
wallLightProp.m_repeatDistance = 20;
345-
wallLightProp.m_segmentOffset = 0;
346-
wallLightProp.m_angle = 90;
347-
wallLightProp.m_position = new Vector3(xPos, 1.5f, 0);
354+
var wallLightProp = new NetLaneProps.Prop
355+
{
356+
m_prop = wallLightPropInfo.ShallowClone(),
357+
m_probability = 100,
358+
m_repeatDistance = 20,
359+
m_segmentOffset = 0,
360+
m_angle = 90,
361+
m_position = new Vector3(xPos, 1.5f, 0)
362+
};
348363
props.Add(wallLightProp);
349364
}
350365

@@ -367,12 +382,14 @@ public static void SetHighwaySignsSlope(this ICollection<NetLaneProps.Prop> prop
367382
}
368383
}
369384

370-
public static void TrimNonHighwayProps(this NetInfo info, bool removeRightStreetLights = false, bool removeLeftStreetLights = true)
385+
public static void TrimNonHighwayProps(this NetInfo info, bool removeRightStreetLights = false, bool removeLeftStreetLights = true, bool removeMotorwaySigns = false)
371386
{
372387
var randomProp = Prefabs.Find<PropInfo>("Random Street Prop", false);
373388
var streetLight = Prefabs.Find<PropInfo>("New Street Light", false);
374389
var streetLightHw = Prefabs.Find<PropInfo>("New Street Light Highway", false);
375390
var manhole = Prefabs.Find<PropInfo>("Manhole", false);
391+
var motorwaySign = Prefabs.Find<PropInfo>("Motorway Sign", false);
392+
var motorwayOverroadSigns = Prefabs.Find<PropInfo>("Motorway Overroad Signs", false);
376393

377394
foreach (var laneProps in info.m_lanes.Select(l => l.m_laneProps).Where(lpi => lpi != null))
378395
{
@@ -425,6 +442,14 @@ public static void TrimNonHighwayProps(this NetInfo info, bool removeRightStreet
425442
}
426443
}
427444

445+
if (removeMotorwaySigns)
446+
{
447+
if (prop.m_prop == motorwaySign || prop.m_prop == motorwayOverroadSigns)
448+
{
449+
continue;
450+
}
451+
}
452+
428453
remainingProp.Add(prop);
429454
}
430455

Transit.Addon.RoadExtensions/Roads/Highways/Highway2L2W/Highway2L2WBuilder.cs

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public partial class Highway2L2WBuilder : Activable, INetInfoBuilderPart
1515

1616
public string BasedPrefabName { get { return NetInfos.Vanilla.HIGHWAY_3L; } }
1717
public string Name { get { return "Highway2L2W"; } }
18-
public string DisplayName { get { return "Four-Lane National Highway"; } }
19-
public string Description { get { return "A four-lane national highway accommodating medium traffic. Highway does not allow zoning next to it!"; } }
18+
public string DisplayName { get { return "2+2 Lane Highway"; } }
19+
public string Description { get { return "A two way two lane highway suitable for medium traffic."; } }
2020
public string ShortDescription { get { return "No parking, not zoneable, medium traffic"; } }
2121
public string UICategory { get { return "RoadsHighway"; } }
2222

@@ -42,6 +42,7 @@ public void BuildUp(NetInfo info, NetInfoVersion version)
4242
///////////////////////////
4343
info.Setup24mMesh(version);
4444

45+
4546
///////////////////////////
4647
// Texturing //
4748
///////////////////////////
@@ -61,50 +62,60 @@ public void BuildUp(NetInfo info, NetInfoVersion version)
6162
info.m_hasPedestrianLanes = false;
6263
info.m_UnlockMilestone = highwayInfo.m_UnlockMilestone;
6364
info.m_halfWidth = (version == NetInfoVersion.Bridge || version == NetInfoVersion.Elevated) ? 11 : 12;
64-
info.m_pavementWidth = 2f;
65+
info.m_pavementWidth = 2;
6566
info.m_maxBuildAngle = 90;
6667
info.m_maxBuildAngleCos = 0;
6768
if (version == NetInfoVersion.Tunnel)
6869
{
6970
info.m_setVehicleFlags = Vehicle.Flags.Transition | Vehicle.Flags.Underground;
70-
info.m_class = highwayTunnelInfo.m_class.Clone(info.name + version.ToString() + "Class");
71+
info.m_class = highwayTunnelInfo.m_class.Clone(NetInfoClasses.NEXT_HIGHWAY2L2W_TUNNEL);
7172
}
7273
else
7374
{
74-
info.m_class = highwayInfo.m_class.Clone(info.name + version.ToString() + "Class");
75+
info.m_class = highwayInfo.m_class.Clone(NetInfoClasses.NEXT_HIGHWAY2L2W);
7576
}
7677

78+
7779
///////////////////////////
7880
// Set up lanes //
7981
///////////////////////////
80-
info.SetRoadLanes(version, new LanesConfiguration
82+
info.SetupHighwayLanes();
83+
var leftHwLane = info.SetHighwayLeftShoulder(highwayInfo, version);
84+
var rightHwLane = info.SetHighwayRightShoulder(highwayInfo, version);
85+
var vehicleLanes = info.SetHighwayVehicleLanes(1, true);
86+
foreach (var lane in vehicleLanes)
8187
{
82-
LanePositionOffst = (version == NetInfoVersion.Bridge || version == NetInfoVersion.Elevated) ? -1 : -2,
83-
IsTwoWay = true,
84-
LaneWidth = 4,
85-
LanesToAdd = 1,
86-
SpeedLimit = 1.8f
87-
});
88+
lane.m_speedLimit = 1.8f;
89+
}
90+
8891

8992
///////////////////////////
9093
// Set up props //
9194
///////////////////////////
92-
var leftPedLane = info.GetLeftRoadShoulder();
93-
var rightPedLane = info.GetRightRoadShoulder();
95+
var leftHwLaneProps = leftHwLane.m_laneProps.m_props.ToList();
96+
var rightHwLaneProps = rightHwLane.m_laneProps.m_props.ToList();
9497

95-
var leftRoadProps = leftPedLane?.m_laneProps.m_props.ToList();
96-
var rightRoadProps = rightPedLane?.m_laneProps.m_props.ToList();
98+
if (version == NetInfoVersion.Slope)
99+
{
100+
leftHwLaneProps.SetHighwaySignsSlope();
101+
rightHwLaneProps.SetHighwaySignsSlope();
102+
}
97103

104+
// Lightning
105+
rightHwLaneProps.SetHighwayRightLights(version);
98106
if (version == NetInfoVersion.Slope)
99107
{
100-
leftRoadProps?.AddLeftWallLights(info.m_pavementWidth);
101-
rightRoadProps?.AddRightWallLights(info.m_pavementWidth);
108+
leftHwLaneProps.AddLeftWallLights(1);
109+
rightHwLaneProps.AddRightWallLights(-1);
102110
}
103-
if (leftPedLane != null && leftPedLane.m_laneProps != null)
104-
leftPedLane.m_laneProps.m_props = leftRoadProps.ToArray();
105-
if (rightPedLane != null && rightPedLane.m_laneProps != null)
106-
rightPedLane.m_laneProps.m_props = rightRoadProps.ToArray();
107-
info.TrimNonHighwayProps(version == NetInfoVersion.Ground);
111+
112+
leftHwLaneProps.RemoveProps("100 Speed Limit"); // Since we dont have the 90km/h limit prop
113+
rightHwLaneProps.RemoveProps("100 Speed Limit"); // Since we dont have the 90km/h limit prop
114+
115+
leftHwLane.m_laneProps.m_props = leftHwLaneProps.ToArray();
116+
rightHwLane.m_laneProps.m_props = rightHwLaneProps.ToArray();
117+
118+
info.TrimNonHighwayProps(false, false, true);
108119

109120
///////////////////////////
110121
// AI //

Transit.Addon.RoadExtensions/Roads/Highways/HighwayL1R2/HighwayL1R2Builder.cs

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class HighwayL1R2Builder : Activable, INetInfoBuilderPart
1515

1616
public string BasedPrefabName { get { return NetInfos.Vanilla.HIGHWAY_3L; } }
1717
public string Name { get { return "AsymHighwayL1R2"; } }
18-
public string DisplayName { get { return "3 Lane Asymmetrical Highway: (1+2)"; } }
18+
public string DisplayName { get { return "1+2 Lane Asymmetrical Highway"; } }
1919
public string Description { get { return "An asymmetrical highway with one left lane and two right lanes. Note, dragging this highway backwards reverses its orientation."; } }
2020
public string ShortDescription { get { return "No parking, not zoneable, medium to high traffic"; } }
2121
public string UICategory { get { return "RoadsHighway"; } }
@@ -41,7 +41,7 @@ public void BuildUp(NetInfo info, NetInfoVersion version)
4141
///////////////////////////
4242
// 3DModeling //
4343
///////////////////////////
44-
info.Setup22mMesh(version, LanesLayoutStyle.AsymL1R2);
44+
info.Setup22mMesh(version);
4545

4646

4747
///////////////////////////
@@ -63,56 +63,60 @@ public void BuildUp(NetInfo info, NetInfoVersion version)
6363
info.m_hasPedestrianLanes = false;
6464
info.m_UnlockMilestone = highwayInfo.m_UnlockMilestone;
6565
info.m_halfWidth = 11;
66-
info.m_pavementWidth = 2f;
66+
info.m_pavementWidth = 2;
6767
info.m_maxBuildAngle = 90;
6868
info.m_maxBuildAngleCos = 0;
6969
if (version == NetInfoVersion.Tunnel)
7070
{
7171
info.m_setVehicleFlags = Vehicle.Flags.Transition | Vehicle.Flags.Underground;
72-
info.m_class = highwayTunnelInfo.m_class.Clone(info.name + version.ToString() + "Class");
72+
info.m_class = highwayTunnelInfo.m_class.Clone(NetInfoClasses.NEXT_HIGHWAYL1R2_TUNNEL);
7373
}
7474
else
7575
{
76-
info.m_class = highwayInfo.m_class.Clone(info.name + version.ToString() + "Class");
76+
info.m_class = highwayInfo.m_class.Clone(NetInfoClasses.NEXT_HIGHWAYL1R2);
7777
}
78-
info.SetRoadLanes(version, new LanesConfiguration
79-
{
80-
LanePositionOffst = -3,
81-
IsTwoWay = true,
82-
LaneWidth = 4,
83-
SpeedLimit = 1.8f
84-
});
78+
79+
8580
///////////////////////////
8681
// Set up lanes //
8782
///////////////////////////
88-
// Setting up lanes
89-
var vehicleLanes = info.m_lanes.Where(l => l.m_laneType == NetInfo.LaneType.Vehicle).ToList();
90-
var leftLane = vehicleLanes.FirstOrDefault(l => l.m_position == vehicleLanes.Min(n => n.m_position));
91-
leftLane.m_direction = NetInfo.Direction.Backward;
92-
leftLane.m_finalDirection = NetInfo.Direction.Backward;
83+
info.SetupHighwayLanes();
84+
var leftHwLane = info.SetHighwayLeftShoulder(highwayInfo, version);
85+
var rightHwLane = info.SetHighwayRightShoulder(highwayInfo, version);
86+
var vehicleLanes = info.SetHighwayVehicleLanes(0, true);
87+
foreach (var lane in vehicleLanes)
88+
{
89+
lane.m_speedLimit = 1.8f;
90+
}
91+
9392

94-
9593
///////////////////////////
9694
// Set up props //
9795
///////////////////////////
98-
var leftPedLane = info.GetLeftRoadShoulder();
99-
var rightPedLane = info.GetRightRoadShoulder();
96+
var leftHwLaneProps = leftHwLane.m_laneProps.m_props.ToList();
97+
var rightHwLaneProps = rightHwLane.m_laneProps.m_props.ToList();
10098

101-
var leftRoadProps = leftPedLane?.m_laneProps.m_props.ToList();
102-
var rightRoadProps = rightPedLane?.m_laneProps.m_props.ToList();
99+
if (version == NetInfoVersion.Slope)
100+
{
101+
leftHwLaneProps.SetHighwaySignsSlope();
102+
rightHwLaneProps.SetHighwaySignsSlope();
103+
}
103104

105+
// Lightning
106+
rightHwLaneProps.SetHighwayRightLights(version);
104107
if (version == NetInfoVersion.Slope)
105108
{
106-
leftRoadProps?.AddLeftWallLights(info.m_pavementWidth);
107-
rightRoadProps?.AddRightWallLights(info.m_pavementWidth);
109+
leftHwLaneProps.AddLeftWallLights(1);
110+
rightHwLaneProps.AddRightWallLights(-1);
108111
}
109112

110-
if (leftPedLane != null && leftPedLane.m_laneProps != null)
111-
leftPedLane.m_laneProps.m_props = leftRoadProps.ToArray();
112-
if (rightPedLane != null && rightPedLane.m_laneProps != null)
113-
rightPedLane.m_laneProps.m_props = rightRoadProps.ToArray();
113+
leftHwLaneProps.RemoveProps("100 Speed Limit"); // Since we dont have the 90km/h limit prop
114+
rightHwLaneProps.RemoveProps("100 Speed Limit"); // Since we dont have the 90km/h limit prop
115+
116+
leftHwLane.m_laneProps.m_props = leftHwLaneProps.ToArray();
117+
rightHwLane.m_laneProps.m_props = rightHwLaneProps.ToArray();
114118

115-
info.TrimNonHighwayProps(version == NetInfoVersion.Ground);
119+
info.TrimNonHighwayProps(false, false, true);
116120

117121
///////////////////////////
118122
// AI //

Transit.Framework/Network/NetInfoClasses.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public static class NetInfoClasses
1111
public const string NEXT_HIGHWAY1L_TUNNEL = "NExtHighwayTunnel1LTunnel";
1212
public const string NEXT_HIGHWAY2L = "NExtHighway2L";
1313
public const string NEXT_HIGHWAY2L_TUNNEL = "NExtHighwayTunnel2LTunnel";
14+
public const string NEXT_HIGHWAY2L2W = "NExtHighway2L2W";
15+
public const string NEXT_HIGHWAY2L2W_TUNNEL = "NExtHighwayTunnel2L2W";
16+
public const string NEXT_HIGHWAYL1R2 = "NExtHighwayL1R2";
17+
public const string NEXT_HIGHWAYL1R2_TUNNEL = "NExtHighwayTunnelL1R2";
1418
public const string NEXT_HIGHWAY4L = "NExtHighway4L";
1519
public const string NEXT_HIGHWAY4L_TUNNEL = "NExtHighwayTunnel4LTunnel";
1620
public const string NEXT_HIGHWAY5L = "NExtHighway5L";

0 commit comments

Comments
 (0)