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


C# Vehicle.GetTargetPos方法代码示例

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


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

示例1: 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

示例2: CheckOtherVehicles

 private static void CheckOtherVehicles(CarAI carAI, ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ref float maxSpeed, ref bool blocked, ref Vector3 collisionPush, float maxDistance, float maxBraking, int lodPhysics)
 {
     Vector3 vector = vehicleData.m_targetPos3 - (Vector4)frameData.m_position;
     Vector3 rhs = frameData.m_position + Vector3.ClampMagnitude(vector, maxDistance);
     Vector3 min = Vector3.Min(vehicleData.m_segment.Min(), rhs);
     Vector3 max = Vector3.Max(vehicleData.m_segment.Max(), rhs);
     VehicleManager instance = Singleton<VehicleManager>.instance;
     int num = Mathf.Max((int)((min.x - 10f) / 32f + 270f), 0);
     int num2 = Mathf.Max((int)((min.z - 10f) / 32f + 270f), 0);
     int num3 = Mathf.Min((int)((max.x + 10f) / 32f + 270f), 539);
     int num4 = Mathf.Min((int)((max.z + 10f) / 32f + 270f), 539);
     for (int i = num2; i <= num4; i++)
     {
         for (int j = num; j <= num3; j++)
         {
             ushort num5 = instance.m_vehicleGrid[i * 540 + j];
             int num6 = 0;
             while (num5 != 0)
             {
                 num5 = CustomCarAI.CheckOtherVehicle(vehicleID, ref vehicleData, ref frameData, ref maxSpeed, ref blocked, ref collisionPush, maxBraking, num5, ref instance.m_vehicles.m_buffer[(int)num5], min, max, lodPhysics);
                 if (++num6 > 16384)
                 {
                     CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
                     break;
                 }
             }
         }
     }
     if (lodPhysics == 0 && (CSLTraffic.Options & OptionsManager.ModOptions.noStopForCrossing) != OptionsManager.ModOptions.noStopForCrossing)
     {
         CitizenManager instance2 = Singleton<CitizenManager>.instance;
         float num7 = 0f;
         Vector3 vector2 = vehicleData.m_segment.b;
         Vector3 lhs = vehicleData.m_segment.b - vehicleData.m_segment.a;
         for (int k = 0; k < 4; k++)
         {
             Vector3 vector3 = vehicleData.GetTargetPos(k);
             Vector3 vector4 = vector3 - vector2;
             if (Vector3.Dot(lhs, vector4) > 0f)
             {
                 float magnitude = vector4.magnitude;
                 if (magnitude > 0.01f)
                 {
                     Segment3 segment = new Segment3(vector2, vector3);
                     min = segment.Min();
                     max = segment.Max();
                     int num8 = Mathf.Max((int)((min.x - 3f) / 8f + 1080f), 0);
                     int num9 = Mathf.Max((int)((min.z - 3f) / 8f + 1080f), 0);
                     int num10 = Mathf.Min((int)((max.x + 3f) / 8f + 1080f), 2159);
                     int num11 = Mathf.Min((int)((max.z + 3f) / 8f + 1080f), 2159);
                     for (int l = num9; l <= num11; l++)
                     {
                         for (int m = num8; m <= num10; m++)
                         {
                             ushort num12 = instance2.m_citizenGrid[l * 2160 + m];
                             int num13 = 0;
                             while (num12 != 0)
                             {
                                 num12 = CustomCarAI.CheckCitizen(segment, num7, magnitude, ref maxSpeed, ref blocked, maxBraking, num12, ref instance2.m_instances.m_buffer[(int)num12], min, max);
                                 if (++num13 > 65536)
                                 {
                                     CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 lhs = vector4;
                 num7 += magnitude;
                 vector2 = vector3;
             }
         }
     }
 }
开发者ID:moverperfect,项目名称:csl-traffic,代码行数:75,代码来源:CustomCarAI.cs

示例3: CheckOtherVehicle

 private static ushort CheckOtherVehicle(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ref float maxSpeed, ref bool blocked, ref Vector3 collisionPush, float maxBraking, ushort otherID, ref Vehicle otherData, Vector3 min, Vector3 max, int lodPhysics)
 {
     if (otherID != vehicleID && vehicleData.m_leadingVehicle != otherID && vehicleData.m_trailingVehicle != otherID)
     {
         VehicleInfo info = otherData.Info;
         if (info.m_vehicleType == VehicleInfo.VehicleType.Bicycle)
         {
             return otherData.m_nextGridVehicle;
         }
         Vector3 vector;
         Vector3 vector2;
         if (lodPhysics >= 2)
         {
             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();
             if (lodPhysics < 2)
             {
                 float num2;
                 float num3;
                 float num = vehicleData.m_segment.DistanceSqr(otherData.m_segment, out num2, out num3);
                 if (num < 4f)
                 {
                     Vector3 a = vehicleData.m_segment.Position(0.5f);
                     Vector3 b = otherData.m_segment.Position(0.5f);
                     Vector3 lhs = vehicleData.m_segment.b - vehicleData.m_segment.a;
                     if (Vector3.Dot(lhs, a - b) < 0f)
                     {
                         collisionPush -= lhs.normalized * (0.1f - num * 0.025f);
                     }
                     else
                     {
                         collisionPush += lhs.normalized * (0.1f - num * 0.025f);
                     }
                     blocked = true;
                 }
             }
             float num4 = frameData.m_velocity.magnitude + 0.01f;
             float num5 = lastFrameData.m_velocity.magnitude;
             float num6 = num5 * (0.5f + 0.5f * num5 / info.m_braking) + Mathf.Min(1f, num5);
             num5 += 0.01f;
             float num7 = 0f;
             Vector3 vector3 = vehicleData.m_segment.b;
             Vector3 lhs2 = vehicleData.m_segment.b - vehicleData.m_segment.a;
             for (int i = 0; i < 4; i++)
             {
                 Vector3 vector4 = vehicleData.GetTargetPos(i);
                 Vector3 vector5 = vector4 - vector3;
                 if (Vector3.Dot(lhs2, 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 a2 = otherData.m_segment.a;
                         a2.y *= 0.5f;
                         float num8;
                         if (segment.DistanceSqr(a2, out num8) < 4f)
                         {
                             float num9 = Vector3.Dot(lastFrameData.m_velocity, vector5) / magnitude;
                             float num10 = num7 + magnitude * num8;
                             if (num10 >= 0.01f)
                             {
                                 num10 -= num9 + 3f;
                                 float num11 = Mathf.Max(0f, CalculateMaxSpeed(num10, num9, maxBraking));
                                 if (num11 < 0.01f)
                                 {
                                     blocked = true;
                                 }
                                 Vector3 rhs = Vector3.Normalize(otherData.m_targetPos0 - (Vector4)otherData.m_segment.a);
                                 float num12 = 1.2f - 1f / ((float)vehicleData.m_blockCounter * 0.02f + 0.5f);
                                 if (Vector3.Dot(vector5, rhs) > num12 * magnitude)
                                 {
                                     maxSpeed = Mathf.Min(maxSpeed, num11);
                                 }
                             }
                             break;
                         }
                         if (lodPhysics < 2)
                         {
                             float num13 = 0f;
                             float num14 = num6;
                             Vector3 vector6 = otherData.m_segment.b;
                             Vector3 lhs3 = otherData.m_segment.b - otherData.m_segment.a;
                             bool flag = false;
                             int num15 = 0;
                             while (num15 < 4 && num14 > 0.1f)
                             {
//.........这里部分代码省略.........
开发者ID:moverperfect,项目名称:csl-traffic,代码行数:101,代码来源:CustomCarAI.cs

示例4: SimulationStep

 public static void SimulationStep(CarAI carAI, ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics)
 {
     uint currentFrameIndex = Singleton<SimulationManager>.instance.m_currentFrameIndex;
     frameData.m_position += frameData.m_velocity * 0.5f;
     frameData.m_swayPosition += frameData.m_swayVelocity * 0.5f;
     float acceleration = carAI.m_info.m_acceleration;
     float braking = carAI.m_info.m_braking;
     float magnitude = frameData.m_velocity.magnitude;
     Vector3 vector = vehicleData.m_targetPos0 - (Vector4)frameData.m_position;
     float sqrMagnitude = vector.sqrMagnitude;
     float num = (magnitude + acceleration) * (0.5f + 0.5f * (magnitude + acceleration) / braking) + carAI.m_info.m_generatedInfo.m_size.z * 0.5f;
     float num2 = Mathf.Max(magnitude + acceleration, 5f);
     if (lodPhysics >= 2 && (ulong)(currentFrameIndex >> 4 & 3u) == (ulong)((long)(vehicleID & 3)))
     {
         num2 *= 2f;
     }
     float num3 = Mathf.Max((num - num2) / 3f, 1f);
     float num4 = num2 * num2;
     float num5 = num3 * num3;
     int i = 0;
     bool flag = false;
     if ((sqrMagnitude < num4 || vehicleData.m_targetPos3.w < 0.01f) && (leaderData.m_flags & (Vehicle.Flags.WaitingPath | Vehicle.Flags.Stopped)) == Vehicle.Flags.None)
     {
         if (leaderData.m_path != 0u)
         {
             CustomVehicleAI.UpdatePathTargetPositions(carAI, vehicleID, ref vehicleData, frameData.m_position, ref i, 4, num4, num5);
             if ((leaderData.m_flags & Vehicle.Flags.Spawned) == Vehicle.Flags.None)
             {
                 frameData = vehicleData.m_frame0;
                 return;
             }
         }
         if ((leaderData.m_flags & Vehicle.Flags.WaitingPath) == Vehicle.Flags.None)
         {
             while (i < 4)
             {
                 float minSqrDistance;
                 Vector3 refPos;
                 if (i == 0)
                 {
                     minSqrDistance = num4;
                     refPos = frameData.m_position;
                     flag = true;
                 }
                 else
                 {
                     minSqrDistance = num5;
                     refPos = vehicleData.GetTargetPos(i - 1);
                 }
                 int num6 = i;
                 carAI.UpdateBuildingTargetPositions(vehicleID, ref vehicleData, refPos, leaderID, ref leaderData, ref i, minSqrDistance);
                 if (i == num6)
                 {
                     break;
                 }
             }
             if (i != 0)
             {
                 Vector4 targetPos = vehicleData.GetTargetPos(i - 1);
                 while (i < 4)
                 {
                     vehicleData.SetTargetPos(i++, targetPos);
                 }
             }
         }
         vector = vehicleData.m_targetPos0 - (Vector4)frameData.m_position;
         sqrMagnitude = vector.sqrMagnitude;
     }
     if (leaderData.m_path != 0u && (leaderData.m_flags & Vehicle.Flags.WaitingPath) == Vehicle.Flags.None)
     {
         NetManager instance = Singleton<NetManager>.instance;
         byte b = leaderData.m_pathPositionIndex;
         byte lastPathOffset = leaderData.m_lastPathOffset;
         if (b == 255)
         {
             b = 0;
         }
         float num7 = 1f + leaderData.CalculateTotalLength(leaderID);
         PathManager instance2 = Singleton<PathManager>.instance;
         PathUnit.Position pathPos;
         if (instance2.m_pathUnits.m_buffer[(int)((UIntPtr)leaderData.m_path)].GetPosition(b >> 1, out pathPos))
         {
             instance.m_segments.m_buffer[(int)pathPos.m_segment].AddTraffic(Mathf.RoundToInt(num7 * 2.5f));
             bool flag2 = false;
             if ((b & 1) == 0 || lastPathOffset == 0)
             {
                 uint laneID = PathManager.GetLaneID(pathPos);
                 if (laneID != 0u)
                 {
                     Vector3 b2 = instance.m_lanes.m_buffer[(int)((UIntPtr)laneID)].CalculatePosition((float)pathPos.m_offset * 0.003921569f);
                     float num8 = 0.5f * magnitude * magnitude / carAI.m_info.m_braking + carAI.m_info.m_generatedInfo.m_size.z * 0.5f;
                     if (Vector3.Distance(frameData.m_position, b2) >= num8 - 1f)
                     {
                         instance.m_lanes.m_buffer[(int)((UIntPtr)laneID)].ReserveSpace(num7);
                         flag2 = true;
                     }
                 }
             }
             if (!flag2 && instance2.m_pathUnits.m_buffer[(int)((UIntPtr)leaderData.m_path)].GetNextPosition(b >> 1, out pathPos))
             {
//.........这里部分代码省略.........
开发者ID:moverperfect,项目名称:csl-traffic,代码行数:101,代码来源:CustomCarAI.cs

示例5: SimulationStep

        public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics)
        {
            uint currentFrameIndex = Singleton<SimulationManager>.instance.m_currentFrameIndex;
            frameData.m_position += frameData.m_velocity * 0.5f;
            frameData.m_swayPosition += frameData.m_swayVelocity * 0.5f;
            float acceleration = this.m_info.m_acceleration;
            float braking = this.m_info.m_braking;
            float magnitude = frameData.m_velocity.magnitude;
            Vector3 vector = (Vector3)vehicleData.m_targetPos0 - frameData.m_position;
            float sqrMagnitude = vector.sqrMagnitude;
            float num = (magnitude + acceleration) * (0.5f + 0.5f * (magnitude + acceleration) / braking) + this.m_info.m_generatedInfo.m_size.z * 0.5f;
            float num2 = Mathf.Max(magnitude + acceleration, 5f);
            if (lodPhysics >= 2 && (ulong)(currentFrameIndex >> 4 & 3u) == (ulong)((long)(vehicleID & 3)))
            {
                num2 *= 2f;
            }
            float num3 = Mathf.Max((num - num2) / 3f, 1f);
            float num4 = num2 * num2;
            float num5 = num3 * num3;
            int i = 0;
            bool flag = false;
            if ((sqrMagnitude < num4 || vehicleData.m_targetPos3.w < 0.01f) && (leaderData.m_flags & (Vehicle.Flags.WaitingPath | Vehicle.Flags.Stopped)) == Vehicle.Flags.None)
            {
                if (leaderData.m_path != 0u)
                {
                    base.UpdatePathTargetPositions(vehicleID, ref vehicleData, frameData.m_position, ref i, 4, num4, num5);
                    if ((leaderData.m_flags & Vehicle.Flags.Spawned) == Vehicle.Flags.None)
                    {
                        frameData = vehicleData.m_frame0;
                        return;
                    }
                }
                if ((leaderData.m_flags & Vehicle.Flags.WaitingPath) == Vehicle.Flags.None)
                {
                    while (i < 4)
                    {
                        float minSqrDistance;
                        Vector3 refPos;
                        if (i == 0)
                        {
                            minSqrDistance = num4;
                            refPos = frameData.m_position;
                            flag = true;
                        }
                        else
                        {
                            minSqrDistance = num5;
                            refPos = vehicleData.GetTargetPos(i - 1);
                        }
                        int num6 = i;
                        this.UpdateBuildingTargetPositions(vehicleID, ref vehicleData, refPos, leaderID, ref leaderData, ref i, minSqrDistance);
                        if (i == num6)
                        {
                            break;
                        }
                    }
                    if (i != 0)
                    {
                        Vector4 targetPos = vehicleData.GetTargetPos(i - 1);
                        while (i < 4)
                        {
                            vehicleData.SetTargetPos(i++, targetPos);
                        }
                    }
                }
                vector = (Vector3)vehicleData.m_targetPos0 - frameData.m_position;
                sqrMagnitude = vector.sqrMagnitude;
            }
            if (leaderData.m_path != 0u && (leaderData.m_flags & Vehicle.Flags.WaitingPath) == Vehicle.Flags.None)
            {
                NetManager instance = Singleton<NetManager>.instance;
                byte b = leaderData.m_pathPositionIndex;
                byte lastPathOffset = leaderData.m_lastPathOffset;
                if (b == 255)
                {
                    b = 0;
                }
                float num7 = 1f + leaderData.CalculateTotalLength(leaderID);
                PathManager instance2 = Singleton<PathManager>.instance;
                PathUnit.Position pathPos;
                if (instance2.m_pathUnits.m_buffer[(int)((UIntPtr)leaderData.m_path)].GetPosition(b >> 1, out pathPos))
                {
                    instance.m_segments.m_buffer[(int)pathPos.m_segment].AddTraffic(Mathf.RoundToInt(num7 * 2.5f));
                    bool flag2 = false;
                    if ((b & 1) == 0 || lastPathOffset == 0)
                    {
                        uint laneID = PathManager.GetLaneID(pathPos);
                        if (laneID != 0u)
                        {
                            Vector3 b2 = instance.m_lanes.m_buffer[(int)((UIntPtr)laneID)].CalculatePosition((float)pathPos.m_offset * 0.003921569f);
                            float num8 = 0.5f * magnitude * magnitude / this.m_info.m_braking + this.m_info.m_generatedInfo.m_size.z * 0.5f;
                            if (Vector3.Distance(frameData.m_position, b2) >= num8 - 1f)
                            {
                                instance.m_lanes.m_buffer[(int)((UIntPtr)laneID)].ReserveSpace(num7);
                                flag2 = true;
                            }
                        }
                    }
                    if (!flag2 && instance2.m_pathUnits.m_buffer[(int)((UIntPtr)leaderData.m_path)].GetNextPosition(b >> 1, out pathPos))
                    {
//.........这里部分代码省略.........
开发者ID:fadster,项目名称:TrafficManager_ImprovedAI,代码行数:101,代码来源:CustomCarAI.cs

示例6: CheckOverlap

 private static ushort CheckOverlap(ushort vehicleID, ref Vehicle vehicleData, Segment3 segment, ushort ignoreVehicle, ushort otherID, ref Vehicle otherData, ref bool overlap, Vector3 min, Vector3 max)
 {
     if (ignoreVehicle == 0 || (otherID != ignoreVehicle && otherData.m_leadingVehicle != ignoreVehicle && otherData.m_trailingVehicle != ignoreVehicle))
     {
         VehicleInfo info = otherData.Info;
         if (info.m_vehicleType == VehicleInfo.VehicleType.Bicycle)
         {
             return otherData.m_nextGridVehicle;
         }
         if (((vehicleData.m_flags | otherData.m_flags) & Vehicle.Flags.Transition) == Vehicle.Flags.None && (vehicleData.m_flags & Vehicle.Flags.Underground) != (otherData.m_flags & Vehicle.Flags.Underground))
         {
             return otherData.m_nextGridVehicle;
         }
         Vector3 vector = Vector3.Min (otherData.m_segment.Min (), otherData.m_targetPos3);
         Vector3 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)
         {
             Vector3 rhs = Vector3.Normalize (segment.b - segment.a);
             Vector3 lhs = otherData.m_segment.a - vehicleData.m_segment.b;
             Vector3 lhs2 = otherData.m_segment.b - vehicleData.m_segment.b;
             if (Vector3.Dot (lhs, rhs) >= 1f || Vector3.Dot (lhs2, rhs) >= 1f)
             {
                 float num2;
                 float num3;
                 float num = segment.DistanceSqr (otherData.m_segment, out num2, out num3);
                 if (num < 4f)
                 {
                     overlap = true;
                 }
                 Vector3 a = otherData.m_segment.b;
                 segment.a.y = segment.a.y * 0.5f;
                 segment.b.y = segment.b.y * 0.5f;
                 for (int i = 0; i < 4; i++)
                 {
                     Vector3 vector3 = otherData.GetTargetPos (i);
                     Segment3 segment2 = new Segment3 (a, vector3);
                     segment2.a.y = segment2.a.y * 0.5f;
                     segment2.b.y = segment2.b.y * 0.5f;
                     if (segment2.LengthSqr () > 0.01f)
                     {
                         num = segment.DistanceSqr (segment2, out num2, out num3);
                         if (num < 4f)
                         {
                             overlap = true;
                             break;
                         }
                     }
                     a = vector3;
                 }
             }
         }
     }
     return otherData.m_nextGridVehicle;
 }
开发者ID:klyte45,项目名称:CS-VehicleLimitExpander,代码行数:54,代码来源:FakeTrainAI.cs


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