public override byte[] Rebuild() { FileOutput f = new FileOutput(); f.Endian = Endianness.Big; f.writeHex("4C494748"); //LIGH f.writeInt(version); f.writeInt(frameCount); if (version == 5) { f.writeInt(frameDuration); } //Offsets int padding = 0; while ((((frameCount * 3) + padding) % 4) != 0) //All offsets must be multiples of 4 or the game won't use the file properly { padding++; } int[] offsets = new int[6]; int currOff = 0x24; if (version == 4) { currOff = 0x24; } else if (version == 5) { currOff = 0x28; } for (int i = 0; i < 5; i++) { offsets[i + 1] = (rgbProperties[i].enabled) ? currOff : 0x0; if (rgbProperties[i].enabled) { currOff += (frameCount * 3) + padding; } } offsets[0] = currOff; for (int i = 0; i < 6; i++) { f.writeInt(offsets[i]); } //RGB properties for (int i = 0; i < 5; i++) { for (int j = 0; j < frameCount; j++) { for (int k = 0; k < 3; k++) { f.writeByte(rgbProperties[i].frames[j][k]); } } for (int j = 0; j < padding; j++) { f.writeByte(0); } } //Light data for (int i = 0; i < frameCount; i++) { for (int j = 0; j < 17; j++) { for (int k = 0; k < 4; k++) { f.writeInt((int)lightFrames[i].lightSets[j].lights[k].enabled); for (int l = 0; l < 3; l++) { f.writeFloat(lightFrames[i].lightSets[j].lights[k].angle[l]); } f.writeFloat(lightFrames[i].lightSets[j].lights[k].colorHue); f.writeFloat(lightFrames[i].lightSets[j].lights[k].colorSat); f.writeFloat(lightFrames[i].lightSets[j].lights[k].colorVal); } f.writeByte(lightFrames[i].lightSets[j].fog.unknown); for (int k = 0; k < 3; k++) { f.writeByte(lightFrames[i].lightSets[j].fog.color[k]); } } f.writeByte(lightFrames[i].effect.unknown); for (int j = 0; j < 3; j++) { f.writeByte(lightFrames[i].effect.color[j]); } for (int j = 0; j < 3; j++) { f.writeFloat(lightFrames[i].effect.position[j]); } } return(f.getBytes()); }