当前位置: 首页>>代码示例>>C#>>正文


C# Vehicle.GetLastFramePosition方法代码示例

本文整理汇总了C#中Vehicle.GetLastFramePosition方法的典型用法代码示例。如果您正苦于以下问题:C# Vehicle.GetLastFramePosition方法的具体用法?C# Vehicle.GetLastFramePosition怎么用?C# Vehicle.GetLastFramePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vehicle的用法示例。


在下文中一共展示了Vehicle.GetLastFramePosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TrafficManagerSimulationStep

		/// <summary>
		/// Lightweight simulation step method.
		/// This method is occasionally being called for different cars.
		/// </summary>
		/// <param name="vehicleId"></param>
		/// <param name="vehicleData"></param>
		/// <param name="physicsLodRefPos"></param>
		public void TrafficManagerSimulationStep(ushort vehicleId, ref Vehicle vehicleData, Vector3 physicsLodRefPos) {
			if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != 0) {
				PathManager instance = Singleton<PathManager>.instance;
				byte pathFindFlags = instance.m_pathUnits.m_buffer[(int)((UIntPtr)vehicleData.m_path)].m_pathFindFlags;
				if ((pathFindFlags & 4) != 0) {
					vehicleData.m_pathPositionIndex = 255;
					vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
					vehicleData.m_flags &= ~Vehicle.Flags.Arriving;
					this.PathfindSuccess(vehicleId, ref vehicleData);
					this.TrySpawn(vehicleId, ref vehicleData);
				} else if ((pathFindFlags & 8) != 0) {
					vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
					Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
					vehicleData.m_path = 0u;
					this.PathfindFailure(vehicleId, ref vehicleData);
					return;
				}
			} else if ((vehicleData.m_flags & Vehicle.Flags.WaitingSpace) != 0) {
				this.TrySpawn(vehicleId, ref vehicleData);
			}

			try {
				CustomVehicleAI.HandleVehicle(vehicleId, ref Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId], true, true);
			} catch (Exception e) {
				Log.Error("CarAI TrafficManagerSimulationStep Error: " + e.ToString());
			}

			Vector3 lastFramePosition = vehicleData.GetLastFramePosition();
			int lodPhysics;
			if (Vector3.SqrMagnitude(physicsLodRefPos - lastFramePosition) >= 1210000f) {
				lodPhysics = 2;
			} else if (Vector3.SqrMagnitude(Singleton<SimulationManager>.instance.m_simulationView.m_position - lastFramePosition) >= 250000f) {
				lodPhysics = 1;
			} else {
				lodPhysics = 0;
			}
			this.SimulationStep(vehicleId, ref vehicleData, vehicleId, ref vehicleData, lodPhysics);
			if (vehicleData.m_leadingVehicle == 0 && vehicleData.m_trailingVehicle != 0) {
				VehicleManager instance2 = Singleton<VehicleManager>.instance;
				ushort num = vehicleData.m_trailingVehicle;
				int num2 = 0;
				while (num != 0) {
					ushort trailingVehicle = instance2.m_vehicles.m_buffer[(int)num].m_trailingVehicle;
					VehicleInfo info = instance2.m_vehicles.m_buffer[(int)num].Info;
					info.m_vehicleAI.SimulationStep(num, ref instance2.m_vehicles.m_buffer[(int)num], vehicleId, ref vehicleData, lodPhysics);
					num = trailingVehicle;
					if (++num2 > 16384) {
						CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
						break;
					}
				}
			}
			int privateServiceIndex = ItemClass.GetPrivateServiceIndex(this.m_info.m_class.m_service);
			int num3 = (privateServiceIndex == -1) ? 150 : 100;
			if ((vehicleData.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace)) == 0 && vehicleData.m_cargoParent == 0) {
				Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
			} else if ((int)vehicleData.m_blockCounter == num3 && Options.enableDespawning) {
				Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
			}
		}
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:67,代码来源:CustomCarAI.cs

