コード例 #1
0
    protected virtual void CheckPullingObjects()
    {
        bool updateConnected = false;

        for (int i = PullingTogether.Count - 1; i >= 0; i--)
        {
            PullTogether pulling  = PullingTogether[i];
            Vector3      toPoints = pulling.AttachmentPoint.transform.position - pulling.Point.transform.position;
            if (toPoints.magnitude < 1f)
            {
                PullObjectsController puller = pulling.Point.GetComponent <PullObjectsController>();
                if (puller != null)
                {
                    puller.PullSpecific = null;
                }
                Attach(pulling.Point, pulling.Attachment, pulling.AttachmentPoint);
                PullingTogether.RemoveAt(i);
                updateConnected = true;
            }
        }
        if (updateConnected)
        {
            DiscoverConnected();
        }
    }
コード例 #2
0
    public bool Matches(Type matches, bool isAvailable = true)
    {
        if ((HardpointType & matches) == matches)
        {
            if (isAvailable)
            {
                PullObjectsController puller = transform.GetComponent <PullObjectsController>();
                if (puller != null && puller.PullSpecific != null)
                {
                    return(false);
                }

                if (Attached != null)
                {
                    return(false);
                }
                return(true);
            }
        }
        return(false);
    }
コード例 #3
0
    public virtual void PullAndAttach(HardpointController point, AttachmentController attachment, HardpointController attachmentPoint)
    {
        PullableController pullable = attachment.GetComponent <PullableController>();

        if (pullable == null)
        {
            Debug.Log("Cannot pull object that is not pullable.");
            return;
        }


        PullObjectsController puller = point.GetComponent <PullObjectsController>();

        if (puller == null)
        {
            //Debug.Log("Cannot pull and attach as there is no puller on the point.");
            Attach(point, attachment, attachmentPoint);
            DiscoverConnected();
            return;
        }
        puller.PullSpecific = pullable;

        PullingTogether.Add(new PullTogether(point, attachment, attachmentPoint));
    }