public override void Update(bool isPlayerIn) { if (bone != null) { if (rotatingPartDataEntry.IsToggle) { bool?value = CheckConditions(isPlayerIn); if (value.HasValue && value.Value) { rotating = !rotating; } } else { bool?value = CheckConditions(isPlayerIn); if (value.HasValue) { rotating = value.Value; } } } if (rotating) { if (hasRange) { { rangePercentage += rotatingPartDataEntry.RotationSpeed * Game.FrameTime * (rangeIncreasing ? 1.0f : -1.0f); Quaternion newRotation = QuaternionUtils.Slerp(rangeMin, rangeMax, rangePercentage, rotatingPartDataEntry.Range.LongestPath); bone.SetRotation(newRotation); if ((rangeIncreasing && rangePercentage >= 1.0f) || (!rangeIncreasing && rangePercentage <= 0.0f)) { rangeIncreasing = !rangeIncreasing; } } #if DEBUG { Quaternion rotation = MatrixUtils.DecomposeRotation(bone.Matrix); Quaternion vehRot = Vehicle.Orientation; Vector3 pos = Vehicle.GetBonePosition(bone.Index); Debug.DrawLine(pos, pos + ((vehRot * rotation).ToVector() * 2.0f), System.Drawing.Color.Red); Debug.DrawLine(pos, pos + ((vehRot * bone.OriginalRotation).ToVector() * 2.0f), System.Drawing.Color.Blue); Quaternion minRot = vehRot * rangeMin; Quaternion maxRot = vehRot * rangeMax; Debug.DrawLine(pos, pos + (minRot.ToVector() * 2.0f), System.Drawing.Color.Green); Debug.DrawLine(pos, pos + (maxRot.ToVector() * 2.0f), System.Drawing.Color.Purple); } #endif } else { Vector3 axis = rotatingPartDataEntry.RotationAxis; float degrees = rotatingPartDataEntry.RotationSpeed * Game.FrameTime; bone.RotateAxis(axis, degrees); } } }