void EnableIcons()
        {
            RoadCustomizerTool rct = ToolsModifierControl.GetCurrentTool <RoadCustomizerTool>();

            if (rct != null)
            {
                ExtendedVehicleType restrictions = rct.GetCurrentVehicleRestrictions();
                float speed = rct.GetCurrentSpeedRestrictions() * 50f;

                for (int i = 0; i < this.m_scrollablePanel.components.Count; i++)
                {
                    UIButton btn = this.m_scrollablePanel.components[i] as UIButton;

                    if (this.m_panelType == Panel.VehicleRestrictions)
                    {
                        ExtendedVehicleType vehicleType = (ExtendedVehicleType)btn.objectUserData;

                        if ((vehicleType & restrictions) == vehicleType)
                        {
                            btn.stringUserData  = "Selected";
                            btn.normalFgSprite  = btn.name;
                            btn.focusedFgSprite = btn.name;
                            btn.hoveredFgSprite = btn.name + "90%";
                            btn.pressedFgSprite = btn.name + "80%";
                        }
                        else if (vehicleType == ExtendedVehicleType.EmergencyVehicles && (restrictions & ExtendedVehicleType.Emergency) == ExtendedVehicleType.Emergency)
                        {
                            btn.stringUserData  = "Emergency";
                            btn.hoveredFgSprite = btn.name + "90%";
                            btn.pressedFgSprite = btn.name + "80%";
                            StartCoroutine("EmergencyLights", btn);
                        }
                        else
                        {
                            btn.stringUserData  = null;
                            btn.normalFgSprite  = btn.name + "Deselected";
                            btn.focusedFgSprite = btn.name + "Deselected";
                            btn.hoveredFgSprite = btn.name + "80%";
                            btn.pressedFgSprite = btn.name + "90%";
                        }
                        btn.state = UIButton.ButtonState.Normal;
                    }
                    else if (this.m_panelType == Panel.SpeedRestrictions)
                    {
                        if (Mathf.Approximately((int)btn.objectUserData, speed))
                        {
                            m_selectedIndex = i;
                        }
                    }

                    btn.isEnabled = true;
                }
            }
        }
Exemplo n.º 2
0
        protected override bool StartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget)
        {
            ExtendedVehicleType vehicleType = ExtendedVehicleType.PoliceCar;

            if ((vehicleData.m_flags & Vehicle.Flags.Emergency2) != 0)
            {
                vehicleType |= ExtendedVehicleType.Emergency;
            }

            VehicleInfo info             = this.m_info;
            bool        allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;

            PathUnit.Position startPosA;
            PathUnit.Position startPosB;
            float             num;
            float             num2;

            PathUnit.Position endPosA;
            PathUnit.Position endPosB;
            float             num3;
            float             num4;

            if (PathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out num, out num2) && PathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out num3, out num4))
            {
                if (!startBothWays || num < 10f)
                {
                    startPosB = default(PathUnit.Position);
                }
                if (!endBothWays || num3 < 10f)
                {
                    endPosB = default(PathUnit.Position);
                }
                uint path;
                bool createPathResult = Singleton <PathManager> .instance.CreatePath(vehicleType, out path, ref Singleton <SimulationManager> .instance.m_randomizer, Singleton <SimulationManager> .instance.m_currentBuildIndex, startPosA, startPosB, endPosA, endPosB, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, 20000f, this.IsHeavyVehicle(), this.IgnoreBlocked(vehicleID, ref vehicleData), false, false);

                if (createPathResult)
                {
                    if (vehicleData.m_path != 0u)
                    {
                        Singleton <PathManager> .instance.ReleasePath(vehicleData.m_path);
                    }
                    vehicleData.m_path   = path;
                    vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
                    return(true);
                }
            }
            return(false);
        }
        public ExtendedVehicleType ToggleRestriction(ExtendedVehicleType vehicleType)
        {
            if (!AnyLaneSelected)
            {
                return(ExtendedVehicleType.None);
            }

            ExtendedVehicleType vehicleRestrictions = LaneManager.GetVehicleRestrictions(m_selectedLaneMarkers[0].m_lane);

            vehicleRestrictions ^= vehicleType;

            foreach (SegmentLaneMarker lane in m_selectedLaneMarkers)
            {
                LaneManager.SetVehicleRestrictions(lane.m_lane, vehicleRestrictions);
            }

            return(vehicleRestrictions);
        }
Exemplo n.º 4
0
        public static bool CanUseLane(this NetInfo.Lane laneInfo, ExtendedVehicleType vehicleType, uint laneId)
        {
            if ((vehicleType & sm_routedUnits) == 0)
            {
                return(true);
            }

            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Car) == VehicleInfo.VehicleType.None)
            {
                return(true);
            }

            // Quick fix for tram
            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Tram) != VehicleInfo.VehicleType.None)
            {
                return(true);
            }

            return((GetLane(laneId).m_vehicleTypes & vehicleType) != ExtendedVehicleType.None);
        }
Exemplo n.º 5
0
        public static bool CheckLaneConnection(this NetInfo.Lane laneInfo, ExtendedVehicleType vehicleType, uint from, uint to)
        {
            if ((vehicleType & sm_routedUnits) == 0)
            {
                return true;
            }

            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Car) == VehicleInfo.VehicleType.None)
            {
                return true;
            }

            // Quick fix for tram
            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Tram) != VehicleInfo.VehicleType.None)
            {
                return true;
            }

            Lane lane = GetLane(from);

            return lane.ConnectsTo(to);
        }
