예제 #1
0
 private static BuildingProximity.ProximityInfo GetProximity(
     Construction construction1,
     Vector3 position1,
     Quaternion rotation1,
     Construction construction2,
     Vector3 position2,
     Quaternion rotation2)
 {
     BuildingProximity.ProximityInfo proximityInfo = new BuildingProximity.ProximityInfo();
     proximityInfo.hit        = false;
     proximityInfo.connection = false;
     proximityInfo.line       = (Line)null;
     proximityInfo.sqrDist    = float.MaxValue;
     for (int index1 = 0; index1 < construction1.allSockets.Length; ++index1)
     {
         ConstructionSocket allSocket1 = construction1.allSockets[index1] as ConstructionSocket;
         if (!((PrefabAttribute)allSocket1 == (PrefabAttribute)null))
         {
             for (int index2 = 0; index2 < construction2.allSockets.Length; ++index2)
             {
                 Socket_Base allSocket2 = construction2.allSockets[index2];
                 if (allSocket1.CanConnect(position1, rotation1, allSocket2, position2, rotation2))
                 {
                     proximityInfo.connection = true;
                     return(proximityInfo);
                 }
             }
         }
     }
     if (!proximityInfo.connection && construction1.allProximities.Length != 0)
     {
         for (int index1 = 0; index1 < construction1.allSockets.Length; ++index1)
         {
             ConstructionSocket allSocket = construction1.allSockets[index1] as ConstructionSocket;
             if (!((PrefabAttribute)allSocket == (PrefabAttribute)null) && allSocket.socketType == ConstructionSocket.Type.Wall)
             {
                 Vector3 selectPivot1 = allSocket.GetSelectPivot(position1, rotation1);
                 for (int index2 = 0; index2 < construction2.allProximities.Length; ++index2)
                 {
                     Vector3 selectPivot2 = construction2.allProximities[index2].GetSelectPivot(position2, rotation2);
                     Line    line;
                     ((Line) ref line).\u002Ector(selectPivot1, selectPivot2);
                     Vector3 vector3      = Vector3.op_Subtraction((Vector3)line.point1, (Vector3)line.point0);
                     float   sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude();
                     if ((double)sqrMagnitude < (double)proximityInfo.sqrDist)
                     {
                         proximityInfo.hit     = true;
                         proximityInfo.line    = line;
                         proximityInfo.sqrDist = sqrMagnitude;
                     }
                 }
             }
         }
     }
     return(proximityInfo);
 }
 private static BuildingProximity.ProximityInfo GetProximity(Construction construction1, Vector3 position1, Quaternion rotation1, Construction construction2, Vector3 position2, Quaternion rotation2)
 {
     BuildingProximity.ProximityInfo proximityInfo = new BuildingProximity.ProximityInfo()
     {
         hit        = false,
         connection = false,
         line       = new Line(),
         sqrDist    = Single.MaxValue
     };
     for (int i = 0; i < (int)construction1.allSockets.Length; i++)
     {
         ConstructionSocket constructionSocket = construction1.allSockets[i] as ConstructionSocket;
         if (constructionSocket != null)
         {
             for (int j = 0; j < (int)construction2.allSockets.Length; j++)
             {
                 if (constructionSocket.CanConnect(position1, rotation1, construction2.allSockets[j], position2, rotation2))
                 {
                     proximityInfo.connection = true;
                     return(proximityInfo);
                 }
             }
         }
     }
     if (!proximityInfo.connection && construction1.allProximities.Length != 0)
     {
         for (int k = 0; k < (int)construction1.allSockets.Length; k++)
         {
             ConstructionSocket constructionSocket1 = construction1.allSockets[k] as ConstructionSocket;
             if (!(constructionSocket1 == null) && constructionSocket1.socketType == ConstructionSocket.Type.Wall)
             {
                 Vector3 selectPivot = constructionSocket1.GetSelectPivot(position1, rotation1);
                 for (int l = 0; l < (int)construction2.allProximities.Length; l++)
                 {
                     Vector3 vector3 = construction2.allProximities[l].GetSelectPivot(position2, rotation2);
                     Line    line    = new Line(selectPivot, vector3);
                     float   single  = (line.point1 - line.point0).sqrMagnitude;
                     if (single < proximityInfo.sqrDist)
                     {
                         proximityInfo.hit     = true;
                         proximityInfo.line    = line;
                         proximityInfo.sqrDist = single;
                     }
                 }
             }
         }
     }
     return(proximityInfo);
 }