示例2: Update

        /// <summary>
        /// Updates the specified vehicle.
        /// </summary>
        /// <param name="vehicle">The vehicle.</param>
        /// <param name="freeToCollect">If set to <c>true</c> the vehicle is free.</param>
        /// <param name="checkAssignment">If set to <c>true</c> check vehicles assignment and possibly de-assign vehicle].</param>
        /// <param name="updateValues">If set to <c>true</c> update vehicle values.</param>
        public void Update(ref Vehicle vehicle, bool freeToCollect, bool checkAssignment, bool updateValues)
        {
            if (this.LastSeen != Global.CurrentFrame)
            {
                if (updateValues)
                {
                    string localeKey;
                    int bufCur, bufMax;
                    vehicle.Info.m_vehicleAI.GetBufferStatus(this.VehicleId, ref vehicle, out localeKey, out bufCur, out bufMax);
                    this.CapacityFree = bufMax - bufCur;
                    this.CapacityUsed = (float)bufCur / (float)bufMax;
                }

                if (checkAssignment && (vehicle.m_flags & (VehicleHelper.VehicleUnavailable | VehicleHelper.VehicleBusy)) == ~Vehicle.Flags.All &&
                    vehicle.m_targetBuilding != 0 && vehicle.m_targetBuilding != this.Target && Global.CurrentFrame - this.LastAssigned > Global.DemandLingerDelay)
                {
                    if (Log.LogALot)
                    {
                        Log.DevDebug(this, "Update", this.dispatcherType, "CheckAssignment", "DeAssign", this.VehicleId, vehicle.m_targetBuilding, vehicle.m_flags);
                    }

                    this.DeAssign(ref vehicle, false, "Update");
                }
            }

            this.Position = vehicle.GetLastFramePosition();
            this.LastSeen = Global.CurrentFrame;
            this.FreeToCollect = freeToCollect;

            if (checkAssignment && vehicle.m_targetBuilding != this.Target)
            {
                this.Target = 0;
            }
            else if (this.Target != 0)
            {
                this.LastAssigned = Global.CurrentFrame;
            }
        }
开发者ID:DinkyToyz,项目名称:wtmcsServiceDispatcher,代码行数:45,代码来源:ServiceVehicleInfo.cs

示例3: SimulationStep

        public override void SimulationStep(ushort vehicleId, ref Vehicle data, Vector3 physicsLodRefPos)
        {
            if ((data.m_flags & Vehicle.Flags.WaitingPath) != Vehicle.Flags.None)
            {
                if (!CanFindPath(vehicleId, ref data))
                    return;
            }
            else if ((data.m_flags & Vehicle.Flags.WaitingSpace) != Vehicle.Flags.None)
            {
                TrySpawn(vehicleId, ref data);
            }

            var lastFramePosition = data.GetLastFramePosition();
            int lodPhysics;
            if (Vector3.SqrMagnitude(physicsLodRefPos - lastFramePosition) >= 1210000f)
            {
                lodPhysics = 2;
            }
            else if (
                Vector3.SqrMagnitude(Singleton<SimulationManager>.instance.m_simulationView.m_position -
                                     lastFramePosition) >= 250000f)
            {
                lodPhysics = 1;
            }
            else
            {
                lodPhysics = 0;
            }
            SimulationStep(vehicleId, ref data, vehicleId, ref data, lodPhysics);
            if (data.m_leadingVehicle == 0 && data.m_trailingVehicle != 0)
            {
                var instance2 = Singleton<VehicleManager>.instance;
                var num = data.m_trailingVehicle;
                var num2 = 0;
                while (num != 0)
                {
                    var trailingVehicle = instance2.m_vehicles.m_buffer[num].m_trailingVehicle;
                    var info = instance2.m_vehicles.m_buffer[num].Info;
                    info.m_vehicleAI.SimulationStep(num, ref instance2.m_vehicles.m_buffer[num], vehicleId,
                        ref data, lodPhysics);
                    num = trailingVehicle;

                    if (++num2 > 16384)
                    {
                        CODebugBase<LogChannel>.Error(LogChannel.Core,
                            "Invalid list detected!\n" + Environment.StackTrace);
                        break;
                    }
                }
            }
            var num3 = (m_info.m_class.m_service > ItemClass.Service.Office) ? 150 : 100;
            if ((data.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace)) ==
                Vehicle.Flags.None && data.m_cargoParent == 0)
            {
                Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
            }
            else if (data.m_blockCounter >= num3 && LoadingExtension.Instance.DespawnEnabled)
            {
                Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
            }
        }
