public static CfgEncoder Encode <T>(this T[] arr) where T : ICfg { var cody = new CfgEncoder(); if (arr.IsNullOrEmpty()) { return(cody); } cody.Add("len", arr.Length); var types = typeof(T).TryGetDerivedClasses(); if (types != null && types.Count > 0) { foreach (var v in arr) { cody.Add(v, types); } } else { foreach (var v in arr) { if (!v.IsNullOrDestroyed_Obj()) { cody.Add(CfgDecoder.ListElementTag, v.Encode()); } else { cody.Add_String(CfgEncoder.NullTag, ""); } } } return(cody); }
public CfgEncoder Add <T>(string tag, List <T> lst) where T : ICfg, new() { var cody = new CfgEncoder(); if (lst == null) { return(this); } var indTypes = typeof(T).TryGetDerivedClasses(); if (indTypes != null) { foreach (var v in lst) { cody.Add(v, indTypes); } } else { foreach (var v in lst) { if (v != null) { cody.Add(CfgDecoder.ListElementTag, v.Encode()); } else { cody.Add_String(NullTag, ""); } } } return(Add(tag, cody)); }
public override CfgEncoder Encode() { var cody = new CfgEncoder() .Add("b", base.Encode) .Add("trgf", targetValue) .Add_Bool("rng", minMax); if (minMax) { cody.Add("min", min) .Add("max", max); } return(cody); }
public static CfgEncoder Encode(this Countless <Vector3> c) { var cody = new CfgEncoder(); if (c != null) { List <int> inds; List <Vector3> vals = c.GetAllObjs(out inds); for (int i = 0; i < inds.Count; i++) { cody.Add(inds[i].ToString(), vals[i]); } } return(cody); }
public static CfgEncoder Encode <T>(this Dictionary <string, T> dic) where T : ICfg { var sub = new CfgEncoder(); if (dic == null) { return(sub); } foreach (var e in dic) { sub.Add(e.Key, e.Value.Encode()); } return(sub); }
public static CfgEncoder Encode(this Dictionary <string, CfgData> dic) { var sub = new CfgEncoder(); if (dic == null) { return(sub); } foreach (var e in dic) { sub.Add(e.Key, e.Value); } return(sub); }
public CfgEncoder Add(string tag, Matrix4x4[] arr) { if (arr == null) { return(this); } var cody = new CfgEncoder() .Add("len", arr.Length); foreach (var v in arr) { cody.Add(CfgDecoder.ListElementTag, v.Encode()); } return(Add(tag, cody)); }
public static CfgEncoder Encode(this IEnumerable <UnrecognizedTagsList.UnrecognizedElement> lst) { var cody = new CfgEncoder(); foreach (var e in lst) { if (e.elements.Count == 0) { cody.Add_String(e.tag, e.data); } else { cody.Add(e.tag, e.elements.Encode()); } } return(cody); }
public CfgEncoder Add_Abstract <T>(string tag, List <T> lst) where T : IGotClassTag { if (lst.IsNullOrEmpty()) { return(this); } var cody = new CfgEncoder(); foreach (var v in lst) { if (v != null) { cody.Add(v.ClassTag, v); } else { cody.Add_String(NullTag, ""); } } return(Add(tag, cody)); }
public static CfgEncoder Encode(this Transform tf, bool local) { var cody = new CfgEncoder(); 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); }