示例#1
0
 public static void SerializeTaggedProperties(
     IUnrealSerializer serializer,
     SerializeProperty serializeProperty,
     Dictionary <PropertyTag, object> unknownProperties)
 {
     SerializeTaggedProperties(serializer, serializeProperty, unknownProperties, true);
 }
 public override void Serialize(IUnrealSerializer serializer)
 {
     base.Serialize(serializer);
     serializer.Serialize(ref this._SuperStruct);
     serializer.Serialize(ref this._Children);
     this.SerializeScript(serializer);
 }
        public void Serialize(IUnrealSerializer serializer)
        {
            serializer.Serialize(ref this.Name);

            if (this.Name == "None")
            {
                return;
            }

            serializer.Serialize(ref this.Type);
            serializer.Serialize(ref this.Size);
            serializer.Serialize(ref this.ArrayIndex);

            if (this.Type == "StructProperty")
            {
                serializer.Serialize(ref this.StructName);
                serializer.Serialize(ref this.StructGuid);
            }
            else if (this.Type == "BoolProperty")
            {
                serializer.Serialize(ref this.BoolValue);
            }
            else if (this.Type == "ByteProperty" || this.Type == "EnumProperty")
            {
                serializer.Serialize(ref this.EnumName);
            }
            else if (this.Type == "ArrayProperty")
            {
                serializer.Serialize(ref this.InnerType);
            }
            else if (this.Type == "SetProperty")
            {
                serializer.Serialize(ref this.InnerType);
            }
            else if (this.Type == "MapProperty")
            {
                serializer.Serialize(ref this.InnerType);
                serializer.Serialize(ref this.ValueType);
            }

            if (serializer.Mode == UnrealSerializationMode.Loading)
            {
                byte hasPropertyGuid = 0;
                serializer.Serialize(ref hasPropertyGuid);
                if (hasPropertyGuid == 0)
                {
                    this.PropertyGuid = null;
                }
                else
                {
                    Guid propertyGuid = Guid.Empty;
                    serializer.Serialize(ref propertyGuid);
                    this.PropertyGuid = propertyGuid;
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#4
0
        public void Serialize(IUnrealSerializer serializer)
        {
            if (serializer.Mode == UnrealSerializationMode.Loading)
            {
                int count = 0;
                serializer.Serialize(ref count);

                var innerTag = new PropertyTag();
                serializer.Serialize(ref innerTag);

                var startPosition = serializer.Position;

                for (int i = 0; i < count; i++)
                {
                    var item = new TType();
                    serializer.Serialize(ref item);
                    this.Items.Add(item);
                }

                if (startPosition + innerTag.Size != serializer.Position)
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#5
0
        public void Serialize(IUnrealSerializer serializer)
        {
            serializer.Serialize(ref this.Flags);
            serializer.Serialize(ref this.HistoryType);

            switch (this.HistoryType)
            {
            case 255:
            {
                break;
            }

            case 0:     // Base
            {
                serializer.Serialize(ref this.Namespace);
                serializer.Serialize(ref this.Key);
                serializer.Serialize(ref this.SourceString);
                break;
            }

            default:
            {
                throw new NotImplementedException();
            }
            }
        }
        public void SerializeTaggedProperties(IUnrealSerializer serializer)
        {
            if (serializer.Mode == UnrealSerializationMode.Loading)
            {
                this.UnknownProperties.Clear();
            }

            PropertyBagHelper.SerializeTaggedProperties(serializer, this.SerializeProperty, this.UnknownProperties);
        }
 public static void Serialize(this IUnrealSerializer serializer, ref PropertyTag tag, ref bool value)
 {
     if (serializer.Mode == UnrealSerializationMode.Loading)
     {
         value = tag.BoolValue != 0;
     }
     else
     {
         throw new NotImplementedException();
     }
 }
示例#8
0
 /// <summary>
 /// Reads specified package.
 /// </summary>
 /// <param name="FilePath">Absolute path to a package.</param>
 /// <param name="szr">Serializer class for a desired version of package.</param>
 public L2Package(string FilePath, IUnrealSerializer szr = null)
 {
     Path   = FilePath;
     Reader = new PackageReader();
     Reader.Read(Path);
     Header      = new Header(Reader.Bytes);
     NameTable   = new NameTable(Header, Reader.Bytes);
     ImportTable = new ImportTable(Header, Reader.Bytes);
     ExportTable = new ExportTable(Header, Reader.Bytes);
     Serializer  = szr;
 }
示例#9
0
        public static void SerializeTaggedProperties(
            IUnrealSerializer serializer,
            SerializeProperty serializeProperty,
            Dictionary <PropertyTag, object> unknownProperties,
            bool safe)
        {
            if (serializer.Mode != UnrealSerializationMode.Loading)
            {
                throw new InvalidOperationException();
            }

            while (true)
            {
                var tag = new PropertyTag();
                serializer.Serialize(ref tag);

                if (tag.Name == "None")
                {
                    break;
                }

                if (safe == false)
                {
                    if (serializeProperty == null || serializeProperty(serializer, ref tag) == false)
                    {
                        var bytes = new byte[tag.Size];
                        serializer.Serialize(bytes, 0, bytes.Length);
                        unknownProperties.Add(tag, bytes);
                    }
                }
                else
                {
                    var bytes = new byte[tag.Size];
                    serializer.Serialize(bytes, 0, bytes.Length);

                    if (serializeProperty == null)
                    {
                        unknownProperties.Add(tag, bytes);
                    }
                    else
                    {
                        using (var temp = new MemoryStream(bytes, false))
                        {
                            var safeSerializer = serializer.New(temp);
                            if (serializeProperty(safeSerializer, ref tag) == false)
                            {
                                unknownProperties.Add(tag, bytes);
                            }
                        }
                    }
                }
            }
        }
        protected virtual void SerializeScript(IUnrealSerializer serializer)
        {
            if (serializer.Mode == UnrealSerializationMode.Loading)
            {
                int bytecodeBufferSize = 0;
                serializer.Serialize(ref bytecodeBufferSize);
                int serializedScriptSize = 0;
                serializer.Serialize(ref serializedScriptSize);

                var serializedScriptBytes = new byte[serializedScriptSize];
                serializer.Serialize(serializedScriptBytes, 0, serializedScriptBytes.Length);

                this._BytecodeBufferSize    = bytecodeBufferSize;
                this._SerializedScriptBytes = serializedScriptBytes;
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#11
0
        public override void Serialize(IUnrealSerializer serializer)
        {
            base.Serialize(serializer);

            if (serializer.Mode == UnrealSerializationMode.Loading)
            {
                bool hasGuid = false;
                serializer.Serialize(ref hasGuid);
                if (hasGuid == false)
                {
                    this.ObjectGuid = null;
                }
                else
                {
                    Guid guid = Guid.Empty;
                    serializer.Serialize(ref guid);
                    this.ObjectGuid = guid;
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
示例#12
0
        public override void Serialize(IUnrealSerializer serializer)
        {
            base.Serialize(serializer);

            if (serializer.Mode == UnrealSerializationMode.Loading)
            {
                uint rawFunctionFlags = 0;
                serializer.Serialize(ref rawFunctionFlags);
                this._FunctionFlags = (FunctionFlags)rawFunctionFlags;
            }
            else if (serializer.Mode == UnrealSerializationMode.Saving)
            {
                var rawFunctionFlags = (uint)this._FunctionFlags;
                serializer.Serialize(ref rawFunctionFlags);
            }

            if ((this._FunctionFlags & FunctionFlags.Net) != 0)
            {
                serializer.Serialize(ref this._RepOffset);
            }

            serializer.Serialize(ref this._EventGraphFunction);
            serializer.Serialize(ref this._EventGraphCallOffset);
        }
 public void Serialize(IUnrealSerializer serializer)
 {
     serializer.Serialize(ref this.Id);
     serializer.Serialize(ref this.Index);
     this.Value = serializer.LookupName(this);
 }
示例#14
0
 internal L2PackageEnumerator(IExportTable iet, IUnrealSerializer szr)
 {
     et        = iet;
     Cursor    = -1;
     Serilizer = szr;
 }
 protected virtual bool SerializeProperty(IUnrealSerializer serializer, ref PropertyTag tag)
 {
     return(false);
 }
 public virtual void Serialize(IUnrealSerializer serializer)
 {
     this.SerializeTaggedProperties(serializer);
 }