internal VehicleState(ushort vehicleId) { this.vehicleId = vehicleId; lastPathId = 0; lastPathPositionIndex = 0; lastTransitStateUpdate = Now(); lastPositionUpdate = Now(); totalLength = 0; waitTime = 0; reduceSqrSpeedByValueToYield = 0; flags = Flags.None; vehicleType = ExtVehicleType.None; heavyVehicle = false; currentSegmentId = 0; currentStartNode = false; currentLaneIndex = 0; nextSegmentId = 0; nextLaneIndex = 0; previousVehicleIdOnSegment = 0; nextVehicleIdOnSegment = 0; velocity = 0; sqrVelocity = 0; lastAltLaneSelSegmentId = 0; junctionTransitState = VehicleJunctionTransitState.None; }
public ExtVehicle(ushort vehicleId) { this.vehicleId = vehicleId; lastPathId = 0; lastPathPositionIndex = 0; lastTransitStateUpdate = 0; lastPositionUpdate = 0; totalLength = 0; waitTime = 0; flags = ExtVehicleFlags.None; vehicleType = ExtVehicleType.None; heavyVehicle = false; recklessDriver = false; currentSegmentId = 0; currentStartNode = false; currentLaneIndex = 0; nextSegmentId = 0; nextLaneIndex = 0; previousVehicleIdOnSegment = 0; nextVehicleIdOnSegment = 0; lastAltLaneSelSegmentId = 0; junctionTransitState = VehicleJunctionTransitState.None; timedRand = 0; dlsReady = false; maxReservedSpace = 0; laneSpeedRandInterval = 0; maxOptLaneChanges = 0; maxUnsafeSpeedDiff = 0; minSafeSpeedImprovement = 0; minSafeTrafficImprovement = 0; }
internal void OnRelease(ref Vehicle vehicleData) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}) called: {this}"); } #endif if ((flags & Flags.Created) == Flags.None) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}): Vehicle is not created."); } #endif return; } if ((flags & Flags.Spawned) != Flags.None) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}): Vehicle is spawned."); } #endif OnDespawn(); } lastPathId = 0; lastPathPositionIndex = 0; lastTransitStateUpdate = Now(); lastPositionUpdate = Now(); waitTime = 0; reduceSqrSpeedByValueToYield = 0; flags = Flags.None; vehicleType = ExtVehicleType.None; heavyVehicle = false; previousVehicleIdOnSegment = 0; nextVehicleIdOnSegment = 0; lastAltLaneSelSegmentId = 0; junctionTransitState = VehicleJunctionTransitState.None; recklessDriver = false; maxReservedSpace = 0; laneSpeedRandInterval = 0; maxOptLaneChanges = 0; maxUnsafeSpeedDiff = 0; minSafeSpeedImprovement = 0; minSafeTrafficImprovement = 0; #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}) finished: {this}"); } #endif }
public void SetJunctionTransitState(ref ExtVehicle extVehicle, VehicleJunctionTransitState transitState) { if (transitState != extVehicle.junctionTransitState) { extVehicle.junctionTransitState = transitState; extVehicle.lastTransitStateUpdate = Now(); } }
public void SetJunctionTransitState(ref ExtVehicle extVehicle, VehicleJunctionTransitState transitState) { if (transitState != extVehicle.junctionTransitState) { extVehicle.junctionTransitState = transitState; extVehicle.lastTransitStateUpdate = Singleton <SimulationManager> .instance.m_currentFrameIndex; } }
internal void OnRelease(ref Vehicle vehicleData) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}) called: {this}"); } #endif if ((flags & Flags.Created) == Flags.None) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}): Vehicle is not created."); } #endif return; } if ((flags & Flags.Spawned) != Flags.None) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}): Vehicle is spawned."); } #endif OnDespawn(); } lastPathId = 0; lastPathPositionIndex = 0; lastTransitStateUpdate = Now(); lastPositionUpdate = Now(); waitTime = 0; reduceSqrSpeedByValueToYield = 0; flags = Flags.None; vehicleType = ExtVehicleType.None; heavyVehicle = false; previousVehicleIdOnSegment = 0; nextVehicleIdOnSegment = 0; velocity = 0; sqrVelocity = 0; lastAltLaneSelSegmentId = 0; junctionTransitState = VehicleJunctionTransitState.None; #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.OnRelease({vehicleId}) finished: {this}"); } #endif }
public void ResetCar() { Valid = false; ToNode = 0; FromSegment = 0; ToSegment = 0; //ToLaneId = 0; ToLaneIndex = 0; //FromLaneId = 0; FromLaneIndex = 0; VehicleType = ExtVehicleType.None; Stopped = false; WaitTime = 0; CarState = VehicleJunctionTransitState.None; OnEmergency = false; }
internal void UpdatePosition(ref Vehicle vehicleData, ref PathUnit.Position curPos, ref PathUnit.Position nextPos, bool skipCheck = false) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.UpdatePosition({vehicleId}) called: {this}"); } #endif if ((flags & Flags.Spawned) == Flags.None) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.UpdatePosition({vehicleId}): Vehicle is not yet spawned."); } #endif OnSpawn(ref vehicleData); } if (nextSegmentId != nextPos.m_segment || nextLaneIndex != nextPos.m_lane) { nextSegmentId = nextPos.m_segment; nextLaneIndex = nextPos.m_lane; } bool startNode = IsTransitNodeCurStartNode(ref curPos, ref nextPos); ISegmentEnd end = Constants.ManagerFactory.SegmentEndManager.GetSegmentEnd(curPos.m_segment, startNode); if (end == null || currentSegmentId != end.SegmentId || currentStartNode != end.StartNode || currentLaneIndex != curPos.m_lane) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.UpdatePosition({vehicleId}): Current segment end changed. seg. {currentSegmentId}, start {currentStartNode}, lane {currentLaneIndex} -> seg. {end?.SegmentId}, start {end?.StartNode}, lane {curPos.m_lane}"); } #endif if (currentSegmentId != 0) { #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.UpdatePosition({vehicleId}): Unlinking from current segment end"); } #endif Unlink(); } lastPathId = vehicleData.m_path; lastPathPositionIndex = vehicleData.m_pathPositionIndex; currentSegmentId = curPos.m_segment; currentStartNode = startNode; currentLaneIndex = curPos.m_lane; waitTime = 0; if (end != null) { #if DEBUGVSTATE if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.UpdatePosition({vehicleId}): Linking vehicle to segment end {end.SegmentId} @ {end.StartNode} ({end.NodeId}). Current position: Seg. {curPos.m_segment}, lane {curPos.m_lane}, offset {curPos.m_offset} / Next position: Seg. {nextPos.m_segment}, lane {nextPos.m_lane}, offset {nextPos.m_offset}"); } #endif Link(end); JunctionTransitState = VehicleJunctionTransitState.Approach; } else { JunctionTransitState = VehicleJunctionTransitState.None; } } #if DEBUG if (GlobalConfig.Instance.Debug.Switches[9]) { Log._Debug($"VehicleState.UpdatePosition({vehicleId}) finshed: {this}"); } #endif }