public UE3PropertyListInstanceReader(UnPackage package, BinaryReader reader, UnExport export, UnContainer owner) { _package = package; _reader = reader; _export = export; _owner = owner; }
private UnPropertyList ReadStructProperty(UnContainer owner, string name) { var export = owner.FindMemberExport(name); if (export == null) { return(null); } var declaration = (UnTypedClassProperty)export.ReadInstance(); var typeDeclaration = declaration.Type; UnExport scriptStruct = typeDeclaration.Resolve(); var structInstance = (UnScriptStruct)scriptStruct.ReadInstance(); if (structInstance.Native) { return(null); } var result = new UnPropertyList(null); ReadStructValues(scriptStruct, result); return(result); }
private object ReadSingleValue(UnContainer owner, string name, string type) { if (type == "FloatProperty") return _reader.ReadSingle(); if (type == "BoolProperty") return _reader.ReadInt32() != 0; if (type == "IntProperty") return _reader.ReadInt32(); if (type == "StrProperty") { var valueLength = _reader.ReadInt32(); object value; if (valueLength < 0) { var s = _reader.ReadBytes(-2 * valueLength); value = new string(Encoding.Unicode.GetChars(s)); } else { value = new string(_reader.ReadChars(valueLength)); } return ((string)value).Trim('\0'); } if (type == "NameProperty") { var valueNameIndex = _reader.ReadInt64(); return _package.Names[(int)valueNameIndex].Name; } if (type == "ByteProperty") { var export = owner.FindMemberExport(name); var declaration = (UnTypedClassProperty) export.ReadInstance(); if (declaration.Type == null) return _reader.ReadByte(); var valueNameIndex = _reader.ReadInt64(); if (valueNameIndex < 0 || valueNameIndex >= _package.Names.Count) return null; return _package.Names[(int)valueNameIndex].Name; } if (type == "ObjectProperty") { var export = owner.FindMemberExport(name); var index = _reader.ReadInt32(); if (index == 0) return "None"; var item = _package.ResolveClassItem(index); if (export.ClassName == "ClassProperty") { return "class'" + item.ObjectName + "'"; } return item.ClassName + "'" + item.ObjectName + "'"; } if (type == "ClassProperty") { var index = _reader.ReadInt32(); if (index == 0) return "None"; var item = _package.ResolveClassItem(index); return "class'" + item.ObjectName + "'"; } if (type == "ArrayProperty") { var export = owner.FindMemberExport(name); var prop = (UnArrayClassProperty) export.ReadInstance(); var propType = prop.Type.Resolve(); var count = _reader.ReadInt32(); var result = new UnPropertyArray(propType.ClassName); for(int i=0; i<count; i++) { var value = ReadSingleValue(owner, name, propType.ClassName); if (value == null) return null; result.Add(value); } return result; } if (type == "DelegateProperty") { var v1 = _reader.ReadInt32(); var nameIndex = _reader.ReadInt64(); return _package.Names[(int) nameIndex].Name; } return null; }
private UnPropertyList ReadStructProperty(UnContainer owner, string name) { var export = owner.FindMemberExport(name); if (export == null) return null; var declaration = (UnTypedClassProperty) export.ReadInstance(); var typeDeclaration = declaration.Type; UnExport scriptStruct = typeDeclaration.Resolve(); var structInstance = (UnScriptStruct)scriptStruct.ReadInstance(); if (structInstance.Native) return null; var result = new UnPropertyList(null); ReadStructValues(scriptStruct, result); return result; }
private object ReadSingleValue(UnContainer owner, string name, string type) { if (type == "FloatProperty") { return(_reader.ReadSingle()); } if (type == "BoolProperty") { return(_reader.ReadInt32() != 0); } if (type == "IntProperty") { return(_reader.ReadInt32()); } if (type == "StrProperty") { var valueLength = _reader.ReadInt32(); object value; if (valueLength < 0) { var s = _reader.ReadBytes(-2 * valueLength); value = new string(Encoding.Unicode.GetChars(s)); } else { value = new string(_reader.ReadChars(valueLength)); } return(((string)value).Trim('\0')); } if (type == "NameProperty") { var valueNameIndex = _reader.ReadInt64(); return(_package.Names[(int)valueNameIndex].Name); } if (type == "ByteProperty") { var export = owner.FindMemberExport(name); var declaration = (UnTypedClassProperty)export.ReadInstance(); if (declaration.Type == null) { return(_reader.ReadByte()); } var valueNameIndex = _reader.ReadInt64(); if (valueNameIndex < 0 || valueNameIndex >= _package.Names.Count) { return(null); } return(_package.Names[(int)valueNameIndex].Name); } if (type == "ObjectProperty") { var export = owner.FindMemberExport(name); var index = _reader.ReadInt32(); if (index == 0) { return("None"); } var item = _package.ResolveClassItem(index); if (export.ClassName == "ClassProperty") { return("class'" + item.ObjectName + "'"); } return(item.ClassName + "'" + item.ObjectName + "'"); } if (type == "ClassProperty") { var index = _reader.ReadInt32(); if (index == 0) { return("None"); } var item = _package.ResolveClassItem(index); return("class'" + item.ObjectName + "'"); } if (type == "ArrayProperty") { var export = owner.FindMemberExport(name); var prop = (UnArrayClassProperty)export.ReadInstance(); var propType = prop.Type.Resolve(); var count = _reader.ReadInt32(); var result = new UnPropertyArray(propType.ClassName); for (int i = 0; i < count; i++) { var value = ReadSingleValue(owner, name, propType.ClassName); if (value == null) { return(null); } result.Add(value); } return(result); } if (type == "DelegateProperty") { var v1 = _reader.ReadInt32(); var nameIndex = _reader.ReadInt64(); return(_package.Names[(int)nameIndex].Name); } return(null); }