SliderJoint.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. namespace BansheeEngine
  4. {
  5. /// <summary>
  6. /// Joint that removes all but a single translational degree of freedom. Bodies are allowed to move along a single axis.
  7. /// </summary>
  8. public sealed class SliderJoint : Joint
  9. {
  10. [SerializeField]
  11. private SerializableData data = new SerializableData();
  12. /// <summary>
  13. /// Determines the limit that constrains the movement of the joint to a specific minimum and maximum distance. You
  14. /// must enable <see cref="EnableLimit"/> for this to be enforced.
  15. /// </summary>
  16. public LimitLinearRange Limit
  17. {
  18. get { return [email protected]; }
  19. set
  20. {
  21. if ([email protected] == value)
  22. return;
  23. [email protected] = value;
  24. if (Native != null)
  25. Native.Limit = value;
  26. }
  27. }
  28. /// <summary>
  29. /// Enables or disables the limit that clamps the movement of the joint.
  30. /// </summary>
  31. public bool EnableLimit
  32. {
  33. get { return [email protected]; }
  34. set
  35. {
  36. if ([email protected] == value)
  37. return;
  38. [email protected] = value;
  39. if (Native != null)
  40. Native.EnableLimit = value;
  41. }
  42. }
  43. /// <summary>
  44. /// Returns the native joint wrapped by this component.
  45. /// </summary>
  46. private NativeSliderJoint Native
  47. {
  48. get { return (NativeSliderJoint)native; }
  49. }
  50. /// <inheritdoc/>
  51. internal override NativeJoint CreateNative()
  52. {
  53. NativeSliderJoint joint = new NativeSliderJoint(commonData.@internal, data.@internal);
  54. return joint;
  55. }
  56. /// <summary>
  57. /// Holds all data the joint component needs to persist through serialization.
  58. /// </summary>
  59. [SerializeObject]
  60. internal new class SerializableData
  61. {
  62. public ScriptSliderJointData @internal;
  63. public SerializableData()
  64. {
  65. @internal.limit = new LimitLinearRange();
  66. @internal.enableLimit = false;
  67. }
  68. }
  69. }
  70. }