/// <summary> /// This will detach from anything holding it. /// </summary> public void Detach() { _events.Detached.Invoke(this, _attachedTo); if (null != _attachedTo) { _attachedTo.StopHoldingAttachable(this); _attachedTo = null; } }
/// <summary> /// Passed in attachable will begin holding this. /// </summary> public void AttachTo(AttachableHolder holder) { _attachedTo = holder; holder.BeginHoldingAttachable(this); if (_lockObjectOnAttach) { MovementInteraction.DisableAfterFinishDamp = true; } _events.Attached.Invoke(this, holder); }
public bool CanAttach(AttachableHolder holder) { if (holder.CanHoldTags.CompareTags(_tags)) { return(true); } if (_canAttachTo.Contains(holder)) { return(true); } return(false); }
private void Attached(Attachable attachable, AttachableHolder holder) { enabled = false; if (null != _guideVisual) { _guideVisual.gameObject.SetActive(false); } _drawHighlight = false; OnStepCompleted(); Analytics.Add("attachment_accuracy", _enteredRotation / 36f); Debug.Log("attachment_accuracy " + _enteredRotation / 36f); Analytics.Add("drops", Mathf.Clamp(_grabCount, 0, 5)); Debug.Log("drops " + _grabCount); }
private void PhysicsVolumeOnExited(Collider collider) { AttachableHolder holder = collider.GetComponent <AttachableHolder>(); if (null != holder && _entered.Contains(holder)) { if (null != _releaseSound) { _audioSource.PlayOneShot(_releaseSound); } _entered.Remove(holder); if (_entered.Count == 0) { MovementInteraction.ClearOverrideDampTarget(); } _events.Exited.Invoke(this, holder); } }
private void PhysicsVolumeOnEntered(Collider collider) { AttachableHolder holder = collider.GetComponent <AttachableHolder>(); if (null != holder && holder.CanHold(this)) { if (null != _attachSound) { _audioSource.PlayOneShot(_attachSound); } _entered.Add(holder); if (_entered.Count == 1) { MovementInteraction.SetOverrideDampTarget(holder.transform); } _events.Entered.Invoke(this, holder); } }
private void Entered(Attachable attachable, AttachableHolder holder) { _enteredRotation = Vector3.Angle(attachable.ParentTransform.up, holder.transform.up); }