using System; using System.IO; using UnityEngine; public abstract class DynamicBoneColliderBase : MonoBehaviour { public virtual string TypeName { get { return string.Empty; } } public virtual bool Collide(ref Vector3 particlePosition, float particleRadius) { return false; } public virtual void Serialize(BinaryWriter f_bw, int f_nVersion) { if (base.transform.name.IndexOf("_HIT_", 0) != 0) { NDebug.MessageBox("確認", base.transform.name + " 名の先頭に _HIT_ を付加して保存します。"); base.transform.name = "_HIT_" + base.transform.name; } f_bw.Write(base.transform.parent.name); f_bw.Write(base.transform.name); f_bw.Write(base.transform.localPosition.x); f_bw.Write(base.transform.localPosition.y); f_bw.Write(base.transform.localPosition.z); f_bw.Write(base.transform.localRotation.x); f_bw.Write(base.transform.localRotation.y); f_bw.Write(base.transform.localRotation.z); f_bw.Write(base.transform.localRotation.w); f_bw.Write(base.transform.localScale.x); f_bw.Write(base.transform.localScale.y); f_bw.Write(base.transform.localScale.z); f_bw.Write((int)this.m_Direction); f_bw.Write(this.m_Center.x); f_bw.Write(this.m_Center.y); f_bw.Write(this.m_Center.z); f_bw.Write((int)this.m_Bound); } public virtual void Deserialize(BinaryReader f_br, int f_nVersion, Transform f_trBodyBoneRoot) { string name = f_br.ReadString(); Transform transform = CMT.SearchObjName(f_trBodyBoneRoot, name, true); if (transform == null) { NDebug.Assert("物理体親ボーンがありません。", false); } base.transform.SetParent(transform, false); base.transform.name = f_br.ReadString(); base.transform.localPosition = new Vector3(f_br.ReadSingle(), f_br.ReadSingle(), f_br.ReadSingle()); base.transform.localRotation = new Quaternion(f_br.ReadSingle(), f_br.ReadSingle(), f_br.ReadSingle(), f_br.ReadSingle()); base.transform.localScale = new Vector3(f_br.ReadSingle(), f_br.ReadSingle(), f_br.ReadSingle()); this.m_Direction = (DynamicBoneColliderBase.Direction)f_br.ReadInt32(); this.m_Center.Set(f_br.ReadSingle(), f_br.ReadSingle(), f_br.ReadSingle()); this.m_Bound = (DynamicBoneColliderBase.Bound)f_br.ReadInt32(); } [Tooltip("The axis of the capsule's height.")] public DynamicBoneColliderBase.Direction m_Direction = DynamicBoneColliderBase.Direction.Y; [Tooltip("The center of the sphere or capsule, in the object's local space.")] public Vector3 m_Center = Vector3.zero; [Tooltip("Constrain bones to outside bound or inside bound.")] public DynamicBoneColliderBase.Bound m_Bound; public enum Direction { X, Y, Z } public enum Bound { Outside, Inside } }