Example #1
0
        public static Rect ToRect(this string data)
        {
            var cody = new CfgDecoder(data);

            var rect = new Rect();

            foreach (var t in cody)
            {
                var d = cody.GetData();
                switch (t)
                {
                case "pos": rect.position = d.ToVector2(); break;

                case "size": rect.size = d.ToVector2(); break;
                }
            }
            return(rect);
        }
Example #2
0
        public static Vector2 ToVector2(this string data)
        {
            var cody = new CfgDecoder(data);

            var v2 = new Vector3();

            foreach (var t in cody)
            {
                var d = cody.GetData();
                switch (t)
                {
                case "x": v2.x = d.ToFloat(); break;

                case "y": v2.y = d.ToFloat(); break;
                }
            }
            return(v2);
        }
Example #3
0
        public static Vector3 ToVector3(this string data)
        {
            var cody = new CfgDecoder(data);

            var v3 = new Vector3();

            foreach (var tag in cody)
            {
                var d = cody.GetData();
                switch (tag)
                {
                case "x": v3.x = d.ToFloat(); break;

                case "y": v3.y = d.ToFloat(); break;

                case "z": v3.z = d.ToFloat(); break;
                }
            }
            return(v3);
        }
Example #4
0
        public Vector3 ToVector3()
        {
            var cody = new CfgDecoder(_value);

            var v3 = new Vector3();

            foreach (var t in cody)
            {
                var d = cody.GetData();
                switch (t)
                {
                case "x": v3.x = d.ToFloat(); break;

                case "y": v3.y = d.ToFloat(); break;

                case "z": v3.z = d.ToFloat(); break;
                }
            }
            return(v3);
        }
Example #5
0
        public T[] Decode_Array <T>(out T[] l) where T : class, ICfgCustom, new()
        {
            var cody = new CfgDecoder(this);

            l = null;

            var tmpList = new List <T>();

            var ind = 0;

            foreach (var tag in cody)
            {
                var d = cody.GetData();

                if (tag == "len")
                {
                    l = new T[d.ToInt(0)];
                }
                else
                {
                    var isNull = tag == CfgEncoder.NullTag;

                    var obj = isNull ? default : d.Decode <T>();

                              if (l != null)
                              {
                                  l[ind] = obj;
                              }
                              else
                              {
                                  tmpList.Add(obj);
                              }

                              ind++;
                }
            }

            return(l ?? tmpList.ToArray());
        }
Example #6
0
        public static bool TryDecode_IntoList_Elements <T>(this string data, List <T> val)
        {
            if (val == null)
            {
                return(false);
            }

            var cody = new CfgDecoder(data);

            var index = 0;

            foreach (var t in cody)
            {
                if (index >= val.Count)
                {
                    return(true);
                }

                cody.GetData().TryDecodeInto(val[index]);
                index++;
            }

            return(true);
        }
Example #7
0
        public static Vector4 ToVector4(this string data)
        {
            var cody = new CfgDecoder(data);

            var v4 = new Vector4();

            foreach (var t in cody)
            {
                var d = cody.GetData();
                switch (t)
                {
                case "x": v4.x = d.ToFloat(); break;

                case "y": v4.y = d.ToFloat(); break;

                case "z": v4.z = d.ToFloat(); break;

                case "w": v4.w = d.ToFloat(); break;

                default: Debug.Log("Unknown component: " + t); break;
                }
            }
            return(v4);
        }
Example #8
0
        public static Quaternion ToQuaternion(this string data)
        {
            var cody = new CfgDecoder(data);

            var q = new Quaternion();

            foreach (var t in cody)
            {
                var d = cody.GetData();
                switch (t)
                {
                case "x": q.x = d.ToFloat(); break;

                case "y": q.y = d.ToFloat(); break;

                case "z": q.z = d.ToFloat(); break;

                case "w": q.w = d.ToFloat(); break;

                default: Debug.Log("Unknown component: " + cody.GetType()); break;
                }
            }
            return(q);
        }
Example #9
0
 private static T DecodeData <T>(this CfgDecoder cody, List <Type> tps) where T : ICfg
 => Decode <T>(cody.currentTag, cody.GetData(), tps);
Example #10
0
 private static T DecodeData <T>(this CfgDecoder cody, List <Type> tps, ListMetaData ld) where T : ICfg
 => Decode <T>(cody.currentTag, cody.GetData(), tps, ld, cody.currentTagIndex);
Example #11
0
 private static T DecodeData <T>(this CfgDecoder cody, TaggedTypesCfg tps) where T : IGotClassTag
 => Decode <T>(cody.currentTag, cody.GetData(), tps);
Example #12
0
 private static T DecodeData <T>(this CfgDecoder cody, TaggedTypesCfg tps, ListMetaData ld) where T : IGotClassTag
 => Decode <T>(cody.currentTag, cody.GetData(), tps, ld, cody.currentTagIndex);