public static void TrimHighwayProps(this NetInfo info) { var randomProp = ToolsCSL.FindPrefab <PropInfo>("Random Street Prop", false); var streetLight = ToolsCSL.FindPrefab <PropInfo>("New Street Light", false); var manhole = ToolsCSL.FindPrefab <PropInfo>("Manhole", false); if (randomProp == null) { return; } foreach (var laneProps in info.m_lanes.Select(l => l.m_laneProps).Where(lpi => lpi != null)) { var remainingProp = new List <NetLaneProps.Prop>(); foreach (var prop in laneProps.m_props) { if (prop.m_prop != null) { if (prop.m_prop == randomProp) { continue; } if (prop.m_prop == manhole) { continue; } if (prop.m_prop == streetLight && laneProps.name.Contains("Left")) { continue; } remainingProp.Add(prop); } } laneProps.m_props = remainingProp.ToArray(); } }
public static void Setup50LimitProps(this NetInfo info) { var speed50 = ToolsCSL.FindPrefab <PropInfo>("50 Speed Limit", false); var speed60 = ToolsCSL.FindPrefab <PropInfo>("60 Speed Limit", false); if (speed50 == null || speed60 == null) { return; } foreach (var lane in info.m_lanes.Where(l => l.m_laneProps != null)) { if (lane.m_laneProps.m_props == null || lane.m_laneProps.m_props.Length == 0) { continue; } var speed60Prop = lane .m_laneProps .m_props .FirstOrDefault(prop => prop.m_prop == speed60); if (speed60Prop != null) { var newPropsContent = new List <NetLaneProps.Prop>(); var speed50Prop = speed60Prop.ShallowClone(); speed50Prop.m_prop = speed50; speed50Prop.m_finalProp = null; newPropsContent.AddRange(lane.m_laneProps.m_props.Where(prop => prop.m_prop != speed60)); newPropsContent.Add(speed50Prop); var newProps = ScriptableObject.CreateInstance <NetLaneProps>(); newProps.name = lane.m_laneProps.name + "_clone"; newProps.m_props = newPropsContent.ToArray(); lane.m_laneProps = newProps; } } }
public void BuildUp(NetInfo info, NetInfoVersion version) { /////////////////////////// // Template // /////////////////////////// var mediumRoadInfo = ToolsCSL.FindPrefab <NetInfo>("Medium Road"); /////////////////////////// // Texturing // /////////////////////////// switch (version) { case NetInfoVersion.Ground: info.SetSegmentsTexture( new TexturesSet (@"NewNetwork\MediumAvenue4L\Textures\Ground_Segment__MainTex.png", @"NewNetwork\MediumAvenue4L\Textures\Ground_Segment__AlphaMap.png")); break; } /////////////////////////// // Set up // /////////////////////////// info.m_class = mediumRoadInfo.m_class.Clone(MediumAvenueHelper.CLASS_NAME); info.m_UnlockMilestone = mediumRoadInfo.m_UnlockMilestone; // Setting up lanes var vehicleLaneTypes = new[] { NetInfo.LaneType.Vehicle, NetInfo.LaneType.PublicTransport, NetInfo.LaneType.CargoVehicle, NetInfo.LaneType.TransportVehicle }; var vehicleLanes = mediumRoadInfo .m_lanes .Where(l => vehicleLaneTypes.Contains(l.m_laneType)) .Select(l => l.ShallowClone()) .OrderBy(l => l.m_position) .ToArray(); var nonVehicleLanes = info.m_lanes .Where(l => !vehicleLaneTypes.Contains(l.m_laneType)) .ToArray(); info.m_lanes = vehicleLanes .Union(nonVehicleLanes) .ToArray(); for (var i = 0; i < vehicleLanes.Length; i++) { var lane = vehicleLanes[i]; switch (i) { // Inside lane case 1: case 2: if (lane.m_position < 0) { lane.m_position += 0.5f; } else { lane.m_position += -0.5f; } break; } } info.Setup50LimitProps(); if (version == NetInfoVersion.Ground) { var mrPlayerNetAI = mediumRoadInfo.GetComponent <PlayerNetAI>(); var playerNetAI = info.GetComponent <PlayerNetAI>(); if (mrPlayerNetAI != null && playerNetAI != null) { playerNetAI.m_constructionCost = mrPlayerNetAI.m_constructionCost * 9 / 10; // 10% decrease playerNetAI.m_maintenanceCost = mrPlayerNetAI.m_maintenanceCost * 9 / 10; // 10% decrease } } }
public void BuildUp(NetInfo info, NetInfoVersion version) { /////////////////////////// // Template // /////////////////////////// var onewayRoadInfo = ToolsCSL.FindPrefab <NetInfo>("Oneway Road"); /////////////////////////// // 3DModeling // /////////////////////////// if (version == NetInfoVersion.Ground) { var segments0 = info.m_segments[0]; var nodes0 = info.m_nodes[0]; var grndMesh = OneWay1LSegmentModel.BuildMesh().CreateMesh("OW_1L_GROUND"); segments0.m_mesh = grndMesh; nodes0.m_mesh = grndMesh; info.m_segments = new[] { segments0 }; info.m_nodes = new[] { nodes0 }; } /////////////////////////// // Texturing // /////////////////////////// switch (version) { case NetInfoVersion.Ground: info.SetSegmentsTexture( new TexturesSet (@"NewNetwork\OneWay1L\Textures\Ground_Segment__MainTex.png", @"NewNetwork\OneWay1L\Textures\Ground_Segment__AlphaMap.png")); info.SetNodesTexture( new TexturesSet (@"NewNetwork\OneWay1L\Textures\Ground_Node__MainTex.png", @"NewNetwork\OneWay1L\Textures\Ground_Node__AlphaMap.png")); break; } /////////////////////////// // Set up // /////////////////////////// info.m_class = onewayRoadInfo.m_class.Clone("SmallOneway"); info.m_hasParkingSpaces = false; info.m_halfWidth = 5.0f; info.m_pavementWidth = 2f; // Setting up lanes var parkingLanes = info.m_lanes .Where(l => l.m_laneType == NetInfo.LaneType.Parking) .ToList(); var vehicleLanes = info.m_lanes .Where(l => l.m_laneType != NetInfo.LaneType.None) .Where(l => l.m_laneType != NetInfo.LaneType.Pedestrian) .Where(l => l.m_laneType != NetInfo.LaneType.Parking) .ToList(); var pedestrianLanes = info.m_lanes .Where(l => l.m_laneType == NetInfo.LaneType.Pedestrian) .OrderBy(l => l.m_similarLaneIndex) .ToList(); var vehicleLane = vehicleLanes[0]; var parkingLane = parkingLanes[0]; vehicleLanes[1].m_laneType = NetInfo.LaneType.None; parkingLanes[1].m_laneType = NetInfo.LaneType.None; vehicleLane.m_width = 3.5f; vehicleLane.m_verticalOffset = -0.3f; vehicleLane.m_position = -1.25f; vehicleLane.m_speedLimit = 0.7f; parkingLane.m_width = 2.5f; parkingLane.m_verticalOffset = -0.3f; parkingLane.m_position = 1.75f; var roadHalfWidth = 3f; var pedWidth = 2f; for (var i = 0; i < pedestrianLanes.Count; i++) { var multiplier = pedestrianLanes[i].m_position / Math.Abs(pedestrianLanes[i].m_position); pedestrianLanes[i].m_width = pedWidth; pedestrianLanes[i].m_position = multiplier * (roadHalfWidth + (.5f * pedWidth)); foreach (var prop in pedestrianLanes[i].m_laneProps.m_props) { prop.m_position.x += multiplier * roadHalfWidth; } } if (version == NetInfoVersion.Ground) { var playerNetAI = info.GetComponent <PlayerNetAI>(); var orPlayerNetAI = onewayRoadInfo.GetComponent <PlayerNetAI>(); if (playerNetAI != null) { playerNetAI.m_constructionCost = orPlayerNetAI.m_constructionCost * 2 / 3; playerNetAI.m_maintenanceCost = orPlayerNetAI.m_maintenanceCost * 2 / 3; } } }
public void BuildUp(NetInfo info, NetInfoVersion version) { /////////////////////////// // Texturing // /////////////////////////// switch (version) { case NetInfoVersion.Ground: info.SetSegmentsTexture( new TexturesSet (@"NewNetwork\Highway2L\Textures\Ground_Segment__MainTex.png", @"NewNetwork\Highway2L\Textures\Ground_Segment__AlphaMap.png")); info.SetNodesTexture( new TexturesSet (@"NewNetwork\Highway2L\Textures\Ground_Segment__MainTex.png", @"NewNetwork\Highway2L\Textures\Ground_Node__AlphaMap.png"), new TexturesSet (@"NewNetwork\Highway2L\Textures\Ground_NodeLOD__MainTex.png", @"NewNetwork\Highway2L\Textures\Ground_NodeLOD__AlphaMap.png", @"NewNetwork\Highway2L\Textures\Ground_NodeLOD__XYSMap.png")); break; case NetInfoVersion.Elevated: case NetInfoVersion.Bridge: info.SetNodesTexture( new TexturesSet (@"NewNetwork\Highway2L\Textures\Elevated_Node__MainTex.png", @"NewNetwork\Highway2L\Textures\Elevated_Node__AlphaMap.png"), new TexturesSet (@"NewNetwork\Highway2L\Textures\Elevated_NodeLOD__MainTex.png", @"NewNetwork\Highway2L\Textures\Elevated_NodeLOD__AlphaMap.png", @"NewNetwork\Highway2L\Textures\Elevated_NodeLOD__XYSMap.png")); break; case NetInfoVersion.Slope: info.SetNodesTexture( new TexturesSet (@"NewNetwork\Highway2L\Textures\Slope_Node__MainTex.png", @"NewNetwork\Highway2L\Textures\Slope_Node__AlphaMap.png"), new TexturesSet (@"NewNetwork\Highway2L\Textures\Slope_NodeLOD__MainTex.png", @"NewNetwork\Highway2L\Textures\Slope_NodeLOD__AlphaMap.png", @"NewNetwork\Highway2L\Textures\Slope_NodeLOD__XYSMap.png")); break; case NetInfoVersion.Tunnel: break; } /////////////////////////// // Set up // /////////////////////////// var highwayInfo = ToolsCSL.FindPrefab <NetInfo>("Highway"); info.m_createPavement = (version != NetInfoVersion.Ground); info.m_createGravel = (version == NetInfoVersion.Ground); info.m_averageVehicleLaneSpeed = 2f; info.m_hasParkingSpaces = false; info.m_hasPedestrianLanes = false; info.m_UnlockMilestone = highwayInfo.m_UnlockMilestone; // Activate with a new mesh //info.m_class = highwayInfo.m_class; // Test //info.m_surfaceLevel = 0; // Disabling Parkings and Peds foreach (var l in info.m_lanes) { switch (l.m_laneType) { case NetInfo.LaneType.Parking: l.m_laneType = NetInfo.LaneType.None; break; case NetInfo.LaneType.Pedestrian: l.m_laneType = NetInfo.LaneType.None; break; } } // Setting up lanes var vehiculeLanes = info.m_lanes .Where(l => l.m_laneType != NetInfo.LaneType.None) .OrderBy(l => l.m_similarLaneIndex) .ToArray(); for (int i = 0; i < vehiculeLanes.Length; i++) { var l = vehiculeLanes[i]; l.m_allowStop = false; l.m_speedLimit = 2f; } if (version == NetInfoVersion.Ground) { var hwPlayerNetAI = highwayInfo.GetComponent <PlayerNetAI>(); var playerNetAI = info.GetComponent <PlayerNetAI>(); if (hwPlayerNetAI != null && playerNetAI != null) { playerNetAI.m_constructionCost = hwPlayerNetAI.m_constructionCost * 2 / 3; playerNetAI.m_maintenanceCost = hwPlayerNetAI.m_maintenanceCost * 2 / 3; } } else // Same as the original oneway { } var roadBaseAI = info.GetComponent <RoadBaseAI>(); if (roadBaseAI != null) { roadBaseAI.m_highwayRules = true; roadBaseAI.m_trafficLights = false; } var roadAI = info.GetComponent <RoadAI>(); if (roadAI != null) { roadAI.m_enableZoning = false; roadAI.m_trafficLights = false; } info.SetHighwayProps(highwayInfo); info.TrimHighwayProps(); }
public void BuildUp(NetInfo info, NetInfoVersion version) { /////////////////////////// // Template // /////////////////////////// var highwayInfo = ToolsCSL.FindPrefab <NetInfo>("Highway"); /////////////////////////// // 3DModeling // /////////////////////////// if (version == NetInfoVersion.Ground) { info.m_surfaceLevel = 0; info.m_class = highwayInfo.m_class.Clone("LargeHighway"); var segments0 = info.m_segments[0]; var nodes0 = info.m_nodes[0]; segments0.m_backwardForbidden = NetSegment.Flags.None; segments0.m_backwardRequired = NetSegment.Flags.None; segments0.m_forwardForbidden = NetSegment.Flags.None; segments0.m_forwardRequired = NetSegment.Flags.None; var nodes1 = nodes0.ShallowClone(); nodes0.m_flagsForbidden = NetNode.Flags.Transition; nodes0.m_flagsRequired = NetNode.Flags.None; nodes1.m_flagsForbidden = NetNode.Flags.None; nodes1.m_flagsRequired = NetNode.Flags.Transition; var grndMesh = Highway6LMeshes.GetGroundData().CreateMesh("HIGHWAY_6L_GROUND"); var grndTransMesh = Highway6LMeshes.GetGroundTransitionData().CreateMesh("HIGHWAY_6L_GROUND_TRS"); segments0.m_mesh = grndMesh; nodes0.m_mesh = grndMesh; nodes1.m_mesh = grndTransMesh; info.m_segments = new[] { segments0 }; info.m_nodes = new[] { nodes0, nodes1 }; } /////////////////////////// // Texturing // /////////////////////////// switch (version) { case NetInfoVersion.Ground: info.SetSegmentsTexture( new TexturesSet( @"NewNetwork\Highway6L\Textures\Ground_Segment__MainTex.png", @"NewNetwork\Highway6L\Textures\Ground_Segment__APRMap.png")); info.SetNodesTexture( new TexturesSet (@"NewNetwork\Highway6L\Textures\Ground_Node__MainTex.png", @"NewNetwork\Highway6L\Textures\Ground_Node__APRMap.png"), new TexturesSet (@"NewNetwork\Highway6L\Textures\Ground_NodeLOD__MainTex.png", @"NewNetwork\Highway6L\Textures\Ground_NodeLOD__APRMap.png", @"NewNetwork\Highway6L\Textures\Ground_NodeLOD__XYSMap.png")); break; case NetInfoVersion.Elevated: case NetInfoVersion.Bridge: info.SetNodesTexture( new TexturesSet (@"NewNetwork\Highway6L\Textures\Elevated_Node__MainTex.png", @"NewNetwork\Highway6L\Textures\Elevated_Node__APRMap.png")); // Lets leave the crossings there until we have a fix //new TexturesSet // (@"NewNetwork\Highway6L\Textures\Elevated_NodeLOD__MainTex.png", // @"NewNetwork\Highway6L\Textures\Elevated_NodeLOD__APRMap.png", // @"NewNetwork\Highway6L\Textures\Elevated_NodeLOD__XYSMap.png")); break; case NetInfoVersion.Slope: info.SetNodesTexture( new TexturesSet (@"NewNetwork\Highway6L\Textures\Slope_Node__MainTex.png", @"NewNetwork\Highway6L\Textures\Slope_Node__APRMap.png"), new TexturesSet (@"NewNetwork\Highway6L\Textures\Slope_NodeLOD__MainTex.png", @"NewNetwork\Highway6L\Textures\Slope_NodeLOD__APRMap.png", @"NewNetwork\Highway6L\Textures\Slope_NodeLOD__XYSMap.png")); break; case NetInfoVersion.Tunnel: break; } /////////////////////////// // Set up // /////////////////////////// info.m_availableIn = ItemClass.Availability.All; info.m_createPavement = (version == NetInfoVersion.Slope); info.m_createGravel = (version == NetInfoVersion.Ground); info.m_averageVehicleLaneSpeed = 2f; info.m_hasParkingSpaces = false; info.m_hasPedestrianLanes = false; info.m_UnlockMilestone = highwayInfo.m_UnlockMilestone; // Disabling Parkings and Peds foreach (var l in info.m_lanes) { switch (l.m_laneType) { case NetInfo.LaneType.Parking: l.m_laneType = NetInfo.LaneType.None; break; case NetInfo.LaneType.Pedestrian: l.m_laneType = NetInfo.LaneType.None; break; } } // Setting up lanes var vehiculeLanes = info.m_lanes .Where(l => l.m_laneType != NetInfo.LaneType.None) .OrderBy(l => l.m_similarLaneIndex) .ToArray(); var nbLanes = vehiculeLanes.Count(); // Supposed to be 6 const float laneWidth = 2f; // TODO: Make it 2.5 with new texture const float laneWidthPad = 1f; const float laneWidthTotal = laneWidth + laneWidthPad; var positionStart = (laneWidthTotal * ((1f - nbLanes) / 2f)); for (int i = 0; i < vehiculeLanes.Length; i++) { var l = vehiculeLanes[i]; l.m_allowStop = false; l.m_speedLimit = 2f; if (version == NetInfoVersion.Ground) { l.m_verticalOffset = 0f; } l.m_width = laneWidthTotal; l.m_position = positionStart + i * laneWidthTotal; } if (version == NetInfoVersion.Ground) { var hwPlayerNetAI = highwayInfo.GetComponent <PlayerNetAI>(); var playerNetAI = info.GetComponent <PlayerNetAI>(); if (hwPlayerNetAI != null && playerNetAI != null) { playerNetAI.m_constructionCost = hwPlayerNetAI.m_constructionCost * 2; playerNetAI.m_maintenanceCost = hwPlayerNetAI.m_maintenanceCost * 2; } } else // Same as the original oneway { } var roadBaseAI = info.GetComponent <RoadBaseAI>(); if (roadBaseAI != null) { roadBaseAI.m_highwayRules = true; roadBaseAI.m_trafficLights = false; } var roadAI = info.GetComponent <RoadAI>(); if (roadAI != null) { roadAI.m_enableZoning = false; } info.SetHighwayProps(highwayInfo); info.TrimHighwayProps(); }
public void ModifyExistingNetInfo() { var highwayRampInfo = ToolsCSL.FindPrefab <NetInfo>("HighwayRamp"); highwayRampInfo.m_UIPriority = highwayRampInfo.m_UIPriority + 1; }
public void BuildUp(NetInfo info, NetInfoVersion version) { /////////////////////////// // Template // /////////////////////////// var basicRoadInfo = ToolsCSL.FindPrefab <NetInfo>("Basic Road"); /////////////////////////// // 3DModeling // /////////////////////////// // NOTE: Lets dont go there yet, since we will need Segment, Bus stop, transition and transition bus stop meshes. // Otherwise, we will be forced to unsupport the bus stops on the Small Avenue, which will cause crash on people allready using it with bus stops. //if (version == NetInfoVersion.Ground) //{ // info.m_surfaceLevel = 0; // info.m_class = basicRoadInfo.m_class.Clone("SmallAvenue"); // var segments0 = info.m_segments[0]; // var nodes0 = info.m_nodes[0]; // var grndMesh = SmallAvenue4LMeshes.GetGroundData().CreateMesh("SMALLROAD_4L_GROUND"); // segments0.m_mesh = grndMesh; // nodes0.m_mesh = grndMesh; //} /////////////////////////// // Texturing // /////////////////////////// switch (version) { case NetInfoVersion.Ground: info.SetSegmentsTexture( new TexturesSet (@"NewNetwork\SmallAvenue4L\Textures\Ground_Segment__MainTex.png", @"NewNetwork\SmallAvenue4L\Textures\Ground_Segment__AlphaMap.png")); break; } /////////////////////////// // Set up // /////////////////////////// info.m_hasParkingSpaces = false; // Setting up lanes var vehicleLaneTypes = new[] { NetInfo.LaneType.Vehicle, NetInfo.LaneType.PublicTransport, NetInfo.LaneType.CargoVehicle, NetInfo.LaneType.TransportVehicle }; var vehicleLanes = info.m_lanes .Where(l => l.m_laneType.HasFlag(NetInfo.LaneType.Parking) || vehicleLaneTypes.Contains(l.m_laneType)) .OrderBy(l => l.m_position) .ToArray(); for (int i = 0; i < vehicleLanes.Length; i++) { var lane = vehicleLanes[i]; if (lane.m_laneType.HasFlag(NetInfo.LaneType.Parking)) { int closestVehicleLaneId; if (i - 1 >= 0 && vehicleLaneTypes.Contains(vehicleLanes[i - 1].m_laneType)) { closestVehicleLaneId = i - 1; } else if (i + 1 < vehicleLanes.Length && vehicleLaneTypes.Contains(vehicleLanes[i + 1].m_laneType)) { closestVehicleLaneId = i + 1; } else { continue; // Not supposed to happen } var closestVehicleLane = vehicleLanes[closestVehicleLaneId]; SetLane(lane, closestVehicleLane); if (lane.m_position < 0) { lane.m_position += 0.3f; } else { lane.m_position -= 0.3f; } } else { if (lane.m_position < 0) { lane.m_position += 0.2f; } else { lane.m_position -= 0.2f; } } } if (version == NetInfoVersion.Ground) { var brPlayerNetAI = basicRoadInfo.GetComponent <PlayerNetAI>(); var playerNetAI = info.GetComponent <PlayerNetAI>(); if (brPlayerNetAI != null && playerNetAI != null) { playerNetAI.m_constructionCost = brPlayerNetAI.m_constructionCost * 12 / 10; // 20% increase playerNetAI.m_maintenanceCost = brPlayerNetAI.m_maintenanceCost * 12 / 10; // 20% increase } } else // Same as the original basic road specs { } // Should we put traffic lights? //var roadBaseAI = info.GetComponent<RoadBaseAI>(); //if (roadBaseAI != null) //{ // roadBaseAI.m_trafficLights = true; //} }