internal static PexObjectProperty Create(PexParseMeta parse) { var ret = new PexObjectProperty(); ret.Name = parse.ReadString(); ret.TypeName = parse.ReadString(); ret.DocString = parse.ReadString(); ret.RawUserFlags = parse.Reader.ReadUInt32(); var flags = parse.Reader.ReadUInt8(); ret.Flags = (PropertyFlags)flags; if ((flags & 4) != 0) { ret.AutoVarName = parse.ReadString(); } if ((flags & 5) == 1) { ret.ReadHandler = PexObjectFunction.Create(parse); } if ((flags & 6) == 2) { ret.WriteHandler = PexObjectFunction.Create(parse); } return(ret); }
internal static PexObject Create(PexParseMeta parse) { var ret = new PexObject(); ret.Name = parse.ReadString(); /* * This is the size of the entire object in bytes not some count variable for a loop. This also includes * the size of itself thus the - sizeof(uint) */ var size = parse.Reader.ReadUInt32() - sizeof(uint); var currentPos = parse.Reader.Position; ret.ParentClassName = parse.ReadString(); ret.DocString = parse.ReadString(); if (parse.Category == GameCategory.Fallout4) { ret.IsConst = parse.Reader.ReadBoolean(); } ret.RawUserFlags = parse.Reader.ReadUInt32(); ret.AutoStateName = parse.ReadString(); if (parse.Category == GameCategory.Fallout4) { var infoCount = parse.Reader.ReadUInt16(); for (var i = 0; i < infoCount; i++) { var structInfo = PexObjectStructInfo.Create(parse); ret.StructInfos.Add(structInfo); } } var variables = parse.Reader.ReadUInt16(); for (var i = 0; i < variables; i++) { var variable = PexObjectVariable.Create(parse); ret.Variables.Add(variable); } var properties = parse.Reader.ReadUInt16(); for (var i = 0; i < properties; i++) { var property = PexObjectProperty.Create(parse); ret.Properties.Add(property); } var states = parse.Reader.ReadUInt16(); for (var i = 0; i < states; i++) { var state = PexObjectState.Create(parse); ret.States.Add(state); } var newPos = parse.Reader.Position; if (newPos != currentPos + size) { throw new InvalidDataException("Current position in Stream does not match expected position: " + $"Current: {newPos} Expected: {currentPos + size}"); } return(ret); }