Exemplo n.º 6
0
        public static bool CheckLaneConnection(this NetInfo.Lane laneInfo, ExtendedVehicleType vehicleType, uint from, uint to)
        {
            if ((vehicleType & sm_routedUnits) == 0)
            {
                return(true);
            }

            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Car) == VehicleInfo.VehicleType.None)
            {
                return(true);
            }

            // Quick fix for tram
            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Tram) != VehicleInfo.VehicleType.None)
            {
                return(true);
            }

            Lane lane = GetLane(from);

            return(lane.ConnectsTo(to));
        }
Exemplo n.º 7
0
        public static bool StartPathFind(this CarAI carAI, ExtendedVehicleType extendedVehicleType, ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget, bool isHeavyVehicle, bool ignoreBlocked)
        {
            VehicleInfo info             = carAI.m_info;
            bool        allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;

            PathUnit.Position startPosA;
            PathUnit.Position startPosB;
            float             num;
            float             num2;

            PathUnit.Position endPosA;
            PathUnit.Position endPosB;
            float             num3;
            float             num4;

            if (PathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out num, out num2) && PathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out num3, out num4))
            {
                if (!startBothWays || num < 10f)
                {
                    startPosB = default(PathUnit.Position);
                }
                if (!endBothWays || num3 < 10f)
                {
                    endPosB = default(PathUnit.Position);
                }
                uint path;
                if (Singleton <PathManager> .instance.CreatePath(extendedVehicleType, out path, ref Singleton <SimulationManager> .instance.m_randomizer, Singleton <SimulationManager> .instance.m_currentBuildIndex, startPosA, startPosB, endPosA, endPosB, NetInfo.LaneType.Vehicle, info.m_vehicleType, 20000f, isHeavyVehicle /*carAI.IsHeavyVehicle()*/, ignoreBlocked /*carAI.IgnoreBlocked(vehicleID, ref vehicleData)*/, false, false))
                {
                    if (vehicleData.m_path != 0u)
                    {
                        Singleton <PathManager> .instance.ReleasePath(vehicleData.m_path);
                    }
                    vehicleData.m_path   = path;
                    vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
                    return(true);
                }
            }
            return(false);
        }
 public static bool StartPathFind(this CarAI carAI, ExtendedVehicleType extendedVehicleType, ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget, bool isHeavyVehicle, bool ignoreBlocked)
 {
     VehicleInfo info = carAI.m_info;
     bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != 0;
     PathUnit.Position startPosA;
     PathUnit.Position startPosB;
     float num;
     float num2;
     PathUnit.Position endPosA;
     PathUnit.Position endPosB;
     float num3;
     float num4;
     if (PathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, allowUnderground, false, 32f, out startPosA, out startPosB, out num, out num2) && PathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, undergroundTarget, false, 32f, out endPosA, out endPosB, out num3, out num4))
     {
         if (!startBothWays || num < 10f)
         {
             startPosB = default(PathUnit.Position);
         }
         if (!endBothWays || num3 < 10f)
         {
             endPosB = default(PathUnit.Position);
         }
         uint path;
         if (Singleton<PathManager>.instance.CreatePath(extendedVehicleType, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, startPosB, endPosA, endPosB, NetInfo.LaneType.Vehicle, info.m_vehicleType, 20000f, isHeavyVehicle/*carAI.IsHeavyVehicle()*/, ignoreBlocked/*carAI.IgnoreBlocked(vehicleID, ref vehicleData)*/, false, false))
         {
             if (vehicleData.m_path != 0u)
             {
                 Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
             }
             vehicleData.m_path = path;
             vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
             return true;
         }
     }
     return false;
 }
Exemplo n.º 9
0
 public void ToggleVehicleRestriction(uint laneId, ExtendedVehicleType vehicleType)
 {
     GetLane(laneId).m_vehicleTypes ^= vehicleType;
 }
