Example #1
0
        public bool Read(Stream s, IEnumerable <D2oClass> classes)
        {
            var classId = s.ReadInt();

            ClassRef = classes.FirstOrDefault(x => x.Id == classId);
            if (ClassRef == null)
            {
                return(false);
            }

            foreach (var field in ClassRef.Fields)
            {
                if (field is ObjectDataField obj)
                {
                    Properties.Add(field.Name, obj.ReadValue(s, classes));
                }
                else if (field is VectorDataField list)
                {
                    Properties.Add(field.Name, list.ReadValue(s, classes));
                }
                else
                {
                    Properties.Add(field.Name, field.ReadValue(s));
                }
            }
            return(true);
        }
Example #2
0
        private bool readClasses(Stream s)
        {
            try
            {
                var count = s.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    var dataClass = new D2oClass();
                    dataClass.Read(s);
                    Classes.Add(dataClass);
                }

                return(true);
            }
            catch { return(false); }
        }