Esempio n. 1
0
        private void ReadField(SQEX.Luminous.Core.Object.BaseObject obj, Xmb2Element parentElement, uint hashedParentName, BaseObject objOffset)
        {
            if (objOffset != null)
            {
                obj = objOffset;
            }

            foreach (var element in parentElement.GetElements())
            {
                var name       = element.Name;
                var hashedName = Fnv1a.Fnv1a32(name, hashedParentName);
                var type       = obj.GetObjectType();
                if (type == null)
                {
                    continue;
                }

                var property = type.PropertyContainer.FindByName(name);
                if (property == null)
                {
                    continue;
                }

                this.ReadValue(obj, parentElement, element, property, hashedName, objOffset);
            }
        }
Esempio n. 2
0
        private void ReadValue(Luminous.Core.Object.BaseObject obj, Xmb2Element parentObject, Xmb2Element element, Property property, uint hashedName, BaseObject objOffset)
        {
            object value = null;

            switch (property.Type)
            {
            case Property.PrimitiveType.ClassField:
                this.ReadField(obj, element, Fnv1a.Fnv1a32(".", hashedName), obj.GetPropertyValue <BaseObject>(property));
                break;

            case Property.PrimitiveType.Int8:
            case Property.PrimitiveType.Int16:
            case Property.PrimitiveType.Int32:
            case Property.PrimitiveType.Int64:
            case Property.PrimitiveType.UInt8:
            case Property.PrimitiveType.UInt16:
            case Property.PrimitiveType.UInt32:
            case Property.PrimitiveType.UInt64:
            case Property.PrimitiveType.INVALID2:
            case Property.PrimitiveType.Bool:
            case Property.PrimitiveType.Float:
            case Property.PrimitiveType.Double:
            case Property.PrimitiveType.String:
            case Property.PrimitiveType.Fixid:
            case Property.PrimitiveType.Vector4:
            case Property.PrimitiveType.Color:
            case Property.PrimitiveType.Enum:
                value = this.ReadPrimitiveValue(element, property);
                break;

            case Property.PrimitiveType.Pointer:
                if (this.ResolvePointer(parentObject, element, out value))
                {
                    // TODO addPointerListReferedBySequenceIfMatchCondition
                }

                break;

            case Property.PrimitiveType.PointerArray:
            case Property.PrimitiveType.IntrusivePointerArray:
                // GOTCHA: We don't want to create a new List, because other objects can reference the list before it's instantiated
                value = obj.GetPropertyValue <IList>(property);
                this.ReadPointerArray(obj, element, value as IList);
                break;

            default:
                if (property.Type != Property.PrimitiveType.Array)
                {
                    throw new ArgumentException($"[EntityPackageXmlLoader]Unknown type {property.Type} for {property.Name}");
                }

                break;
            }

            if (value != null)
            {
                obj.SetPropertyValue(property, value);
            }
        }
Esempio n. 3
0
        private void ReadDynamicBaseObjectChildElement(BaseObject parentObject, BaseObject baseObject, Xmb2Element childElement)
        {
            foreach (var element in childElement.GetElements())
            {
                var name       = element.Name;
                var hashedName = Fnv1a.Fnv1a32(name, 2166136261); // ???
                var type       = baseObject.GetObjectType();
                if (type == null)
                {
                    continue;
                }

                var property = type.PropertyContainer.FindByName(name);
                if (property == null)
                {
                    continue;
                }

                this.ReadValue(baseObject, childElement, element, property, hashedName, baseObject);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Read the attribute element with a given name.
        /// </summary>
        /// <param name="name">The name of the attribute to get.</param>
        /// <returns>The parsed attribute.</returns>
        public Xmb2Variant GetAttributeByName(string name)
        {
            var nameHash = Fnv1a.Fnv1a32(name);

            return(this.GetAttributeByName(nameHash));
        }