Exemplo n.º 10
0
 public static void SetVehicleRestrictions(uint laneId, ExtendedVehicleType vehicleRestrictions)
 {
     GetLane(laneId).m_vehicleTypes = vehicleRestrictions;
 }
        public virtual bool CalculatePath(uint unit, bool skipQueue, ExtendedVehicleType vehicleType)
		{
			if (Singleton<PathManager>.instance.AddPathReference(unit))
			{
				while (!Monitor.TryEnter(this.m_queueLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
				{
				}
				try
				{
					if (skipQueue)
					{
						if (this.m_queueLast == 0u)
						{
							this.m_queueLast = unit;
						}
						else
						{
							this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_nextPathUnit = this.m_queueFirst;
						}
						this.m_queueFirst = unit;
					}
					else
					{
						if (this.m_queueLast == 0u)
						{
							this.m_queueFirst = unit;
						}
						else
						{
							this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_queueLast)].m_nextPathUnit = unit;
						}
						this.m_queueLast = unit;
					}

					PathUnit[] expr_BD_cp_0 = this.m_pathUnits.m_buffer;
					UIntPtr expr_BD_cp_1 = (UIntPtr)unit;
					expr_BD_cp_0[(int)expr_BD_cp_1].m_pathFindFlags = (byte)(expr_BD_cp_0[(int)expr_BD_cp_1].m_pathFindFlags | 1);
                    Facade.m_queuedPathFindCount++;
					Monitor.Pulse(this.m_queueLock);
				}
				finally
				{
					Monitor.Exit(this.m_queueLock);
				}
				return true;
			}
			return false;
		}
 public ExtendedNetInfoLane(ExtendedVehicleType vehicleTypes)
 {
     this.AllowedVehicleTypes = vehicleTypes;
 }
 public ExtendedNetInfoLane(ExtendedVehicleType vehicleTypes)
 {
     this.AllowedVehicleTypes = vehicleTypes;
 }
        public static bool CreatePath(this PathManager pm, ExtendedVehicleType extendedVehicleType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, bool randomParking)
        {
            if (ExtendedPathManager.PathFindFacades == null)
            {
                // Redirections are not installed correctly, fallbacking on the default code
                return pm.CreatePath(
                    out unit, 
                    ref randomizer, 
                    buildIndex, 
                    startPosA, 
                    startPosB, 
                    endPosA,  
                    endPosB, 
                    vehiclePosition, 
                    laneTypes, 
                    vehicleTypes, 
                    maxLength, 
                    isHeavyVehicle, 
                    ignoreBlocked, 
                    stablePath, 
                    skipQueue,
                    randomParking);
            }

            while (!Monitor.TryEnter(pm.m_bufferLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
            {
            }
            uint num;
            try
            {
                if (!pm.m_pathUnits.CreateItem(out num, ref randomizer))
                {
                    unit = 0u;
                    bool result = false;
                    return result;
                }
                pm.m_pathUnitCount = (int)(pm.m_pathUnits.ItemCount() - 1u);
            }
            finally
            {
                Monitor.Exit(pm.m_bufferLock);
            }
            unit = num;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_simulationFlags = 1;
            if (isHeavyVehicle)
            {
                PathUnit[] expr_92_cp_0 = pm.m_pathUnits.m_buffer;
                UIntPtr expr_92_cp_1 = (UIntPtr)unit;
                expr_92_cp_0[(int)expr_92_cp_1].m_simulationFlags = (byte)(expr_92_cp_0[(int)expr_92_cp_1].m_simulationFlags | 16);
            }
            if (ignoreBlocked)
            {
                PathUnit[] expr_BB_cp_0 = pm.m_pathUnits.m_buffer;
                UIntPtr expr_BB_cp_1 = (UIntPtr)unit;
                expr_BB_cp_0[(int)expr_BB_cp_1].m_simulationFlags = (byte)(expr_BB_cp_0[(int)expr_BB_cp_1].m_simulationFlags | 32);
            }
            if (stablePath)
            {
                PathUnit[] expr_E4_cp_0 = pm.m_pathUnits.m_buffer;
                UIntPtr expr_E4_cp_1 = (UIntPtr)unit;
                expr_E4_cp_0[(int)expr_E4_cp_1].m_simulationFlags = (byte)(expr_E4_cp_0[(int)expr_E4_cp_1].m_simulationFlags | 64);
            }
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_pathFindFlags = 0;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_buildIndex = buildIndex;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position00 = startPosA;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position01 = endPosA;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position02 = startPosB;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position03 = endPosB;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position11 = vehiclePosition;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_nextPathUnit = 0u;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_laneTypes = (byte)laneTypes;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_vehicleTypes = (byte)vehicleTypes;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_length = maxLength;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_positionCount = 20;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_referenceCount = 1;
            int num2 = 10000000;
            ExtendedPathFindFacade pathFindFacade = null;
            for (int i = 0; i < ExtendedPathManager.PathFindFacades.Length; i++)
            {
                ExtendedPathFindFacade pathFind2 = ExtendedPathManager.PathFindFacades[i];
                if (pathFind2.IsAvailable && pathFind2.m_queuedPathFindCount < num2)
                {
                    num2 = pathFind2.m_queuedPathFindCount;
                    pathFindFacade = pathFind2;
                }
            }
            if (pathFindFacade != null && pathFindFacade.CalculatePath(unit, skipQueue, extendedVehicleType))
            {
                return true;
            }
            pm.ReleasePath(unit);
            return false;
        }
        //// TO DEBUG
        //[RedirectFrom(typeof(PathManager))]
        //public static bool CreatePath(
        //    out uint unit,
        //    ref Randomizer randomizer,
        //    uint buildIndex,
        //    PathUnit.Position startPosA,
        //    PathUnit.Position startPosB,
        //    PathUnit.Position endPosA,
        //    PathUnit.Position endPosB,
        //    PathUnit.Position vehiclePosition,
        //    NetInfo.LaneType laneTypes,
        //    VehicleInfo.VehicleType vehicleTypes,
        //    float maxLength,
        //    bool isHeavyVehicle,
        //    bool ignoreBlocked,
        //    bool stablePath,
        //    bool skipQueue)
        //{
        //    throw new Exception("CreatePath has been called, please implement redirection to custom method");
        //}

        public static bool CreatePath(this PathManager pm, ExtendedVehicleType extendedVehicleType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPos, PathUnit.Position endPos, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength)
        {
            PathUnit.Position position = default(PathUnit.Position);
            return pm.CreatePath(extendedVehicleType, out unit, ref randomizer, buildIndex, startPos, position, endPos, position, position, laneTypes, vehicleTypes, maxLength, false, false, false, false, false);
        }
Exemplo n.º 16
0
 public static void ToggleVehicleRestriction(uint laneId, ExtendedVehicleType vehicleType)
 {
     GetLane(laneId).m_vehicleTypes ^= vehicleType;
 }
 public bool CalculatePath(uint unit, bool skipQueue, ExtendedVehicleType vehicleType)
 {
     return m_innerPathFind.CalculatePath(unit, skipQueue, vehicleType);
 }
Exemplo n.º 18
0
        protected void OnButtonClicked(UIButton btn)
        {
            if (m_panelType == Panel.VehicleRestrictions)
            {
                ExtendedVehicleType vehicleType = (ExtendedVehicleType)btn.objectUserData;
                if (vehicleType != ExtendedVehicleType.None)
                {
                    if (String.IsNullOrEmpty(btn.stringUserData))
                    {
                        btn.stringUserData  = "Selected";
                        btn.normalFgSprite  = btn.name;
                        btn.focusedFgSprite = btn.name;
                        btn.hoveredFgSprite = btn.name + "90%";
                        btn.pressedFgSprite = btn.name + "80%";
                    }
                    else if (vehicleType == ExtendedVehicleType.EmergencyVehicles && btn.stringUserData != "Emergency")
                    {
                        btn.stringUserData = "Emergency";
                        StartCoroutine("EmergencyLights", btn);
                    }
                    else
                    {
                        if (vehicleType == ExtendedVehicleType.EmergencyVehicles)
                        {
                            StopCoroutine("EmergencyLights");
                        }

                        btn.stringUserData  = null;
                        btn.normalFgSprite  = btn.name + "Deselected";
                        btn.focusedFgSprite = btn.name + "Deselected";
                        btn.hoveredFgSprite = btn.name + "80%";
                        btn.pressedFgSprite = btn.name + "90%";
                    }

                    RoadCustomizerTool rct = ToolsModifierControl.GetCurrentTool <RoadCustomizerTool>();
                    if (rct != null)
                    {
                        if (btn.stringUserData == "Emergency")
                        {
                            rct.ToggleRestriction(vehicleType ^ ExtendedVehicleType.Emergency);
                        }
                        else if (vehicleType == ExtendedVehicleType.EmergencyVehicles && btn.stringUserData == null)
                        {
                            rct.ToggleRestriction(ExtendedVehicleType.Emergency);
                        }
                        else
                        {
                            rct.ToggleRestriction(vehicleType);
                        }
                    }
                }
            }
            else if (m_panelType == Panel.SpeedRestrictions)
            {
                RoadCustomizerTool rct = ToolsModifierControl.GetCurrentTool <RoadCustomizerTool>();
                if (rct != null)
                {
                    rct.SetSpeedRestrictions((int)btn.objectUserData);
                }
            }
        }
 public static bool CreatePath(this PathManager pm, ExtendedVehicleType extendedVehicleType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue)
 {
     return pm.CreatePath(extendedVehicleType, out unit, ref randomizer, buildIndex, startPosA, startPosB, endPosA, endPosB, default(PathUnit.Position), laneTypes, vehicleTypes, maxLength, isHeavyVehicle, ignoreBlocked, stablePath, skipQueue, false);
 }
Exemplo n.º 20
0
 public bool CalculatePath(uint unit, bool skipQueue, ExtendedVehicleType vehicleType)
 {
     return(m_innerPathFind.CalculatePath(unit, skipQueue, vehicleType));
 }
 public ExtendedNetInfoLane(NetInfo.Lane lane, ExtendedVehicleType vehicleTypes)
 {
     this.AllowedVehicleTypes = vehicleTypes;
     this.ShallowCloneFrom(lane);
 }
        //// TO DEBUG
        //[RedirectFrom(typeof(PathManager))]
        //public static bool CreatePath(
        //    out uint unit,
        //    ref Randomizer randomizer,
        //    uint buildIndex,
        //    PathUnit.Position startPosA,
        //    PathUnit.Position startPosB,
        //    PathUnit.Position endPosA,
        //    PathUnit.Position endPosB,
        //    PathUnit.Position vehiclePosition,
        //    NetInfo.LaneType laneTypes,
        //    VehicleInfo.VehicleType vehicleTypes,
        //    float maxLength,
        //    bool isHeavyVehicle,
        //    bool ignoreBlocked,
        //    bool stablePath,
        //    bool skipQueue)
        //{
        //    throw new Exception("CreatePath has been called, please implement redirection to custom method");
        //}

        public static bool CreatePath(this PathManager pm, ExtendedVehicleType extendedVehicleType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPos, PathUnit.Position endPos, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength)
        {
            PathUnit.Position position = default(PathUnit.Position);
            return(pm.CreatePath(extendedVehicleType, out unit, ref randomizer, buildIndex, startPos, position, endPos, position, position, laneTypes, vehicleTypes, maxLength, false, false, false, false, false));
        }
 public ExtendedNetInfoLane(NetInfo.Lane lane, ExtendedVehicleType vehicleTypes)
 {
     this.AllowedVehicleTypes = vehicleTypes;
     this.ShallowCloneFrom(lane);
 }
 public static bool CreatePath(this PathManager pm, ExtendedVehicleType extendedVehicleType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue)
 {
     return(pm.CreatePath(extendedVehicleType, out unit, ref randomizer, buildIndex, startPosA, startPosB, endPosA, endPosB, default(PathUnit.Position), laneTypes, vehicleTypes, maxLength, isHeavyVehicle, ignoreBlocked, stablePath, skipQueue, false));
 }
Exemplo n.º 25
0
 public static bool StartPathFind(this CarAI carAI, ExtendedVehicleType extendedVehicleType, ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool isHeavyVehicle, bool ignoreBlocked)
 {
     return(carAI.StartPathFind(extendedVehicleType, vehicleID, ref vehicleData, startPos, endPos, true, true, false, isHeavyVehicle, ignoreBlocked));
 }
        public static bool CreatePath(this PathManager pm, ExtendedVehicleType extendedVehicleType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, bool randomParking)
        {
            if (ExtendedPathManager.PathFindFacades == null)
            {
                // Redirections are not installed correctly, fallbacking on the default code
                return(pm.CreatePath(
                           out unit,
                           ref randomizer,
                           buildIndex,
                           startPosA,
                           startPosB,
                           endPosA,
                           endPosB,
                           vehiclePosition,
                           laneTypes,
                           vehicleTypes,
                           maxLength,
                           isHeavyVehicle,
                           ignoreBlocked,
                           stablePath,
                           skipQueue,
                           randomParking));
            }

            while (!Monitor.TryEnter(pm.m_bufferLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
            {
            }
            uint num;

            try
            {
                if (!pm.m_pathUnits.CreateItem(out num, ref randomizer))
                {
                    unit = 0u;
                    bool result = false;
                    return(result);
                }
                pm.m_pathUnitCount = (int)(pm.m_pathUnits.ItemCount() - 1u);
            }
            finally
            {
                Monitor.Exit(pm.m_bufferLock);
            }
            unit = num;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_simulationFlags = 1;
            if (isHeavyVehicle)
            {
                PathUnit[] expr_92_cp_0 = pm.m_pathUnits.m_buffer;
                UIntPtr    expr_92_cp_1 = (UIntPtr)unit;
                expr_92_cp_0[(int)expr_92_cp_1].m_simulationFlags = (byte)(expr_92_cp_0[(int)expr_92_cp_1].m_simulationFlags | 16);
            }
            if (ignoreBlocked)
            {
                PathUnit[] expr_BB_cp_0 = pm.m_pathUnits.m_buffer;
                UIntPtr    expr_BB_cp_1 = (UIntPtr)unit;
                expr_BB_cp_0[(int)expr_BB_cp_1].m_simulationFlags = (byte)(expr_BB_cp_0[(int)expr_BB_cp_1].m_simulationFlags | 32);
            }
            if (stablePath)
            {
                PathUnit[] expr_E4_cp_0 = pm.m_pathUnits.m_buffer;
                UIntPtr    expr_E4_cp_1 = (UIntPtr)unit;
                expr_E4_cp_0[(int)expr_E4_cp_1].m_simulationFlags = (byte)(expr_E4_cp_0[(int)expr_E4_cp_1].m_simulationFlags | 64);
            }
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_pathFindFlags  = 0;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_buildIndex     = buildIndex;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position00     = startPosA;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position01     = endPosA;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position02     = startPosB;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position03     = endPosB;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position11     = vehiclePosition;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_nextPathUnit   = 0u;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_laneTypes      = (byte)laneTypes;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_vehicleTypes   = (byte)vehicleTypes;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_length         = maxLength;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_positionCount  = 20;
            pm.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_referenceCount = 1;
            int num2 = 10000000;
            ExtendedPathFindFacade pathFindFacade = null;

            for (int i = 0; i < ExtendedPathManager.PathFindFacades.Length; i++)
            {
                ExtendedPathFindFacade pathFind2 = ExtendedPathManager.PathFindFacades[i];
                if (pathFind2.IsAvailable && pathFind2.m_queuedPathFindCount < num2)
                {
                    num2           = pathFind2.m_queuedPathFindCount;
                    pathFindFacade = pathFind2;
                }
            }
            if (pathFindFacade != null && pathFindFacade.CalculatePath(unit, skipQueue, extendedVehicleType))
            {
                return(true);
            }
            pm.ReleasePath(unit);
            return(false);
        }
 public static bool StartPathFind(this CarAI carAI, ExtendedVehicleType extendedVehicleType, ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool isHeavyVehicle, bool ignoreBlocked)
 {
     return carAI.StartPathFind(extendedVehicleType, vehicleID, ref vehicleData, startPos, endPos, true, true, false, isHeavyVehicle, ignoreBlocked);
 }
Exemplo n.º 28
0
        private void PathFindImplementation(uint unit, ref PathUnit data)
        {
            NetManager instance = Singleton<NetManager>.instance;
            this.m_laneTypes = (NetInfo.LaneType)this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_laneTypes;
            this.m_vehicleTypes = (VehicleInfo.VehicleType)this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_vehicleTypes;
            this.m_maxLength = this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_length;
            this.m_pathFindIndex = (this.m_pathFindIndex + 1u & 32767u);
            this.m_pathRandomizer = new Randomizer(unit);
            this.m_isHeavyVehicle = ((this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_simulationFlags & 16) != 0);
            this.m_ignoreBlocked = ((this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_simulationFlags & 32) != 0);
            this.m_stablePath = ((this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_simulationFlags & 64) != 0);
            this.m_transportVehicle = ((byte)(this.m_laneTypes & NetInfo.LaneType.TransportVehicle) != 0);
            if ((byte)(this.m_laneTypes & NetInfo.LaneType.Vehicle) != 0)
            {
                this.m_laneTypes |= NetInfo.LaneType.TransportVehicle;
            }

            if (!m_pathVehicleType.TryGetValue(unit, out m_vehicleTypeExtended))
            {
                this.m_vehicleTypeExtended = ExtendedVehicleType.Unknown;
            }

            //Logger.LogInfo("PathFindImplementation of " + m_vehicleTypeExtended);

            this.m_priorityVehicle = (this.m_vehicleTypeExtended & (ExtendedVehicleType.Bus | ExtendedVehicleType.EmergencyVehicles)) != ExtendedVehicleType.None;

            int num = (int)(this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_positionCount & 15);
            int num2 = this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_positionCount >> 4;
            BufferItem bufferItem;
            if (data.m_position00.m_segment != 0 && num >= 1)
            {
                this.m_startLaneA = PathManager.GetLaneID(data.m_position00);
                this.m_startOffsetA = data.m_position00.m_offset;
                bufferItem.m_laneID = this.m_startLaneA;
                bufferItem.m_position = data.m_position00;
                this.GetLaneDirection(data.m_position00, out bufferItem.m_direction, out bufferItem.m_lanesUsed);
                bufferItem.m_comparisonValue = 0f;
            }
            else
            {
                this.m_startLaneA = 0u;
                this.m_startOffsetA = 0;
                bufferItem = default(BufferItem);
            }
            BufferItem bufferItem2;
            if (data.m_position02.m_segment != 0 && num >= 3)
            {
                this.m_startLaneB = PathManager.GetLaneID(data.m_position02);
                this.m_startOffsetB = data.m_position02.m_offset;
                bufferItem2.m_laneID = this.m_startLaneB;
                bufferItem2.m_position = data.m_position02;
                this.GetLaneDirection(data.m_position02, out bufferItem2.m_direction, out bufferItem2.m_lanesUsed);
                bufferItem2.m_comparisonValue = 0f;
            }
            else
            {
                this.m_startLaneB = 0u;
                this.m_startOffsetB = 0;
                bufferItem2 = default(BufferItem);
            }
            BufferItem bufferItem3;
            if (data.m_position01.m_segment != 0 && num >= 2)
            {
                this.m_endLaneA = PathManager.GetLaneID(data.m_position01);
                bufferItem3.m_laneID = this.m_endLaneA;
                bufferItem3.m_position = data.m_position01;
                this.GetLaneDirection(data.m_position01, out bufferItem3.m_direction, out bufferItem3.m_lanesUsed);
                bufferItem3.m_methodDistance = 0f;
                bufferItem3.m_comparisonValue = 0f;
            }
            else
            {
                this.m_endLaneA = 0u;
                bufferItem3 = default(BufferItem);
            }
            BufferItem bufferItem4;
            if (data.m_position03.m_segment != 0 && num >= 4)
            {
                this.m_endLaneB = PathManager.GetLaneID(data.m_position03);
                bufferItem4.m_laneID = this.m_endLaneB;
                bufferItem4.m_position = data.m_position03;
                this.GetLaneDirection(data.m_position03, out bufferItem4.m_direction, out bufferItem4.m_lanesUsed);
                bufferItem4.m_methodDistance = 0f;
                bufferItem4.m_comparisonValue = 0f;
            }
            else
            {
                this.m_endLaneB = 0u;
                bufferItem4 = default(BufferItem);
            }
            if (data.m_position11.m_segment != 0 && num2 >= 1)
            {
                this.m_vehicleLane = PathManager.GetLaneID(data.m_position11);
                this.m_vehicleOffset = data.m_position11.m_offset;
            }
            else
            {
                this.m_vehicleLane = 0u;
                this.m_vehicleOffset = 0;
            }
            BufferItem bufferItem5 = default(BufferItem);
            byte b = 0;
            this.m_bufferMinPos = 0;
            this.m_bufferMaxPos = -1;
            if (this.m_pathFindIndex == 0u)
            {
                uint num3 = 4294901760u;
                for (int i = 0; i < 262144; i++)
                {
                    this.m_laneLocation[i] = num3;
                }
            }
            for (int j = 0; j < 1024; j++)
            {
                this.m_bufferMin[j] = 0;
                this.m_bufferMax[j] = -1;
            }
            if (bufferItem3.m_position.m_segment != 0)
            {
                this.m_bufferMax[0]++;
                this.m_buffer[++this.m_bufferMaxPos] = bufferItem3;
            }
            if (bufferItem4.m_position.m_segment != 0)
            {
                this.m_bufferMax[0]++;
                this.m_buffer[++this.m_bufferMaxPos] = bufferItem4;
            }
            bool flag = false;
            while (this.m_bufferMinPos <= this.m_bufferMaxPos)
            {
                int num4 = this.m_bufferMin[this.m_bufferMinPos];
                int num5 = this.m_bufferMax[this.m_bufferMinPos];
                if (num4 > num5)
                {
                    this.m_bufferMinPos++;
                }
                else
                {
                    this.m_bufferMin[this.m_bufferMinPos] = num4 + 1;
                    BufferItem bufferItem6 = this.m_buffer[(this.m_bufferMinPos << 6) + num4];
                    if (bufferItem6.m_position.m_segment == bufferItem.m_position.m_segment && bufferItem6.m_position.m_lane == bufferItem.m_position.m_lane)
                    {
                        if ((byte)(bufferItem6.m_direction & NetInfo.Direction.Forward) != 0 && bufferItem6.m_position.m_offset >= this.m_startOffsetA)
                        {
                            bufferItem5 = bufferItem6;
                            b = this.m_startOffsetA;
                            flag = true;
                            break;
                        }
                        if ((byte)(bufferItem6.m_direction & NetInfo.Direction.Backward) != 0 && bufferItem6.m_position.m_offset <= this.m_startOffsetA)
                        {
                            bufferItem5 = bufferItem6;
                            b = this.m_startOffsetA;
                            flag = true;
                            break;
                        }
                    }
                    if (bufferItem6.m_position.m_segment == bufferItem2.m_position.m_segment && bufferItem6.m_position.m_lane == bufferItem2.m_position.m_lane)
                    {
                        if ((byte)(bufferItem6.m_direction & NetInfo.Direction.Forward) != 0 && bufferItem6.m_position.m_offset >= this.m_startOffsetB)
                        {
                            bufferItem5 = bufferItem6;
                            b = this.m_startOffsetB;
                            flag = true;
                            break;
                        }
                        if ((byte)(bufferItem6.m_direction & NetInfo.Direction.Backward) != 0 && bufferItem6.m_position.m_offset <= this.m_startOffsetB)
                        {
                            bufferItem5 = bufferItem6;
                            b = this.m_startOffsetB;
                            flag = true;
                            break;
                        }
                    }
                    if ((byte)(bufferItem6.m_direction & NetInfo.Direction.Forward) != 0)
                    {
                        ushort startNode = instance.m_segments.m_buffer[(int)bufferItem6.m_position.m_segment].m_startNode;
                        this.ProcessItem(bufferItem6, startNode, ref instance.m_nodes.m_buffer[(int)startNode], 0, false);
                    }
                    if ((byte)(bufferItem6.m_direction & NetInfo.Direction.Backward) != 0)
                    {
                        ushort endNode = instance.m_segments.m_buffer[(int)bufferItem6.m_position.m_segment].m_endNode;
                        this.ProcessItem(bufferItem6, endNode, ref instance.m_nodes.m_buffer[(int)endNode], 255, false);
                    }
                    int num6 = 0;
                    ushort num7 = instance.m_lanes.m_buffer[(int)((UIntPtr)bufferItem6.m_laneID)].m_nodes;
                    if (num7 != 0)
                    {
                        ushort startNode2 = instance.m_segments.m_buffer[(int)bufferItem6.m_position.m_segment].m_startNode;
                        ushort endNode2 = instance.m_segments.m_buffer[(int)bufferItem6.m_position.m_segment].m_endNode;
                        bool flag2 = ((instance.m_nodes.m_buffer[(int)startNode2].m_flags | instance.m_nodes.m_buffer[(int)endNode2].m_flags) & NetNode.Flags.Disabled) != NetNode.Flags.None;
                        while (num7 != 0)
                        {
                            NetInfo.Direction direction = NetInfo.Direction.None;
                            byte laneOffset = instance.m_nodes.m_buffer[(int)num7].m_laneOffset;
                            if (laneOffset <= bufferItem6.m_position.m_offset)
                            {
                                direction |= NetInfo.Direction.Forward;
                            }
                            if (laneOffset >= bufferItem6.m_position.m_offset)
                            {
                                direction |= NetInfo.Direction.Backward;
                            }
                            if ((byte)(bufferItem6.m_direction & direction) != 0 && (!flag2 || (instance.m_nodes.m_buffer[(int)num7].m_flags & NetNode.Flags.Disabled) != NetNode.Flags.None))
                            {
                                this.ProcessItem(bufferItem6, num7, ref instance.m_nodes.m_buffer[(int)num7], laneOffset, true);
                            }
                            num7 = instance.m_nodes.m_buffer[(int)num7].m_nextLaneNode;
                            if (++num6 == 32768)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            if (!flag)
            {
                PathUnit[] expr_909_cp_0 = this.m_pathUnits.m_buffer;
                UIntPtr expr_909_cp_1 = (UIntPtr)unit;
                expr_909_cp_0[(int)expr_909_cp_1].m_pathFindFlags = (byte)(expr_909_cp_0[(int)expr_909_cp_1].m_pathFindFlags | 8);
                return;
            }
            float num8 = bufferItem5.m_comparisonValue * this.m_maxLength;
            this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_length = num8;
            uint num9 = unit;
            int num10 = 0;
            int num11 = 0;
            PathUnit.Position position = bufferItem5.m_position;
            if ((position.m_segment != bufferItem3.m_position.m_segment || position.m_lane != bufferItem3.m_position.m_lane || position.m_offset != bufferItem3.m_position.m_offset) && (position.m_segment != bufferItem4.m_position.m_segment || position.m_lane != bufferItem4.m_position.m_lane || position.m_offset != bufferItem4.m_position.m_offset))
            {
                if (b != position.m_offset)
                {
                    PathUnit.Position position2 = position;
                    position2.m_offset = b;
                    this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].SetPosition(num10++, position2);
                }
                this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].SetPosition(num10++, position);
                position = this.m_laneTarget[(int)((UIntPtr)bufferItem5.m_laneID)];
            }
            for (int k = 0; k < 262144; k++)
            {
                this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].SetPosition(num10++, position);
                if ((position.m_segment == bufferItem3.m_position.m_segment && position.m_lane == bufferItem3.m_position.m_lane && position.m_offset == bufferItem3.m_position.m_offset) || (position.m_segment == bufferItem4.m_position.m_segment && position.m_lane == bufferItem4.m_position.m_lane && position.m_offset == bufferItem4.m_position.m_offset))
                {
                    this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].m_positionCount = (byte)num10;
                    num11 += num10;
                    if (num11 != 0)
                    {
                        num9 = this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_nextPathUnit;
                        num10 = (int)this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_positionCount;
                        int num12 = 0;
                        while (num9 != 0u)
                        {
                            this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].m_length = num8 * (float)(num11 - num10) / (float)num11;
                            num10 += (int)this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].m_positionCount;
                            num9 = this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].m_nextPathUnit;
                            if (++num12 >= 262144)
                            {
                                CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
                                break;
                            }
                        }
                    }
                    PathUnit[] expr_C16_cp_0 = this.m_pathUnits.m_buffer;
                    UIntPtr expr_C16_cp_1 = (UIntPtr)unit;
                    expr_C16_cp_0[(int)expr_C16_cp_1].m_pathFindFlags = (byte)(expr_C16_cp_0[(int)expr_C16_cp_1].m_pathFindFlags | 4);
                    return;
                }
                if (num10 == 12)
                {
                    while (!Monitor.TryEnter(this.m_bufferLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
                    {
                    }
                    uint num13;
                    try
                    {
                        if (!this.m_pathUnits.CreateItem(out num13, ref this.m_pathRandomizer))
                        {
                            PathUnit[] expr_D15_cp_0 = this.m_pathUnits.m_buffer;
                            UIntPtr expr_D15_cp_1 = (UIntPtr)unit;
                            expr_D15_cp_0[(int)expr_D15_cp_1].m_pathFindFlags = (byte)(expr_D15_cp_0[(int)expr_D15_cp_1].m_pathFindFlags | 8);
                            return;
                        }
                        this.m_pathUnits.m_buffer[(int)((UIntPtr)num13)] = this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)];
                        this.m_pathUnits.m_buffer[(int)((UIntPtr)num13)].m_referenceCount = 1;
                        this.m_pathUnits.m_buffer[(int)((UIntPtr)num13)].m_pathFindFlags = 4;
                        this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].m_nextPathUnit = num13;
                        this.m_pathUnits.m_buffer[(int)((UIntPtr)num9)].m_positionCount = (byte)num10;
                        num11 += num10;
                        Singleton<PathManager>.instance.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u);
                    }
                    finally
                    {
                        Monitor.Exit(this.m_bufferLock);
                    }
                    num9 = num13;
                    num10 = 0;
                }
                uint laneID = PathManager.GetLaneID(position);
                position = this.m_laneTarget[(int)((UIntPtr)laneID)];
            }
            PathUnit[] expr_D99_cp_0 = this.m_pathUnits.m_buffer;
            UIntPtr expr_D99_cp_1 = (UIntPtr)unit;
            expr_D99_cp_0[(int)expr_D99_cp_1].m_pathFindFlags = (byte)(expr_D99_cp_0[(int)expr_D99_cp_1].m_pathFindFlags | 8);
        }
