Ejemplo n.º 1
0
    public Hardpoint GetHardpointNear(Vector3 worldPos, float maxRange, Hardpoint.hardpoint_type type)
    {
        Hardpoint hardpoint;

        List <Hardpoint> .Enumerator enumerator = this._points.GetEnumerator();
        try
        {
            while (enumerator.MoveNext())
            {
                Hardpoint current = enumerator.Current;
                if (current.type == type)
                {
                    if (current.IsFree())
                    {
                        if (Vector3.Distance(current.transform.position, worldPos) > maxRange)
                        {
                            continue;
                        }
                        hardpoint = current;
                        return(hardpoint);
                    }
                }
            }
            return(null);
        }
        finally
        {
            ((IDisposable)(object)enumerator).Dispose();
        }
        return(hardpoint);
    }
Ejemplo n.º 2
0
 public Hardpoint GetHardpointNear(Vector3 worldPos, float maxRange, Hardpoint.hardpoint_type type)
 {
     foreach (Hardpoint hardpoint in this._points)
     {
         if (((hardpoint.type == type) && hardpoint.IsFree()) && (Vector3.Distance(hardpoint.transform.position, worldPos) <= maxRange))
         {
             return(hardpoint);
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
    public static Hardpoint GetHardpointFromRay(Ray ray, Hardpoint.hardpoint_type type)
    {
        RaycastHit        raycastHit;
        bool              flag;
        MeshBatchInstance meshBatchInstance;

        if (Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray, out raycastHit, 10f, out flag, out meshBatchInstance))
        {
            IDMain dMain = (!flag ? IDBase.GetMain(raycastHit.collider) : meshBatchInstance.idMain);
            if (dMain)
            {
                HardpointMaster component = dMain.GetComponent <HardpointMaster>();
                if (component)
                {
                    return(component.GetHardpointNear(raycastHit.point, type));
                }
            }
        }
        return(null);
    }
Ejemplo n.º 4
0
 public Hardpoint GetHardpointNear(Vector3 worldPos, Hardpoint.hardpoint_type type)
 {
     return(this.GetHardpointNear(worldPos, 3f, type));
 }