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); }
public static void CachePrefabs() { Log.Info("CachePrefabs() called ..."); Log.Info("Assembly is " + typeof(PrefabUtils).Assembly); Extensions.Init(); TMPEUTILS.Init(); NS2Utils.Init(); #if !DEBUG if (!Extensions.IsActive) { Log.Info("skipped caching prefabs in asset editor/map/scenario/... release build"); return; } #endif NetInfoExt.InitNetInfoExtArray(); TextureUtils.Init(); MaterialUtils.Init(); 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(); if (!segment.Info) { continue; } ushort nodeID = bStartNode ? segment.m_startNode : segment.m_endNode; foreach (var node in segment.Info.m_nodes) { if (node.m_directConnect) { continue; } var flags = nodeID.ToNode().m_flags; //cache: //Log.Info("Caching " + segment.Info.name); if (nodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.Junction)) { CalculateMaterialCommons.CalculateMaterial(node.m_nodeMaterial, nodeID, segmentID); } } } } } PrefabsLoaded = true; Log.Info("all prefabs cached"); }
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); }
public void MakeSettings(UIHelperBase helperBase) { UIHelper helper = helperBase as UIHelper; UIComponent container = helper.self as UIComponent; Extensions.Init(); bool active = Extensions.IsActive; #if DEBUG active = true; // Fast test of options from main menu #endif void RefreshPrefabs() { if (PrefabUtils.PrefabsLoaded) { NetInfoExt.InitNetInfoExtArray(); } } if (active) { _ui_never = container.AddUIComponent <UICheckboxDropDownExt>(); _ui_never.Title = "Except List"; _ui_never.tooltip = "TMPE cannot hide crosswalks from roads in this list.\nThis list does not affect NS2 junction markings."; _ui_never.selectedItems = Split(loaded_never); void HandleAfterDropdownClose(UICheckboxDropDown _) => RefreshPrefabs(); _ui_never.eventAfterDropdownClose += HandleAfterDropdownClose; RefreshPrefabs(); helper.AddButton("Save", Save); } else { var label = container.AddUIComponent <UILabel>(); label.text = "Options are only available in game"; } }
public static bool CanHideMarkings(NetInfo info) => NetInfoExt.GetCanHideMarkings(info);