internal static XAnimationSet Read(XFileTokenReader tokenReader) { var animationSet = new XAnimationSet(); if (tokenReader.FileReader.GetNextToken() == XToken.Name) { animationSet.Name = tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); while (tokenReader.FileReader.GetNextToken() != XToken.ClosedBrace) { string identifier = tokenReader.ReadName(); switch (identifier) { case "Animation": { XAnimation animation = XAnimation.Read(tokenReader); animationSet.Animations.Add(animation); break; } default: throw new InvalidDataException(); } } tokenReader.ReadAssert(XToken.ClosedBrace); return(animationSet); }
private void ReadFile(IXFileReader fileReader) { var tokenReader = new XFileTokenReader(fileReader); var templateReader = new XFileTemplateReader(tokenReader); while (fileReader.GetNextToken() == XToken.Template) { Tuple <string, Guid> template = templateReader.ReadTemplate(); this.Templates.Add(template); } bool headerRead = false; bool animTicksPerSecondRead = false; while (fileReader.GetNextToken() == XToken.Name) { string identifier = tokenReader.ReadName(); switch (identifier) { case "Header": { if (headerRead) { throw new InvalidDataException(); } tokenReader.ReadAssert(XToken.OpenedBrace); int majorVersion = tokenReader.ReadIntegerFromList(); int minorVersion = tokenReader.ReadIntegerFromList(); this.FileVersion = new Version(majorVersion, minorVersion); this.FileFlags = tokenReader.ReadIntegerFromList(); tokenReader.ReadAssert(XToken.ClosedBrace); headerRead = true; break; } case "Material": { XMaterial material = XMaterial.Read(tokenReader); this.Materials.Add(material); break; } case "Mesh": { XMesh mesh = XMesh.Read(tokenReader); this.Meshes.Add(mesh); break; } case "Frame": { XFrame frame = XFrame.Read(tokenReader); this.Frames.Add(frame); break; } case "AnimationSet": { XAnimationSet animationSet = XAnimationSet.Read(tokenReader); this.AnimationSets.Add(animationSet); break; } case "AnimTicksPerSecond": { if (animTicksPerSecondRead) { throw new InvalidDataException(); } tokenReader.ReadAssert(XToken.OpenedBrace); this.AnimTicksPerSecond = tokenReader.ReadIntegerFromList(); tokenReader.ReadAssert(XToken.ClosedBrace); animTicksPerSecondRead = true; break; } default: throw new NotImplementedException(); } } }