Ejemplo n.º 1
0
        public static SpringSetting Deserialize_Settings_ITEM(ListTreeNode <JsonValue> parsed)
        {
            var value = new SpringSetting();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "stiffness")
                {
                    value.Stiffness = kv.Value.GetSingle();
                    continue;
                }

                if (key == "gravityPower")
                {
                    value.GravityPower = kv.Value.GetSingle();
                    continue;
                }

                if (key == "gravityDir")
                {
                    value.GravityDir = Deserialize_GravityDir(kv.Value);
                    continue;
                }

                if (key == "dragForce")
                {
                    value.DragForce = kv.Value.GetSingle();
                    continue;
                }
            }
            return(value);
        }
Ejemplo n.º 2
0
        public static void Serialize_Settings_ITEM(JsonFormatter f, SpringSetting value)
        {
            f.BeginMap();


            if (value.Stiffness.HasValue)
            {
                f.Key("stiffness");
                f.Value(value.Stiffness.GetValueOrDefault());
            }

            if (value.GravityPower.HasValue)
            {
                f.Key("gravityPower");
                f.Value(value.GravityPower.GetValueOrDefault());
            }

            if (value.GravityDir != null && value.GravityDir.Count() >= 3)
            {
                f.Key("gravityDir");
                Serialize_GravityDir(f, value.GravityDir);
            }

            if (value.DragForce.HasValue)
            {
                f.Key("dragForce");
                f.Value(value.DragForce.GetValueOrDefault());
            }

            f.EndMap();
        }