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); }
public StdEncoder GetAll() { var cody = new StdEncoder(); for (int i = 0; i < tags.Count; i++) { cody.Add_String(tags[i], datas[i]); } return(cody); }
public override StdEncoder Encode() { var cody = new StdEncoder(); if (tags != null) { foreach (var t in tags) { cody.Add_String(t.tag, t.data); } } return(cody); }
public StdEncoder Add_IfNotEmpty(string tag, Dictionary <int, string> dic) { if (dic.Count > 0) { var sub = new StdEncoder(); foreach (var e in dic) { sub.Add_String(e.Key.ToString(), e.Value); } Add(tag, sub); } return(this); }
public StdEncoder Add(string tag, List <string> lst) { if (lst != null) { StdEncoder cody = new StdEncoder(); foreach (var s in lst) { cody.Add_String("e", s); } Add(tag, cody); } return(this); }