开发者ID:oczkers,项目名称:Skylines-Traffic-Manager,代码行数:61,代码来源:CustomCarAI.cs

示例4: CheckOtherVehicle

 private ushort CheckOtherVehicle(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ref float maxSpeed, ref bool blocked, float maxBraking, ushort otherID, ref Vehicle otherData, Vector3 min, Vector3 max, int lodPhysics)
 {
     if (otherID != vehicleID && vehicleData.m_leadingVehicle != otherID && vehicleData.m_trailingVehicle != otherID)
     {
         Vector3 vector;
         Vector3 vector2;
         if (lodPhysics >= 1)
         {
             vector = otherData.m_segment.Min ();
             vector2 = otherData.m_segment.Max ();
         }
         else
         {
             vector = Vector3.Min (otherData.m_segment.Min (), otherData.m_targetPos3);
             vector2 = Vector3.Max (otherData.m_segment.Max (), otherData.m_targetPos3);
         }
         if (min.x < vector2.x + 2f && min.y < vector2.y + 2f && min.z < vector2.z + 2f && vector.x < max.x + 2f && vector.y < max.y + 2f && vector.z < max.z + 2f)
         {
             Vehicle.Frame lastFrameData = otherData.GetLastFrameData ();
             VehicleInfo info = otherData.Info;
             float num = frameData.m_velocity.magnitude + 0.01f;
             float num2 = lastFrameData.m_velocity.magnitude;
             float num3 = num2 * (0.5f + 0.5f * num2 / info.m_braking) + info.m_generatedInfo.m_size.z * Mathf.Min (0.5f, num2 * 0.1f);
             num2 += 0.01f;
             float num4 = 0f;
             Vector3 vector3 = frameData.m_position;
             Vector3 lhs = ((Vector3) vehicleData.m_targetPos3) - frameData.m_position;
             for (int i = 1; i < 4; i++)
             {
                 Vector3 vector4 = vehicleData.GetTargetPos (i);
                 Vector3 vector5 = vector4 - vector3;
                 if (Vector3.Dot (lhs, vector5) > 0f)
                 {
                     float magnitude = vector5.magnitude;
                     Segment3 segment = new Segment3 (vector3, vector4);
                     min = segment.Min ();
                     max = segment.Max ();
                     segment.a.y = segment.a.y * 0.5f;
                     segment.b.y = segment.b.y * 0.5f;
                     if (magnitude > 0.01f && min.x < vector2.x + 2f && min.y < vector2.y + 2f && min.z < vector2.z + 2f && vector.x < max.x + 2f && vector.y < max.y + 2f && vector.z < max.z + 2f)
                     {
                         Vector3 a = otherData.m_segment.a;
                         a.y *= 0.5f;
                         float num5;
                         if (segment.DistanceSqr (a, out num5) < 400f)
                         {
                             float num6 = Vector3.Dot (lastFrameData.m_velocity, vector5) / magnitude;
                             float num7 = num4 + magnitude * num5;
                             if (num7 >= 0.01f)
                             {
                                 num7 -= num6 + 30f;
                                 float num8 = Mathf.Max (0f, CalculateMaxSpeed (num7, num6, maxBraking));
                                 if (num8 < 0.01f)
                                 {
                                     blocked = true;
                                 }
                                 Vector3 rhs = Vector3.Normalize (((Vector3)otherData.m_targetPos3) - otherData.GetLastFramePosition ());
                                 float num9 = 1.2f - 1f / ((float)vehicleData.m_blockCounter * 0.02f + 0.5f);
                                 if (Vector3.Dot (vector5, rhs) > num9 * magnitude)
                                 {
                                     maxSpeed = Mathf.Min (maxSpeed, num8);
                                 }
                             }
                             break;
                         }
                         if (lodPhysics == 0)
                         {
                             float num10 = 0f;
                             float num11 = num3;
                             Vector3 vector6 = otherData.GetLastFramePosition ();
                             Vector3 lhs2 = ((Vector3)otherData.m_targetPos3) - vector6;
                             bool flag = false;
                             int num12 = 1;
                             while (num12 < 4 && num11 > 0.1f)
                             {
                                 Vector3 vector7 = otherData.GetTargetPos (num12);
                                 Vector3 vector8 = Vector3.ClampMagnitude (vector7 - vector6, num11);
                                 if (Vector3.Dot (lhs2, vector8) > 0f)
                                 {
                                     vector7 = vector6 + vector8;
                                     float magnitude2 = vector8.magnitude;
                                     num11 -= magnitude2;
                                     Segment3 segment2 = new Segment3 (vector6, vector7);
                                     segment2.a.y = segment2.a.y * 0.5f;
                                     segment2.b.y = segment2.b.y * 0.5f;
                                     if (magnitude2 > 0.01f)
                                     {
                                         float num14;
                                         float num15;
                                         float num13;
                                         if (otherID < vehicleID)
                                         {
                                             num13 = segment2.DistanceSqr (segment, out num14, out num15);
                                         }
                                         else
                                         {
                                             num13 = segment.DistanceSqr (segment2, out num15, out num14);
                                         }
                                         if (num13 < 400f)
                                         {
//.........这里部分代码省略.........
开发者ID:klyte45,项目名称:CS-VehicleLimitExpander,代码行数:101,代码来源:FakeShipAI.cs

示例5: BaseSimulationStep

 protected void BaseSimulationStep(ushort vehicleID, ref Vehicle data, Vector3 physicsLodRefPos)
 {
     if ((data.m_flags & Vehicle.Flags.WaitingPath) != Vehicle.Flags.None)
     {
         PathManager instance = Singleton<PathManager>.instance;
         byte pathFindFlags = instance.m_pathUnits.m_buffer[(int)((UIntPtr)data.m_path)].m_pathFindFlags;
         if ((pathFindFlags & 4) != 0)
         {
             data.m_pathPositionIndex = 255;
             data.m_flags &= ~Vehicle.Flags.WaitingPath;
             data.m_flags &= ~Vehicle.Flags.Arriving;
             this.PathfindSuccess(vehicleID, ref data);
             this.TrySpawn(vehicleID, ref data);
         }
         else if ((pathFindFlags & 8) != 0)
         {
             data.m_flags &= ~Vehicle.Flags.WaitingPath;
             Singleton<PathManager>.instance.ReleasePath(data.m_path);
             data.m_path = 0u;
             this.PathfindFailure(vehicleID, ref data);
             return;
         }
     }
     else if ((data.m_flags & Vehicle.Flags.WaitingSpace) != Vehicle.Flags.None)
     {
         this.TrySpawn(vehicleID, ref data);
     }
     Vector3 lastFramePosition = data.GetLastFramePosition();
     int lodPhysics;
     if (Vector3.SqrMagnitude(physicsLodRefPos - lastFramePosition) >= 1210000f)
     {
         lodPhysics = 2;
     }
     else if (
         Vector3.SqrMagnitude(Singleton<SimulationManager>.instance.m_simulationView.m_position -
                              lastFramePosition) >= 250000f)
     {
         lodPhysics = 1;
     }
     else
     {
         lodPhysics = 0;
     }
     this.SimulationStep(vehicleID, ref data, vehicleID, ref data, lodPhysics);
     if (data.m_leadingVehicle == 0 && data.m_trailingVehicle != 0)
     {
         VehicleManager instance2 = Singleton<VehicleManager>.instance;
         ushort num = data.m_trailingVehicle;
         int num2 = 0;
         while (num != 0)
         {
             ushort trailingVehicle = instance2.m_vehicles.m_buffer[(int)num].m_trailingVehicle;
             VehicleInfo info = instance2.m_vehicles.m_buffer[(int)num].Info;
             info.m_vehicleAI.SimulationStep(num, ref instance2.m_vehicles.m_buffer[(int)num], vehicleID,
                 ref data, lodPhysics);
             num = trailingVehicle;
             if (++num2 > 16384)
             {
                 CODebugBase<LogChannel>.Error(LogChannel.Core,
                     "Invalid list detected!\n" + Environment.StackTrace);
                 break;
             }
         }
     }
     int num3 = (this.m_info.m_class.m_service > ItemClass.Service.Office) ? 150 : 100;
     if ((data.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace)) ==
         Vehicle.Flags.None && data.m_cargoParent == 0)
     {
         Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleID);
     }
     else if ((int)data.m_blockCounter >= num3 && LoadingExtension.Instance.despawnEnabled)
     {
         Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleID);
     }
 }
开发者ID:robbiemu,项目名称:Skylines-Traffic-Manager,代码行数:75,代码来源:CustomCargoTruckAI.cs

示例6: SimulateVehicleAndTrailers

		private void SimulateVehicleAndTrailers(ushort vehicleId, ref Vehicle vehicleData, Vector3 physicsLodRefPos) {
			var lastFramePosition = vehicleData.GetLastFramePosition();

			var lodPhysics = CalculateLod(physicsLodRefPos, lastFramePosition);

			SimulationStep(vehicleId, ref vehicleData, vehicleId, ref vehicleData, lodPhysics);

			if (vehicleData.m_leadingVehicle != 0 || vehicleData.m_trailingVehicle == 0)
				return;

			var vehicleManager = Singleton<VehicleManager>.instance;
			var trailingVehicleId = vehicleData.m_trailingVehicle;
			SimulateTrailingVehicles(vehicleId, ref vehicleData, lodPhysics, trailingVehicleId, ref vehicleManager, 0);
		}
开发者ID:akira-ishizaki,项目名称:Cities-Skylines-Traffic-Manager-President-Edition,代码行数:14,代码来源:CustomCarAI.cs

示例7: Update

        /// <summary>
        /// Updates the specified vehicle.
        /// </summary>
        /// <param name="vehicle">The vehicle.</param>
        public void Update(ref Vehicle vehicle)
        {
            this.targetBuildingId = vehicle.m_targetBuilding;

            // Check if vehicle has flag that should be checked.
            Vehicle.Flags flags = vehicle.m_flags & FlagsToCheck;
            if ((flags & Vehicle.Flags.All) != ~Vehicle.Flags.All)
            {
                Vector3 position = vehicle.GetLastFramePosition();

                // Remember first time stamp the vehicle was seen with this flag at this position.
                if (this.checkFlagSinceFrame == 0 || this.checkFlagSinceTime == 0 || flags != this.checkFlags || Math.Truncate((position - this.checkFlagPosition).sqrMagnitude) > 0)
                {
                    ////if (Log.LogALot)
                    ////{
                    ////    if (this.checkFlags == Vehicle.Flags.None)
                    ////    {
                    ////        Log.DevDebug(this, "Update", "NewCheckFlag", flags, this.vehicleId, this.CheckFlaggedForSeconds, this.CheckFlaggedForFrames, Global.Settings.RemoveStuckVehiclesDelaySeconds, Global.CheckFlagStuckDelay, this.checkFlags, flags, this.checkFlagPosition, position, '-', vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId), this.GetHashCode().ToString());
                    ////    }
                    ////    else
                    ////    {
                    ////        Log.DevDebug(this, "Update", "NewCheckFlag", flags, this.vehicleId, this.CheckFlaggedForSeconds, this.CheckFlaggedForFrames, Global.Settings.RemoveStuckVehiclesDelaySeconds, Global.CheckFlagStuckDelay, this.checkFlags, flags, this.checkFlagPosition, position, (position - this.checkFlagPosition).sqrMagnitude, vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId), this.GetHashCode().ToString());
                    ////    }
                    ////}

                    this.checkFlags = flags;
                    this.checkFlagPosition = position;
                    this.checkFlagSinceTime = Global.SimulationTime;
                    this.checkFlagSinceFrame = Global.CurrentFrame;
                }
                ////else if (Log.LogALot)
                ////{
                ////    Log.DevDebug(this, "Update", "CheckFlag", flags, this.vehicleId, this.CheckFlaggedForSeconds, this.CheckFlaggedForFrames, Global.Settings.RemoveStuckVehiclesDelaySeconds, Global.CheckFlagStuckDelay, this.checkFlags, flags, this.checkFlagPosition, position, (position - this.checkFlagPosition).sqrMagnitude, vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId), this.GetHashCode().ToString());
                ////}
            }
            else if ((this.checkFlags & Vehicle.Flags.All) != ~Vehicle.Flags.All || this.checkFlagSinceTime != 0 || this.checkFlagSinceFrame != 0)
            {
                ////if (Log.LogALot)
                ////{
                ////    Log.DevDebug(this, "Update", "ResetCheckFlag", flags, this.vehicleId, this.CheckFlaggedForSeconds, this.CheckFlaggedForFrames, Global.Settings.RemoveStuckVehiclesDelaySeconds, Global.CheckFlagStuckDelay, this.checkFlags, flags, vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId), this.GetHashCode().ToString());
                ////}

                this.checkFlags = ~Vehicle.Flags.All;
                this.checkFlagSinceTime = 0;
                this.checkFlagSinceFrame = 0;
            }

            // Check if vehicle is confused.
            if (ConfusionHelper.VehicleIsConfused(ref vehicle))
            {
                if (this.confusedDeAssignedSinceFrame == 0)
                {
                    this.confusedDeAssignedSinceFrame = Global.CurrentFrame;
                }

                if (this.confusedSinceFrame == 0 || this.confusedSinceTime == 0)
                {
                    if (Log.LogALot)
                    {
                        Log.DevDebug(this, "Update", "NewConfused", this.vehicleId, this.ConfusedForSeconds, this.ConfusedForFrames, Global.Settings.RecoveryCrews.DelaySeconds, Global.DeAssignConfusedDelay, vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId));
                    }

                    this.confusedSinceTime = Global.SimulationTime;
                    this.confusedSinceFrame = Global.CurrentFrame;
                    this.confusedDeAssignedSinceFrame = Global.CurrentFrame;
                }
                ////else if (Log.LogALot)
                ////{
                ////    Log.DevDebug(this, "Update", "Confused", this.vehicleId, this.ConfusedForSeconds, this.ConfusedForFrames, Global.Settings.RemoveStuckVehiclesDelaySeconds, Global.DeAssignConfusedDelay, vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId));
                ////}
            }
            else if (this.confusedSinceTime != 0 || this.confusedSinceFrame != 0 || this.confusedDeAssignedSinceFrame != 0)
            {
                ////if (Log.LogALot)
                ////{
                ////    Log.DevDebug(this, "Update", "ResetConfused", this.vehicleId, this.ConfusedForSeconds, this.ConfusedForFrames, Global.Settings.RemoveStuckVehiclesDelaySeconds, Global.DeAssignConfusedDelay, vehicle.m_targetBuilding, vehicle.m_flags, VehicleHelper.GetVehicleName(this.vehicleId));
                ////}

                this.confusedSinceTime = 0;
                this.confusedSinceFrame = 0;
                this.confusedDeAssignedSinceFrame = 0;
            }

            // Check if vehicle is stuck.
            if (!this.isStuck)
            {
                double delta;

                // Check if stuck with flag.
                if ((this.checkFlags & Vehicle.Flags.All) != ~Vehicle.Flags.All && this.CheckFlaggedForFrames > Global.CheckFlagStuckDelay)
                {
                    delta = this.CheckFlaggedForSeconds;

                    if (delta > Global.Settings.RecoveryCrews.DelaySeconds)
                    {
                        Log.Info(this, "IsStuck", this.checkFlags, this.vehicleId, delta, VehicleHelper.GetVehicleName(this.vehicleId));
//.........这里部分代码省略.........
开发者ID:DinkyToyz,项目名称:wtmcsServiceDispatcher,代码行数:101,代码来源:StuckVehicleInfo.cs

示例8: PathFindReady

 protected virtual bool PathFindReady(ushort vehicleID, ref Vehicle vehicleData)
 {
     PathManager instance = Singleton<PathManager>.instance;
     NetManager instance2 = Singleton<NetManager>.instance;
     float num = vehicleData.CalculateTotalLength (vehicleID);
     float distance = (num + this.m_info.m_generatedInfo.m_wheelBase - this.m_info.m_generatedInfo.m_size.z) * 0.5f;
     Vector3 vector = vehicleData.GetLastFramePosition ();
     PathUnit.Position pathPos;
     if ((vehicleData.m_flags & Vehicle.Flags.Spawned) == Vehicle.Flags.None && instance.m_pathUnits.m_buffer [(int)((UIntPtr)vehicleData.m_path)].GetPosition (0, out pathPos))
     {
         uint laneID = PathManager.GetLaneID (pathPos);
         vector = instance2.m_lanes.m_buffer [(int)((UIntPtr)laneID)].CalculatePosition ((float)pathPos.m_offset * 0.003921569f);
     }
     vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
     instance.m_pathUnits.m_buffer [(int)((UIntPtr)vehicleData.m_path)].MoveLastPosition (vehicleData.m_path, distance);
     if ((vehicleData.m_flags & Vehicle.Flags.Spawned) != Vehicle.Flags.None)
     {
         InitializePath (vehicleID, ref vehicleData);
     }
     else
     {
         int index = Mathf.Min (1, (int)(instance.m_pathUnits.m_buffer [(int)((UIntPtr)vehicleData.m_path)].m_positionCount - 1));
         PathUnit.Position pathPos2;
         if (instance.m_pathUnits.m_buffer [(int)((UIntPtr)vehicleData.m_path)].GetPosition (index, out pathPos2))
         {
             uint laneID2 = PathManager.GetLaneID (pathPos2);
             Vector3 a = instance2.m_lanes.m_buffer [(int)((UIntPtr)laneID2)].CalculatePosition ((float)pathPos2.m_offset * 0.003921569f);
             Vector3 forward = a - vector;
             vehicleData.m_frame0.m_position = vector;
             if (forward.sqrMagnitude > 1f)
             {
                 float length = instance2.m_lanes.m_buffer [(int)((UIntPtr)laneID2)].m_length;
                 vehicleData.m_frame0.m_position = vehicleData.m_frame0.m_position + forward.normalized * Mathf.Min (length * 0.5f, (num - this.m_info.m_generatedInfo.m_size.z) * 0.5f);
                 vehicleData.m_frame0.m_rotation = Quaternion.LookRotation (forward);
             }
             vehicleData.m_frame1 = vehicleData.m_frame0;
             vehicleData.m_frame2 = vehicleData.m_frame0;
             vehicleData.m_frame3 = vehicleData.m_frame0;
             this.FrameDataUpdated (vehicleID, ref vehicleData, ref vehicleData.m_frame0);
         }
         this.TrySpawn (vehicleID, ref vehicleData);
     }
     return true;
 }
开发者ID:klyte45,项目名称:CS-VehicleLimitExpander,代码行数:44,代码来源:FakeTrainAI.cs


注:本文中的Vehicle.GetLastFramePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。