private UEBoolProperty ReadUEBoolProperty(JObject o) { var value = new UEBoolProperty(); value.Value = bool.Parse(o["Value"].ToString()); return(value); }
public async Task <List <int> > GetMissingBitsCount(UEBoolProperty other) { // If there is no previous bitfield member, just calculate the missing bits. if (!other.IsValid()) { return new List <int> { Utils.GetBitPosition(await GetByteMask()), -1 } } ; var byteMask = GetByteMask(); var offset = GetOffset(); var otherByteMask = other.GetByteMask(); var otherOffset = other.GetOffset(); // If both bitfield member belong to the same byte, calculate the bit position difference. if (await offset == await otherOffset) { return new List <int> { Utils.GetBitPosition(await byteMask) - Utils.GetBitPosition(await otherByteMask) - 1, -1 } } ; // If they have different offsets, we need two distances // |00001000|00100000| // 1. ^---^ // 2. ^--^ return(new List <int> { /* Number of bits on byte is => */ 8 - Utils.GetBitPosition(await otherByteMask) - 1, Utils.GetBitPosition(await byteMask) }); }
internal static UEProperty Deserialize(string name, string type, long valueLength, BinaryReader reader) { UEProperty result; var itemOffset = reader.BaseStream.Position; switch (type) { case "BoolProperty": result = new UEBoolProperty(reader, valueLength); break; case "IntProperty": result = new UEIntProperty(reader, valueLength); break; case "FloatProperty": result = new UEFloatProperty(reader, valueLength); break; case "NameProperty": case "StrProperty": case "SoftObjectProperty": case "ObjectProperty": result = new UEStringProperty(reader, valueLength); break; case "TextProperty": result = new UETextProperty(reader, valueLength); break; case "EnumProperty": result = new UEEnumProperty(reader, valueLength); break; case "StructProperty": result = UEStructProperty.Read(reader, valueLength); break; case "ArrayProperty": result = new UEArrayProperty(reader, valueLength); break; case "MapProperty": result = new UEMapProperty(reader, valueLength); break; case "ByteProperty": result = UEByteProperty.Read(reader, valueLength); break; default: throw new FormatException($"Offset: 0x{itemOffset:x8}. Unknown value type '{type}' of item '{name}'"); } result.Name = name; result.Type = type; result.ValueLength = valueLength; return(result); }
internal static UEProperty Deserialize(string name, string type, long valueLength, BinaryReader reader) { UEProperty result; var itemOffset = reader.BaseStream.Position; switch (type) { case "BoolProperty": result = new UEBoolProperty(reader, valueLength); break; case "IntPropertyArray": result = new UEIntProperty(reader, valueLength, false); break; case "IntProperty": result = new UEIntProperty(reader, valueLength, true); break; case "UInt32Property": result = new UEInt32Property(reader, valueLength); break; case "FloatProperty": result = new UEFloatProperty(reader, valueLength); break; case "NameProperty": case "StrProperty": result = new UEStringProperty(reader, valueLength); break; case "TextProperty": result = new UETextProperty(reader, valueLength); break; case "EnumProperty": result = new UEEnumProperty(reader, valueLength); break; case "StructProperty": result = UEStructProperty.Read(reader, valueLength); result.Address = $"0x{ reader.BaseStream.Position - 1:x8}"; break; case "ArrayProperty": result = new UEArrayProperty(reader, valueLength); break; case "MapProperty": result = new UEMapProperty(reader, valueLength); break; case "ByteProperty": result = UEByteProperty.Read(reader, valueLength); result.Address = $"0x{ reader.BaseStream.Position - 1:x8}"; break; case "SetProperty": result = new UESetProperty(reader, valueLength); break; case "SoftObjectProperty": result = new UEStringProperty(reader, valueLength); break; case "ObjectProperty": result = new UEStringProperty(reader, valueLength); break; default: result = new UEStringProperty(reader, valueLength); break; } result.Name = name; result.Type = type; Debug.WriteLine(String.Format("{0} ({1}) {2}", name, type, $"0x{ reader.BaseStream.Position - 1:x8}")); return(result); }