BaseCustomParts.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using UnityEngine;
  3. namespace SceneEditWindow
  4. {
  5. public class BaseCustomParts
  6. {
  7. public BaseCustomParts(Maid maid, TBody.SlotID slotId, string apName)
  8. {
  9. this.maid = maid;
  10. this.slotId = slotId;
  11. this.apName = ((!string.IsNullOrEmpty(apName)) ? apName : null);
  12. }
  13. public Maid maid { get; private set; }
  14. public TBody.SlotID slotId { get; private set; }
  15. public string apName { get; private set; }
  16. public bool enabled
  17. {
  18. get
  19. {
  20. return this.maid.body0.maid.body0.GetEnableAttachPointEdit(this.slotId, this.apName);
  21. }
  22. set
  23. {
  24. if (!value)
  25. {
  26. this.Reset();
  27. }
  28. this.maid.body0.maid.body0.SetEnableAttachPointEdit(value, this.slotId, this.apName);
  29. }
  30. }
  31. public Vector3 position
  32. {
  33. get
  34. {
  35. Vector3 result;
  36. Quaternion quaternion;
  37. Vector3 vector;
  38. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out result, out quaternion, out vector);
  39. return result;
  40. }
  41. set
  42. {
  43. Vector3 vector;
  44. Quaternion qRotWorld;
  45. Vector3 vScaleRate;
  46. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out vector, out qRotWorld, out vScaleRate);
  47. this.maid.body0.SetAttachPointWorld(this.slotId, this.apName, value, qRotWorld, vScaleRate);
  48. }
  49. }
  50. public Quaternion rotation
  51. {
  52. get
  53. {
  54. Vector3 vector;
  55. Quaternion result;
  56. Vector3 vector2;
  57. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out vector, out result, out vector2);
  58. return result;
  59. }
  60. set
  61. {
  62. Vector3 vPosWorld;
  63. Quaternion quaternion;
  64. Vector3 vScaleRate;
  65. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out vPosWorld, out quaternion, out vScaleRate);
  66. this.maid.body0.SetAttachPointWorld(this.slotId, this.apName, vPosWorld, value, vScaleRate);
  67. }
  68. }
  69. public Vector3 scale
  70. {
  71. get
  72. {
  73. Vector3 vector;
  74. Quaternion quaternion;
  75. Vector3 result;
  76. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out vector, out quaternion, out result);
  77. return result;
  78. }
  79. set
  80. {
  81. Vector3 vPosWorld;
  82. Quaternion qRotWorld;
  83. Vector3 vector;
  84. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out vPosWorld, out qRotWorld, out vector);
  85. this.maid.body0.SetAttachPointWorld(this.slotId, this.apName, vPosWorld, qRotWorld, value);
  86. }
  87. }
  88. public void SetTransformData(Transform transform, bool setWorldData = true)
  89. {
  90. if (setWorldData)
  91. {
  92. this.maid.body0.SetAttachPointWorld(this.slotId, this.apName, transform.position, transform.rotation, transform.localScale);
  93. }
  94. else
  95. {
  96. this.maid.body0.SetAttachPointLocal(this.slotId, this.apName, transform.localPosition, transform.localRotation, transform.localScale);
  97. }
  98. }
  99. public void SetTransformData(Vector3 position, Quaternion rotation, Vector3 scale, bool setWorldData = true)
  100. {
  101. if (setWorldData)
  102. {
  103. this.maid.body0.SetAttachPointWorld(this.slotId, this.apName, position, rotation, scale);
  104. }
  105. else
  106. {
  107. this.maid.body0.SetAttachPointLocal(this.slotId, this.apName, position, rotation, scale);
  108. }
  109. }
  110. public void GetTransformData(out Vector3 position, out Quaternion rotation, out Vector3 scale, bool getWorldData = true)
  111. {
  112. if (getWorldData)
  113. {
  114. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out position, out rotation, out scale);
  115. }
  116. else
  117. {
  118. this.maid.body0.GetAttachPointLocal(this.slotId, this.apName, out position, out rotation, out scale);
  119. }
  120. }
  121. public void SaveBackup()
  122. {
  123. this.maid.body0.CopyAttachPoint(this.slotId, this.apName);
  124. }
  125. public void LoadBackup()
  126. {
  127. this.maid.body0.PasteAttachPoint(this.slotId, this.apName);
  128. }
  129. public void Reset()
  130. {
  131. this.maid.body0.ResetAttachPoint(this.slotId, this.apName);
  132. Vector3 vPosWorld;
  133. Quaternion qRotWorld;
  134. Vector3 vScaleRate;
  135. this.maid.body0.GetAttachPointWorld(this.slotId, this.apName, out vPosWorld, out qRotWorld, out vScaleRate);
  136. this.maid.body0.SetAttachPointWorld(this.slotId, this.apName, vPosWorld, qRotWorld, vScaleRate);
  137. }
  138. }
  139. }