public void Write(FileWriter writer, LayoutHeader header) { Console.WriteLine(ToJson()); long flagPos = 0; writer.WriteString(Name, 0x1C); if (header.VersionMajor >= 8) { flagPos = writer.Position; writer.Write(flags); writer.Write(unknown); writer.Write(BlackColor); writer.Write(WhiteColor); } else { writer.Write(BlackColor); writer.Write(WhiteColor); flagPos = writer.Position; writer.Write(flags); } if (TextureMaps?.Length > 0 && TexCoordGens?.Length == 0) { TexCoordGens = new BxlytTexCoordGen[TextureMaps.Length]; for (int i = 0; i < TextureMaps?.Length; i++) { TexCoordGens[i] = new TexCoordGen(); } } flags = 0; for (int i = 0; i < TextureMaps.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 30); ((TextureRef)TextureMaps[i]).Write(writer); } for (int i = 0; i < TextureTransforms.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 28); ((BxlytTextureTransform)TextureTransforms[i]).Write(writer); } for (int i = 0; i < TexCoordGens.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 26); ((TexCoordGen)TexCoordGens[i]).Write(writer, (BxlytHeader)header); } for (int i = 0; i < TevStages.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 24); ((TevStage)TevStages[i]).Write(writer); } if (AlphaCompare != null && EnableAlphaCompare) { flags += Bit.BitInsert(1, 1, 1, 22); AlphaCompare.Write(writer); } if (BlendMode != null && EnableBlend) { flags += Bit.BitInsert(1, 1, 2, 20); BlendMode.Write(writer); } if (BlendModeLogic != null && EnableBlendLogic) { flags += Bit.BitInsert(1, 1, 2, 18); BlendModeLogic.Write(writer); } if (IndParameter != null && EnableIndParams) { flags += Bit.BitInsert(1, 1, 1, 17); IndParameter.Write(writer); } for (int i = 0; i < ProjTexGenParams.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 15); ProjTexGenParams[i].Write(writer); } if (FontShadowParameter != null && EnableFontShadowParams) { flags += Bit.BitInsert(1, 1, 1, 14); FontShadowParameter.Write(writer); } if (AlphaInterpolation) { flags += Bit.BitInsert(1, 1, 1, 13); } using (writer.TemporarySeek(flagPos, SeekOrigin.Begin)) { writer.Write(flags); } }
public void Write(FileWriter writer, LayoutHeader header) { writer.WriteString(Name, 20); writer.Write(BlackColor); writer.Write(WhiteColor); writer.Write(TevConstantColors); long flagPos = writer.Position; writer.Write(flags); flags = 0; for (int i = 0; i < TextureMaps?.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 30); ((TextureRef)TextureMaps[i]).Write(writer); } for (int i = 0; i < TextureTransforms?.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 28); ((BxlytTextureTransform)TextureTransforms[i]).Write(writer); } for (int i = 0; i < TexCoordGens?.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 26); ((TexCoordGen)TexCoordGens[i]).Write(writer); } for (int i = 0; i < TevStages?.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 24); ((TevStage)TevStages[i]).Write(writer); } if (AlphaCompare != null && EnableAlphaCompare) { flags += Bit.BitInsert(1, 1, 1, 22); AlphaCompare.Write(writer); } if (BlendMode != null && EnableBlend) { flags += Bit.BitInsert(1, 1, 2, 20); BlendMode.Write(writer); } if (BlendModeLogic != null && EnableBlendLogic) { flags += Bit.BitInsert(1, 1, 2, 18); BlendModeLogic.Write(writer); } if (IndParameter != null && EnableIndParams) { flags += Bit.BitInsert(1, 1, 1, 17); IndParameter.Write(writer); } for (int i = 0; i < ProjTexGenParams.Length; i++) { flags += Bit.BitInsert(1, 1, 2, 15); ProjTexGenParams[i].Write(writer); } if (FontShadowParameter != null && EnableFontShadowParams) { flags += Bit.BitInsert(1, 1, 1, 14); FontShadowParameter.Write(writer); } if (AlphaInterpolation) { flags += Bit.BitInsert(1, 1, 1, 13); } using (writer.TemporarySeek(flagPos, System.IO.SeekOrigin.Begin)) { writer.Write(flags); } }