/// <summary>
        /// Apply torque.
        /// </summary>
        /// <returns> True is torque limit reached. </returns>
        public bool ApplyTorque(float amount)
        {
            _currentTorque += amount;

            if (_currentTorque < 0 && !Torqued)
            {
                Torqued = true;
                _torqueCompleted.Invoke();
            }
            else if (!Torqued)
            {
                if (_rotateParent)
                {
                    ParentTransform.Rotate(0, -amount, 0, Space.Self);
                }
                else
                {
                    transform.Rotate(0, -amount, 0, Space.Self);
                }
            }

            if (Torqued)
            {
                return(true);
            }
            return(false);
        }
Example #2
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hash = 17;
         hash = hash * 29 + (Name == null ? 0 : Name.GetHashCode());
         hash = hash * 29 + (GroupName == null ? 0 : GroupName.GetHashCode());
         hash = hash * 29 + (ParentTransform == null ? 0 : ParentTransform.GetHashCode());
         hash = hash * 29 + (ParentTransformGetter == null ? 0 : ParentTransformGetter.GetHashCode());
         hash = hash * 29 + (!Position.HasValue ? 0 : Position.Value.GetHashCode());
         hash = hash * 29 + (!Rotation.HasValue ? 0 : Rotation.Value.GetHashCode());
         return(hash);
     }
 }
Example #3
0
        private Matrix3x2 GetWorldMatrix(Matrix3x2 localMatrix)
        {
            var transformed = localMatrix * Matrix;

            return(IsInheiritingParentTransform ? ParentTransform.GetWorldMatrix(transformed) : transformed);
        }
Example #4
0
 public Matrix3x2 GetPositionScaledWorldMatrix(float positionScale)
 {
     return(IsInheiritingParentTransform? ParentTransform.GetWorldMatrix(GetPositionScaledMatrix(positionScale)) : GetPositionScaledMatrix(positionScale));
 }