Esempio n. 1
0
    public override bool GetDismountPosition(BasePlayer player, out Vector3 res)
    {
        BaseVehicle baseVehicle = base.VehicleParent();

        if (baseVehicle != null)
        {
            return(baseVehicle.GetDismountPosition(player, out res));
        }
        List <Vector3> list = Pool.GetList <Vector3>();

        Transform[] transformArrays = this.dismountPositions;
        for (int i = 0; i < (int)transformArrays.Length; i++)
        {
            Transform transforms = transformArrays[i];
            if (this.ValidDismountPosition(transforms.transform.position))
            {
                list.Add(transforms.transform.position);
            }
        }
        if (list.Count != 0)
        {
            Vector3 vector3 = player.transform.position;
            list.Sort((Vector3 a, Vector3 b) => Vector3.Distance(a, vector3).CompareTo(Vector3.Distance(b, vector3)));
            res = list[0];
            Pool.FreeList <Vector3>(ref list);
            return(true);
        }
        Debug.LogWarning(string.Concat(new object[] { "Failed to find dismount position for player :", player.displayName, " / ", player.userID, " on obj : ", base.gameObject.name }));
        Pool.FreeList <Vector3>(ref list);
        res = player.transform.position;
        return(false);
    }
Esempio n. 2
0
    public virtual bool GetDismountPosition(BasePlayer player, out Vector3 res)
    {
        BaseVehicle baseVehicle = this.VehicleParent();

        if (baseVehicle != null)
        {
            return(baseVehicle.GetDismountPosition(player, out res));
        }
        int num = 0;

        Transform[] transformArrays = this.dismountPositions;
        for (int i = 0; i < (int)transformArrays.Length; i++)
        {
            Transform transforms = transformArrays[i];
            if (this.ValidDismountPosition(transforms.transform.position))
            {
                res = transforms.transform.position;
                return(true);
            }
            num++;
        }
        Debug.LogWarning(string.Concat(new object[] { "Failed to find dismount position for player :", player.displayName, " / ", player.userID, " on obj : ", base.gameObject.name }));
        res = player.transform.position;
        return(false);
    }
Esempio n. 3
0
    public override bool GetDismountPosition(BasePlayer player, out Vector3 res)
    {
        BaseVehicle baseVehicle = VehicleParent();

        if (baseVehicle != null)
        {
            return(baseVehicle.GetDismountPosition(player, out res));
        }
        List <Vector3> obj = Facepunch.Pool.GetList <Vector3>();
        Vector3        visualCheckOrigin = player.TriggerPoint();

        Transform[] array = dismountPositions;
        foreach (Transform transform in array)
        {
            if (ValidDismountPosition(transform.transform.position, visualCheckOrigin))
            {
                obj.Add(transform.transform.position);
            }
        }
        if (obj.Count == 0)
        {
            Debug.LogWarning("Failed to find dismount position for player :" + player.displayName + " / " + player.userID + " on obj : " + base.gameObject.name);
            Facepunch.Pool.FreeList(ref obj);
            res = player.transform.position;
            return(false);
        }
        Vector3 pos = player.transform.position;

        obj.Sort((Vector3 a, Vector3 b) => Vector3.Distance(a, pos).CompareTo(Vector3.Distance(b, pos)));
        res = obj[0];
        Facepunch.Pool.FreeList(ref obj);
        return(true);
    }
Esempio n. 4
0
    public virtual bool GetDismountPosition(BasePlayer player, out Vector3 res)
    {
        BaseVehicle baseVehicle = VehicleParent();

        if (baseVehicle != null)
        {
            return(baseVehicle.GetDismountPosition(player, out res));
        }
        int     num = 0;
        Vector3 visualCheckOrigin = player.TriggerPoint();

        Transform[] array = dismountPositions;
        foreach (Transform transform in array)
        {
            if (ValidDismountPosition(transform.transform.position, visualCheckOrigin))
            {
                res = transform.transform.position;
                return(true);
            }
            num++;
        }
        Debug.LogWarning("Failed to find dismount position for player :" + player.displayName + " / " + player.userID + " on obj : " + base.gameObject.name);
        res = player.transform.position;
        return(false);
    }
Esempio n. 5
0
    public override Vector3 GetDismountPosition(BasePlayer player)
    {
        BaseVehicle baseVehicle = this.VehicleParent();

        if (Object.op_Inequality((Object)baseVehicle, (Object)null))
        {
            return(baseVehicle.GetDismountPosition(player));
        }
        List <Vector3> list = (List <Vector3>)Pool.GetList <Vector3>();

        foreach (Transform dismountPosition in this.dismountPositions)
        {
            if (this.ValidDismountPosition(((Component)dismountPosition).get_transform().get_position()))
            {
                list.Add(((Component)dismountPosition).get_transform().get_position());
            }
        }
        if (list.Count == 0)
        {
            Debug.LogWarning((object)("Failed to find dismount position for player :" + player.displayName + " / " + (object)player.userID + " on obj : " + ((Object)((Component)this).get_gameObject()).get_name()));
            // ISSUE: cast to a reference type
            Pool.FreeList <Vector3>((List <M0>&) ref list);
            return(BaseMountable.DISMOUNT_POS_INVALID);
        }
        Vector3 pos = ((Component)player).get_transform().get_position();

        list.Sort((Comparison <Vector3>)((a, b) => Vector3.Distance(a, pos).CompareTo(Vector3.Distance(b, pos))));
        Vector3 vector3 = list[0];

        // ISSUE: cast to a reference type
        Pool.FreeList <Vector3>((List <M0>&) ref list);
        return(vector3);
    }
Esempio n. 6
0
    public virtual Vector3 GetDismountPosition(BasePlayer player)
    {
        BaseVehicle baseVehicle = this.VehicleParent();

        if (Object.op_Inequality((Object)baseVehicle, (Object)null))
        {
            return(baseVehicle.GetDismountPosition(player));
        }
        int num = 0;

        foreach (Transform dismountPosition in this.dismountPositions)
        {
            if (this.ValidDismountPosition(((Component)dismountPosition).get_transform().get_position()))
            {
                return(((Component)dismountPosition).get_transform().get_position());
            }
            ++num;
        }
        Debug.LogWarning((object)("Failed to find dismount position for player :" + player.displayName + " / " + (object)player.userID + " on obj : " + ((Object)((Component)this).get_gameObject()).get_name()));
        return(BaseMountable.DISMOUNT_POS_INVALID);
    }