int[] ReadAnimation(byte[] bytes, int offset, int length)
{
Stream s = new MemoryStream(bytes, offset, length);
BinaryReader br = new BinaryReader(s);
ArrayList array = new ArrayList();
for (;;) {
byte code = br.ReadByte();
array.Add((int)code);
switch ((Animation)code) {
case Animation.PLAY:
case Animation.STOP:
case Animation.NEXTFRAME:
case Animation.PREVFRAME:
break;
case Animation.GOTOFRAME:
case Animation.GOTOLABEL:
case Animation.EVENT:
case Animation.CALL:
array.Add(br.ReadInt32());
break;
case Animation.SETTARGET:
{
int count = br.ReadInt32();
array.Add(count);
for (int i = 0; i < (int)count; ++i) {
int target = br.ReadInt32();
array.Add(target);
}
}
break;
case Animation.END:
return (int[])array.ToArray(typeof(int));
}
}
}