/// <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); }
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); } }
private Matrix3x2 GetWorldMatrix(Matrix3x2 localMatrix) { var transformed = localMatrix * Matrix; return(IsInheiritingParentTransform ? ParentTransform.GetWorldMatrix(transformed) : transformed); }
public Matrix3x2 GetPositionScaledWorldMatrix(float positionScale) { return(IsInheiritingParentTransform? ParentTransform.GetWorldMatrix(GetPositionScaledMatrix(positionScale)) : GetPositionScaledMatrix(positionScale)); }