예제 #1
0
        private static SwayBone ReadSwayBone([NotNull, ItemNotNull] string[] lines, [NotNull] string line, ref int i)
        {
            var kv         = ParseKeyValue(line);
            var bone       = new SwayBone();
            var anyPropSet = false;

            do
            {
                var setAProp = true;

                switch (kv.Key)
                {
                case "SwayBone":
                    bone.Path = kv.Value;
                    setAProp  = false;
                    break;

                case "radius":
                    bone.Radius = Convert.ToSingle(kv.Value);
                    break;

                case "type":
                    bone.Type = ParseColliderType(kv.Value);
                    break;

                case "isSkirt":
                    bone.IsSkirt = Convert.ToBoolean(kv.Value);
                    break;

                case "HitMuteForce":
                    bone.HitMuteForce = Convert.ToBoolean(kv.Value);
                    break;

                case "HitMuteRate":
                    bone.HitMuteRate = Convert.ToSingle(kv.Value);
                    break;

                case "isZConstraint":
                    bone.IsZConstraint = Convert.ToBoolean(kv.Value);
                    break;

                case "limitAngle":
                    bone.HasAngleLimit = Convert.ToBoolean(kv.Value);
                    break;

                case "useBindDir":
                    bone.UseBindingDirection = Convert.ToBoolean(kv.Value);
                    break;

                case "minYAngle":
                    bone.MinYAngle = Convert.ToSingle(kv.Value);
                    break;

                case "maxYAngle":
                    bone.MaxYAngle = Convert.ToSingle(kv.Value);
                    break;

                case "minZAngle":
                    bone.MinZAngle = Convert.ToSingle(kv.Value);
                    break;

                case "maxZAngle":
                    bone.MaxZAngle = Convert.ToSingle(kv.Value);
                    break;

                case "followForce":
                    bone.FollowForce = Convert.ToSingle(kv.Value);
                    break;

                case "refParam":
                    bone.RefParam = ParseRefParam(kv.Value);
                    break;

                case "stiffnessForce":
                    bone.StiffnessForce = Convert.ToSingle(kv.Value);
                    break;

                case "dragForce":
                    bone.DragForce = Convert.ToSingle(kv.Value);
                    break;

                case "hitTwice":
                    bone.HitTwice = Convert.ToBoolean(kv.Value);
                    break;

                case "useLinkHit":
                    bone.UseLinkHit = Convert.ToBoolean(kv.Value);
                    break;

                case "gravity":
                    bone.Gravity = ParseVector3(kv.Value);
                    break;

                case "colliderOffset":
                    bone.ColliderOffset = ParseVector3(kv.Value);
                    break;

                case "sideSpringTorelance":     // not my typo
                    bone.SideSpringTolerance = Convert.ToSingle(kv.Value);
                    break;

                case "sideSpringForce":
                    bone.SideSpringForce = Convert.ToSingle(kv.Value);
                    break;

                case "sideAntiSpringTorelance":     // not my typo
                    bone.SideAntiSpringTolerance = Convert.ToSingle(kv.Value);
                    break;

                case "sideAntiSpringForce":
                    bone.SideAntiSpringForce = Convert.ToSingle(kv.Value);
                    break;

                case "antiFoldForceK":
                    bone.AntiFoldForceK = Convert.ToSingle(kv.Value);
                    break;

                case "antiFoldAngle":
                    bone.AntiFoldAngle = Convert.ToSingle(kv.Value);
                    break;

                case "colliders": {
                    var colliderCount    = Convert.ToInt32(kv.Value);
                    var colliderPathList = new List <string>();

                    for (var j = 0; j < colliderCount; ++j)
                    {
                        ++i;
                        line = lines[i];

                        kv = ParseKeyValue(line);

                        colliderPathList.Add(kv.Value);
                    }

                    bone.ColliderPaths = colliderPathList.ToArray();

                    break;
                }

                case "sideLink":
                    bone.SideLinkPath = kv.Value;
                    break;

                default:
                    Debug.LogWarning($"Unknown bone property key/value: {kv.Key} / {kv.Value}");
                    setAProp = false;
                    break;
                }

                anyPropSet = anyPropSet || setAProp;

                {
                    ++i;
                    line = lines[i];

                    if (line.Length == 0 || line[0] != ' ')
                    {
                        // A new entry (manager/collider/bone) starts.
                        // Decrease counter so the next reading attempt will work with auto counter increment.
                        --i;
                        break;
                    }

                    kv = ParseKeyValue(line);
                }
            } while (true);

            if (!anyPropSet)
            {
                throw new ArgumentException("Empty SwayBone body");
            }

            return(bone);
        }
예제 #2
0
 public static bool IsSemiRootBone([NotNull] this SwayBone bone)
 {
     return(bone.Parent == null);
 }