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(); } }
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); }
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)); }