Ejemplo n.º 1
0
        public static void FixMaxTurnAngles()
        {
            if (!DCRConfig.Config.RemoveDCRestrictionsAngle)
            {
                Log.Info($"skipping {ThisMethod} because RemoveDCRestrictionsAngle={DCRConfig.Config.RemoveDCRestrictionsAngle}");
                return;
            }

            Log.Called();
            foreach (NetInfo netInfo in IterateRoadPrefabs())
            {
                try {
                    if (netInfo.m_connectGroup == NetInfo.ConnectGroup.None)
                    {
                        continue;
                    }
                    bool hasTracks = false;
                    foreach (var nodeInfo in netInfo.m_nodes)
                    {
                        bool isMedian = DCUtil.IsMedian(nodeInfo: nodeInfo, netInfo: netInfo);
                        hasTracks = nodeInfo.m_directConnect && !isMedian;
                    }
                    if (!hasTracks)
                    {
                        if (!OriginalTurnAngles.ContainsKey(netInfo))
                        {
                            OriginalTurnAngles[netInfo] = netInfo.m_maxTurnAngle;
                        }
                        netInfo.SetMaxTurnAngle(180);
                    }
                } catch (Exception e) {
                    Log.Error(e.ToString());
                }
            } // end for
        }
Ejemplo n.º 2
0
 public static bool HasDCMedian(NetInfo netInfo)
 {
     foreach (NetInfo.Node nodeInfo in netInfo.m_nodes)
     {
         bool isDC = nodeInfo.m_directConnect && nodeInfo.m_connectGroup != 0;
         if (isDC && DCUtil.IsMedian(nodeInfo, netInfo))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public static void FixDCFlags()
        {
            Log.Called();
            foreach (NetInfo netInfo in IterateRoadPrefabs())
            {
                try {
                    if (netInfo?.m_netAI == null || netInfo.m_nodes == null)
                    {
                        continue;
                    }
                    foreach (var nodeInfo in netInfo.m_nodes)
                    {
                        if (!nodeInfo.m_directConnect)
                        {
                            continue;
                        }
                        bool isMedian = DCUtil.IsMedian(nodeInfo: nodeInfo, netInfo: netInfo);
                        if (!isMedian)
                        {
                            continue;
                        }

                        var flags = nodeInfo.m_flagsForbidden;
                        if (DCRConfig.Config.RemoveDCRestrictionsTransition)
                        {
                            flags &= ~NetNode.Flags.Transition;
                        }
                        if (DCRConfig.Config.RemoveDCRestrictionsTL)
                        {
                            flags &= ~NetNode.Flags.TrafficLights;
                        }
                        if (nodeInfo.m_flagsForbidden != flags)
                        {
                            OriginalForbiddenFalgs[nodeInfo] = nodeInfo.m_flagsForbidden;
                            nodeInfo.m_flagsForbidden        = flags;
                        }
                    }
                } catch (Exception e) {
                    Log.Error(e.ToString());
                }
            } // end for
        }