Пример #1
0
        public static StdEncoder Encode <T>(this List <T> val) where T : ISTD
        {
            StdEncoder cody = new StdEncoder();

            // int debugCount = 0;

            if (val != null)
            {
                var types = typeof(T).TryGetDerrivedClasses();

                if (types != null && types.Count > 0)
                {
                    foreach (var v in val)
                    {
                        if (v != null)
                        {
                            int typeIndex = types.IndexOf(v.GetType());
                            if (typeIndex != -1)
                            {
                                cody.Add(typeIndex.ToString(), v.Encode());
                            }
#if UNITY_EDITOR
                            else
                            {
                                cody.Add("e", v.Encode());
#if PEGI
                                Debug.Log("Type not listed: " + v.GetType() + " in " + typeof(T).ToPEGIstring());
#endif
                            }
#endif
                        }
                        else
                        {
                            cody.Add_String(StdEncoder.nullTag, "");
                        }
                    }
                }
                else
                {
                    foreach (var v in val)
                    {
                        //debugCount++;
                        if (v != null)
                        {
                            cody.Add("e", v.Encode());
                        }
                        else
                        {
                            cody.Add_String(StdEncoder.nullTag, "");
                        }
                    }
                }

                //  Debug.Log("Encoded "+ debugCount + " points");
            }
            return(cody);
        }
Пример #2
0
        public StdEncoder Add(string tag, List <uint> val)
        {
            StdEncoder cody = new StdEncoder();

            foreach (uint i in val)
            {
                cody.Add("e", i);
            }
            Add(tag, cody);

            return(this);
        }
Пример #3
0
        public static StdEncoder TryEncode <T>(this List <T> val)
        {
            StdEncoder cody = new StdEncoder();

            if (val != null)
            {
                for (int i = 0; i < val.Count; i++)
                {
                    var v = val[i];
                    if (v != null)
                    {
                        var std = v as ISTD;
                        if (std != null)
                        {
                            cody.Add(i.ToString(), std.Encode());
                        }
                    }
                }
            }
            return(cody);
        }
Пример #4
0
        public static StdEncoder Encode(this Transform tf, bool local)
        {
            var cody = new StdEncoder();

            cody.Add_Bool("loc", local);

            if (local)
            {
                cody.Add("pos", tf.localPosition);
                cody.Add("size", tf.localScale);
                cody.Add("rot", tf.localRotation);
            }
            else
            {
                cody.Add("pos", tf.position);
                cody.Add("size", tf.localScale);
                cody.Add("rot", tf.rotation);
            }

            return(cody);
        }