public static bool Prefix(ref NetNode __instance, ushort nodeID, BuildingInfo newBuilding, float heightOffset) { float num = 0f; if ((object)newBuilding != null) { NetInfo info = __instance.Info; if ((object)info != null) { num = info.m_netAI.GetNodeBuildingAngle(nodeID, ref __instance); } } BuildingInfo buildingInfo = null; if (__instance.m_building != 0) { buildingInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[__instance.m_building].Info; } if ((object)newBuilding != buildingInfo) { if (__instance.m_building != 0) { Singleton <BuildingManager> .instance.ReleaseBuilding(__instance.m_building); __instance.m_building = 0; } if ((object)newBuilding != null) { Vector3 position = __instance.m_position; position.y += heightOffset; // NON-STOCK CODE STARTS if (CSURUtil.IsCSUROffset(__instance.Info)) { float laneOffset = 0; float startOffset = 0; float endOffset = 0; if (CSURUtil.IsCSURSLane(__instance.Info, ref laneOffset, ref startOffset, ref endOffset)) { bool lht = false; if (__instance.CountSegments() != 0) { float collisionHalfWidth = 0; float vehicleLaneNum = CSURUtil.CountCSURSVehicleLanes(__instance.Info); float otherLaneNum = CSURUtil.CountCSURSOtherLanes(__instance.Info); float laneNum = otherLaneNum + vehicleLaneNum; if (CSURUtil.isStartNode(nodeID)) { if (startOffset != 0) { collisionHalfWidth = startOffset * 3.75f - laneNum * 1.875f + 1.875f + otherLaneNum * 3.75f; } } else { if (endOffset != 0) { collisionHalfWidth = endOffset * 3.75f - laneNum * 1.875f + 1.875f + otherLaneNum * 3.75f; } } NetSegment mysegment = CSURUtil.GetSameInfoSegment(__instance); Vector3 direction = CSURUtil.CheckNodeEq(mysegment.m_startNode, __instance) ? mysegment.m_startDirection : -mysegment.m_endDirection; if ((mysegment.m_flags & NetSegment.Flags.Invert) != 0) { lht = true; } // normal to the right hand side Vector3 normal = new Vector3(direction.z, 0, -direction.x).normalized; position = position + (lht ? -collisionHalfWidth : collisionHalfWidth) * normal; } } else { bool lht = false; if (__instance.CountSegments() != 0) { float collisionHalfWidth = Mathf.Max(3f, (__instance.Info.m_halfWidth + __instance.Info.m_pavementWidth) / 2f); NetSegment mysegment = CSURUtil.GetSameInfoSegment(__instance); Vector3 direction = CSURUtil.CheckNodeEq(mysegment.m_startNode, __instance) ? mysegment.m_startDirection : -mysegment.m_endDirection; if ((mysegment.m_flags & NetSegment.Flags.Invert) != 0) { lht = true; } // normal to the right hand side Vector3 normal = new Vector3(direction.z, 0, -direction.x).normalized; position = position + (lht ? -collisionHalfWidth : collisionHalfWidth) * normal; } } } // NON-STOCK CODE ENDS num *= 6.28318548f; if ((object)buildingInfo != null || TestNodeBuilding(nodeID, newBuilding, position, num)) { Randomizer randomizer = new Randomizer(nodeID); if (Singleton <BuildingManager> .instance.CreateBuilding(out __instance.m_building, ref randomizer, newBuilding, position, num, 0, __instance.m_buildIndex + 1)) { Singleton <BuildingManager> .instance.m_buildings.m_buffer[__instance.m_building].m_flags |= (Building.Flags.Untouchable | Building.Flags.FixedHeight); } } } } else if (__instance.m_building != 0) { BuildingManager instance = Singleton <BuildingManager> .instance; Vector3 position2 = __instance.m_position; position2.y += heightOffset; // NON-STOCK CODE STARTS if (CSURUtil.IsCSUROffset(__instance.Info)) { float laneOffset = 0; float startOffset = 0; float endOffset = 0; if (CSURUtil.IsCSURSLane(__instance.Info, ref laneOffset, ref startOffset, ref endOffset)) { bool lht = false; if (__instance.CountSegments() != 0) { float collisionHalfWidth = 0; float vehicleLaneNum = CSURUtil.CountCSURSVehicleLanes(__instance.Info); float otherLaneNum = CSURUtil.CountCSURSOtherLanes(__instance.Info); float laneNum = otherLaneNum + vehicleLaneNum; if (CSURUtil.isStartNode(nodeID)) { if (startOffset != 0) { collisionHalfWidth = startOffset * 3.75f - laneNum * 1.875f + 1.875f + otherLaneNum * 3.75f; } } else { if (endOffset != 0) { collisionHalfWidth = endOffset * 3.75f - laneNum * 1.875f + 1.875f + otherLaneNum * 3.75f; } } NetSegment mysegment = CSURUtil.GetSameInfoSegment(__instance); Vector3 direction = CSURUtil.CheckNodeEq(mysegment.m_startNode, __instance) ? mysegment.m_startDirection : -mysegment.m_endDirection; if ((mysegment.m_flags & NetSegment.Flags.Invert) != 0) { lht = true; } // normal to the right hand side Vector3 normal = new Vector3(direction.z, 0, -direction.x).normalized; position2 = position2 + (lht ? -collisionHalfWidth : collisionHalfWidth) * normal; } } else { bool lht = false; if (__instance.CountSegments() != 0) { float collisionHalfWidth = Mathf.Max(3f, (__instance.Info.m_halfWidth + __instance.Info.m_pavementWidth) / 2f); NetSegment mysegment = CSURUtil.GetSameInfoSegment(__instance); Vector3 direction = CSURUtil.CheckNodeEq(mysegment.m_startNode, __instance) ? mysegment.m_startDirection : -mysegment.m_endDirection; if ((mysegment.m_flags & NetSegment.Flags.Invert) != 0) { lht = true; } // normal to the right hand side Vector3 normal = new Vector3(direction.z, 0, -direction.x).normalized; position2 = position2 + (lht ? -collisionHalfWidth : collisionHalfWidth) * normal; } } } // NON-STOCK CODE ENDS num *= 6.28318548f; // NON-STOCK CODE STARTS if (CSURUtil.IsCSUROffset(__instance.Info) && (instance.m_buildings.m_buffer[__instance.m_building].m_position != position2 || instance.m_buildings.m_buffer[__instance.m_building].m_angle != num)) { RemoveFromGrid(__instance.m_building, ref instance.m_buildings.m_buffer[__instance.m_building]); instance.m_buildings.m_buffer[__instance.m_building].m_position = position2; instance.m_buildings.m_buffer[__instance.m_building].m_angle = num; AddToGrid(__instance.m_building, ref instance.m_buildings.m_buffer[__instance.m_building]); instance.m_buildings.m_buffer[__instance.m_building].CalculateBuilding(__instance.m_building); Singleton <BuildingManager> .instance.UpdateBuildingRenderer(__instance.m_building, true); } else { if (instance.m_buildings.m_buffer[__instance.m_building].m_position.y != position2.y || instance.m_buildings.m_buffer[__instance.m_building].m_angle != num) { instance.m_buildings.m_buffer[__instance.m_building].m_position.y = position2.y; instance.m_buildings.m_buffer[__instance.m_building].m_angle = num; instance.UpdateBuilding(__instance.m_building); } } // NON-STOCK CODE ENDS } return(false); }