using System; using System.Collections.Generic; using UnityEngine; using wf; public class GravityTransformControl : MonoBehaviour { public bool isEnabled { get { return this.isEnabled_; } set { this.isEnabled_ = false; if (value && this.isValid) { this.isEnabled_ = true; } } } public bool isValid { get { return (this.dynamickirtBones != null && this.dynamickirtBones.Count != 0) || (this.dynamicBones != null && this.dynamicBones.Count != 0) || (this.dynamicYureBones != null && this.dynamicYureBones.Count != 0); } } public bool visibleTransTargetObject { get { return this.transTargetObject != null && this.transTargetObject.axis_obj.Visible; } set { if (this.transTargetObject != null) { this.transTargetObject.axis_obj.Visible = value; } } } private void Awake() { if (this.maidBody != null) { return; } Transform parent = base.transform.parent; while (parent != null) { this.maidBody = parent.GetComponent(); if (this.maidBody != null) { break; } parent = parent.parent; } } public void SetTargetSlods(TBody.SlotID[] slotIds) { this.Awake(); this.targetSloatIds = slotIds; this.dynamickirtBones.Clear(); this.dynamicBones.Clear(); this.dynamicYureBones.Clear(); foreach (TBody.SlotID i2 in slotIds) { if (this.maidBody.goSlot[(int)i2] != null && !(this.maidBody.goSlot[(int)i2].obj == null)) { DynamicSkirtBone component = this.maidBody.goSlot[(int)i2].obj.GetComponent(); if (component != null) { this.dynamickirtBones.Add(new KeyValuePair(component, component.m_vGravity)); } DynamicBone component2 = this.maidBody.goSlot[(int)i2].obj.GetComponent(); if (component2 != null) { this.dynamicBones.Add(new KeyValuePair(component2, component2.m_Force)); } DynamicYureBone component3 = this.maidBody.goSlot[(int)i2].obj.GetComponent(); if (component3 != null) { this.dynamicYureBones.Add(new KeyValuePair(component3, component3.status.force)); } } } } public bool OnChangeMekure() { bool flag = false; foreach (KeyValuePair keyValuePair in this.dynamickirtBones) { if (keyValuePair.Key == null) { flag = true; break; } } if (!flag) { foreach (KeyValuePair keyValuePair2 in this.dynamicBones) { if (keyValuePair2.Key == null) { flag = true; break; } } } if (flag) { this.SetTargetSlods(this.targetSloatIds); } return true; } public void Update() { Vector3 b = Vector3.zero; Vector3 vector = base.transform.localPosition; vector = new Vector3(Mathf.Max(Mathf.Min(1f, vector.x), -1f), Mathf.Max(Mathf.Min(1f, vector.y), -1f), Mathf.Max(Mathf.Min(1f, vector.z), -1f)); base.transform.localPosition = vector; if (!this.isEnabled) { vector = Vector3.zero; } if (!wf.Math.Approximately(vector, Vector3.zero)) { b = vector * this.forceRate; } foreach (KeyValuePair keyValuePair in this.dynamickirtBones) { DynamicSkirtBone key = keyValuePair.Key; Vector3 vector2 = keyValuePair.Value + b; if (!wf.Math.Approximately(key.m_vGravity, vector2)) { key.m_vGravity = vector2; key.UpdateParameters(); } } foreach (KeyValuePair keyValuePair2 in this.dynamicBones) { DynamicBone key2 = keyValuePair2.Key; Vector3 vector3 = keyValuePair2.Value + b; if (!wf.Math.Approximately(key2.m_Force, vector3)) { key2.m_Force = vector3; key2.UpdateParameters(); } } foreach (KeyValuePair keyValuePair3 in this.dynamicYureBones) { DynamicYureBone key3 = keyValuePair3.Key; Vector3 vector4 = keyValuePair3.Value + b; if (!wf.Math.Approximately(key3.status.force, vector4)) { key3.status.force = vector4; key3.UpdateParameters(); } } } public float forceRate = 1f; public PhotoTransTargetObject transTargetObject; private TBody maidBody; private TBody.SlotID[] targetSloatIds; private List> dynamickirtBones = new List>(); private List> dynamicBones = new List>(); private List> dynamicYureBones = new List>(); private bool isEnabled_; }