public static Optional <TextureXImage> From(ByteReader reader) { try { UpperString name = reader.StringWithoutNulls(8); TextureXFlags flags = (TextureXFlags)reader.UShort(); Vector2 scale = new Vector2(reader.Byte(), reader.Byte()); Dimension dimension = new Dimension(reader.Short(), reader.Short()); int columnDirectory = reader.Int(); int patchCount = reader.Short(); List <TextureXPatch> patches = Range(patchCount).Map(i => { Vec2I offset = new Vec2I(reader.Short(), reader.Short()); short patchIndex = reader.Short(); short stepDirection = reader.Short(); short colormap = reader.Short(); return(new TextureXPatch(offset, patchIndex, stepDirection, colormap)); }).ToList(); return(new TextureXImage(name, flags, scale, dimension, columnDirectory, patches)); } catch { return(Empty); } }
private TextureXImage(UpperString name, TextureXFlags flags, Vector2 scale, Dimension dimension, int columnDirectory, IReadOnlyList <TextureXPatch> patches) { Name = name; Flags = flags; Scale = scale; Dimension = dimension; ColumnDirectory = columnDirectory; Patches = patches; }