Exemplo n.º 29
0
 public bool CanUseLane(ExtendedVehicleType vehicleType, uint laneId)
 {
     return((GetLane(laneId).m_vehicleTypes & vehicleType) != ExtendedVehicleType.None);
 }
Exemplo n.º 30
0
 public void SetVehicleRestrictions(uint laneId, ExtendedVehicleType vehicleRestrictions)
 {
     GetLane(laneId).m_vehicleTypes = vehicleRestrictions;
 }
		public ExtendedVehicleType ToggleRestriction(ExtendedVehicleType vehicleType)
		{
			if (!AnyLaneSelected)
				return ExtendedVehicleType.None;

			ExtendedVehicleType vehicleRestrictions = LaneManager.GetVehicleRestrictions(m_selectedLaneMarkers[0].m_lane);
			vehicleRestrictions ^= vehicleType;

			foreach (SegmentLaneMarker lane in m_selectedLaneMarkers)
				LaneManager.SetVehicleRestrictions(lane.m_lane, vehicleRestrictions);

			return vehicleRestrictions;
		}
Exemplo n.º 32
0
        public static bool CanUseLane(this NetInfo.Lane laneInfo, ExtendedVehicleType vehicleType, uint laneId)
        {
            if ((vehicleType & sm_routedUnits) == 0)
            {
                return true;
            }

            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Car) == VehicleInfo.VehicleType.None)
            {
                return true;
            }

            // Quick fix for tram
            if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Tram) != VehicleInfo.VehicleType.None)
            {
                return true;
            }

            return (GetLane(laneId).m_vehicleTypes & vehicleType) != ExtendedVehicleType.None;
        }