public static bool ShouldHideCrossing(ushort nodeID, ushort segmentID)
        {
#if !DEBUG
            if (!Extensions.IsActiveFast)
            {
                // do not hide crossings in asset editor.
                return(false);
            }
#endif
            // TODO move to netnode.updateflags
            NetInfo info       = segmentID.ToSegment().Info;
            bool    isJunction = nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction);
            Extensions.Assert(isJunction, $"isJunction | segmentID:{segmentID} nodeID:{nodeID}");
            bool ret0 = NetInfoExt.GetCanHideMarkings(info);

#if DEBUG
            if (Extensions.InAssetEditor)
            {
                //Log._Debug($"Should hide crossings: {ret0} | stack:\n" + System.Environment.StackTrace);
                return(ret0); // always hide crossings in asset editor for quick testing.
            }
#endif
            bool ret1 = TMPEUTILS.HasCrossingBan(segmentID, nodeID) & NetInfoExt.GetCanHideCrossings(info);
            bool ret2 = ret0 & NS2Utils.HideJunctionMarkings(segmentID);
            bool ret  = ret1 | ret2;
            // Log._Debug($"ShouldHideCrossing segmentID={segmentID} nodeID={nodeID} ret0:{ret0} ret1:{ret1} ret2:{ret2} ret:{ret}");
            return(ret);
        }
Пример #2
0
        public static bool ShouldHideCrossing(ushort nodeID, ushort segmentID) {
#if DEBUG
            if(Extensions.currentMode == AppMode.AssetEditor) {
                return true; // always hide crossings in asset editor for quick testing.
            }
#endif
            NetInfo info = segmentID.ToSegment().Info;
            bool ret1 = info.CanHideCrossings() && TMPEUTILS.HasCrossingBan(segmentID, nodeID);
            bool ret2 = info.CanHideMarkings() && NS2Utils.HideJunction(segmentID);

            //Texture cache is not broken.
            bool ret = PrefabUtils.MaterialCache != null;
            ret &= ret1 || ret2;
            return ret;
        }
        public static bool ShouldHideCrossing(ushort nodeID, ushort segmentID)
        {
            // TODO move to netnode.updateflags or something
            NetInfo info = segmentID.ToSegment().Info;

            // this assertion can fail due to race condition (when node controller post chanes node).
            // therefore i am commenting this out.
            // it would be nice to move as much of this code in simulation thread (eg netnode.updateflags)
            //bool isJunction = nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction);
            //Assertion.Assert(isJunction, $"isJunction | segmentID:{segmentID} nodeID:{nodeID}");

            bool ret0 = NetInfoExt.GetCanHideMarkings(info);
            bool ret1 = TMPEUTILS.HasCrossingBan(segmentID, nodeID) & NetInfoExt.GetCanHideCrossings(info);
            bool ret2 = ret0 & NS2Utils.HideJunctionMarkings(segmentID);
            bool ret  = ret1 | ret2;

            // Log.Debug($"ShouldHideCrossing segmentID={segmentID} nodeID={nodeID} ret0:{ret0} ret1:{ret1} ret2:{ret2} ret:{ret}");
            return(ret);
        }
Пример #4
0
 public static void BannAllCrossings()
 {
     Log.Info("BENCHMARK> BannAllCrossings started ... ");
     for (ushort segmentID = 0; segmentID < NetManager.MAX_SEGMENT_COUNT; ++segmentID)
     {
         foreach (bool bStartNode in new bool[] { false, true })
         {
             if (TMPEUTILS.HasCrossingBan(segmentID, bStartNode))
             {
                 NetSegment segment = segmentID.ToSegment();
                 ushort     nodeID  = bStartNode ? segment.m_startNode : segment.m_endNode;
                 var        flags   = nodeID.ToNode().m_flags;
                 //Ban:
                 TrafficManager.Manager.Impl.JunctionRestrictionsManager.Instance.
                 SetPedestrianCrossingAllowed(segmentID, bStartNode, false);
             }
         }
     }
     Log.Info("BENCHMARK> BannAllCrossings Done!");
 }
        public static bool ShouldHideCrossing(ushort nodeID, ushort segmentID) {
#if DEBUG
            if(Extensions.currentMode == AppMode.AssetEditor) {
                return true; // always hide crossings in asset editor for quick testing.
            }
#endif
            NetInfo info = segmentID.ToSegment().Info;
            bool ret = info.m_netAI is RoadBaseAI && TMPEUTILS.HasCrossingBan(segmentID, nodeID);
            // roads without pedesterian lanes (eg highways) have no crossings to hide to the best of my knowledege.
            // not sure about custom highways. Processing texture for such roads may reduce smoothness of the transition.
            ret &= info.m_hasPedestrianLanes;

            //Texture cache is not broken.
            ret &= PrefabUtils.MaterialCache != null;

            //TODO optimize
            //bool never = PrefabUtils.NeverZebra(info);
            //bool always = PrefabUtils.AlwaysZebra(info);
            //ret |= always;
            //ret &= !never;

            return ret;
        }