/// <summary> /// Throws liftable object up and in the 'facingDirection' of the thrower. /// </summary> /// <param name="facingDirection"> /// Normalized Vector3 indicating direction thrower is facing. /// </param> public void Throw(Vector3 facingDirection) { Liftable liftable = LiftedObject; LiftedObject = null; liftable.ThrowSelf(facingDirection); }
/// <summary> /// Checks if a gameobject attached to a rigidbody holds Liftable or /// CarryRigidbodiesCarriable components. /// </summary> /// <param name="rb"> /// The rigidbody being checked for components. /// </param> /// <returns> /// True if input rigidbody has a Liftable or CarryRigidbodiesCarriable /// components, false otherwise. /// </returns> private bool IsLiftableOrCarriable(Rigidbody rb) { // If rigidbody is liftable and is not currently being lifted OR is // CarryRigidbodiesCarriable Liftable liftable = rb.GetComponent <Liftable>(); if ((liftable != null && !liftable.IsLifted) || rb.GetComponent <ICarryRigidbodiesCarriable>() != null) { return(true); } return(false); }
//===================================================================== #region Public methods //===================================================================== /// <summary> /// Pairs a lifted object with the lifter. Wrapper methord for /// PairToLifter(). /// </summary> /// <param name="lifter"> /// The Liftable component of the liftable object. /// </param> public void Lift(Liftable liftable) { LiftedObject = liftable; }
/// <summary> /// Drops liftable object currently being lifted. /// </summary> public void Drop() { LiftedObject = null; }
/// <summary> /// Sources and initializes component variables. /// </summary> private void InitVars() { _liftable = GetComponent <Liftable>(); _rigidbody = GetComponent <Rigidbody>(); _startPosition = this.transform.position; }