Пример #1
0
        /// <summary>
        /// Get the canonicalized source path of an element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The canonicalized source path.</returns>
        private string GetDataRelativePath(Xmb2Element element, EntityPackage parentPackage)
        {
            var sourcePathElement = element.GetElementByName("sourcePath_");

            if (sourcePathElement == null)
            {
                return(null);
            }

            var isSharedElement = element.GetElementByName("isShared_");

            if (isSharedElement?.GetBoolValue() == true)
            {
                return(null);
            }

            var sourcePath = sourcePathElement.GetTextValue();

            if (sourcePath == null)
            {
                return(null);
            }

            //return sourcePath;

            // TODO Properly implement and debug
            if (parentPackage != null)
            {
                return(SQEX.Luminous.Core.IO.Path.ResolveRelativePath(parentPackage.sourcePath_, sourcePath));
            }

            return(SQEX.Luminous.Core.IO.Path.ResolveRelativePath(this.SourcePath, sourcePath));
        }
        new public static void SetupObjectType()
        {
            if (ObjectType != null)
            {
                return;
            }

            var dummy      = new EntityPackage();
            var properties = dummy.GetFieldProperties();

            ObjectType = new ObjectType("SQEX.Ebony.Framework.Entity.EntityPackage", 0, SQEX.Ebony.Framework.Entity.EntityPackage.ObjectType, Construct, properties, 8, 592);
        }
Пример #3
0
        private EntityPackage CreatePackage()
        {
            EntityPackage package = null;

            if (this.CurrentDocument == null)
            {
                return(null);
            }

            this.LoadStatus = LOAD_STATUS.LOAD_ST_LOAD;

            var rootElementRelativeOffset = BitConverter.ToInt32(this.CurrentDocument, RootElementOffsetOffset);
            var rootElement    = Xmb2Element.FromByteArray(this.CurrentDocument, RootElementOffsetOffset + rootElementRelativeOffset);
            var objectsElement = rootElement.GetElementByName("objects");

            if (objectsElement == null || this.LoadedObjectCount >= this.ObjectElementList.Count)
            {
                this.LoadStatus = LOAD_STATUS.LOAD_ST_CREATE;
                // TODO goto LABEL_28;
            }

            // Instantiate each object.
            for (int i = (int)this.LoadedObjectCount; i < this.ObjectElementList.Count; i++)
            {
                var element = this.ObjectElementList[i];

                var objectIndex          = 0;
                var objectIndexAttribute = element.GetAttributeByName("objectIndex");
                if (objectIndexAttribute != null)
                {
                    objectIndex = objectIndexAttribute.ToInt();
                }

                this.ObjectIndexMap.Add(objectIndex, i);
                if (!this.ReadObject(element))
                {
                    break;
                }
            }

            // Read each object's fields.
            for (int i = 0; i < this.ObjectElementList.Count; i++)
            {
                var element = this.ObjectElementList[i];
                var obj     = this.Objects[i];
                if (this.Objects[i] is EntityPackage)
                {
                    package             = obj as EntityPackage;
                    package.sourcePath_ = this.GetDataRelativePath(element, package);
                }

                this.ReadField(obj, element, 2166136261, null);  // ""

                if (!(this.Objects[i] is EntityPackage))
                {
                    var ownerIndexAttribute = element.GetAttributeByName("ownerIndex");
                    var ownerIndex          = 0;
                    if (ownerIndexAttribute != null)
                    {
                        ownerIndex = ownerIndexAttribute.ToInt();
                    }
                }

                string name          = null;
                var    nameAttribute = element.GetAttributeByName("name");
                if (nameAttribute != null)
                {
                    name = nameAttribute.GetTextValue();
                    if (this.Objects[i] is EntityPackage)
                    {
                        package.simpleName_ = name;
                    }
                }

                string objPath       = null;
                var    pathAttribute = element.GetAttributeByName("path");
                if (pathAttribute != null)
                {
                    objPath = pathAttribute.GetTextValue();
                }

                package.AddLoadedObject(obj, name, objPath);
            }

            this.LoadStatus = LOAD_STATUS.LOAD_ST_CREATE;
            return(package);
        }