public static FxVfxNode Read(BinaryReader reader, FxVfxNodeDefinition definition, StringType stringType) { var node = new FxVfxNode { definition = definition }; foreach (var property in definition.properties) { var values = new List <object>(); node.properties.Add(property.name, values); var arraySize = reader.ReadByte(); if (Program.IsVerbose) { Console.WriteLine($"Reading {property.name} ({arraySize}) at {reader.BaseStream.Position - 1}"); } for (var i = 0; i < arraySize; i++) { values.Add(ReadValue(reader, property.type, stringType)); } } return(node); }
private bool TryReadNode(BinaryReader reader, int index, IDictionary <ulong, FxVfxNodeDefinition> definitions) { var hash = reader.ReadUInt64(); if (!definitions.ContainsKey(hash)) { Console.WriteLine("---"); Console.WriteLine($"[{this.filename}] Unsupported node type {hash} encountered at offset {reader.BaseStream.Position - 8}"); return(false); } var definition = definitions[hash]; if (Program.IsVerbose) { Console.WriteLine("---"); Console.WriteLine($"Reading node #{index} ({definition.name}) at {reader.BaseStream.Position - 8}"); Console.WriteLine("---"); } var node = FxVfxNode.Read(reader, definition, this.GetStringType()); if (Program.IsVerbose) { Console.WriteLine($"Finished {definition.name} at {reader.BaseStream.Position}"); } nodes.Add(node); return(true); }
public bool ReadXml(XmlReader reader) { reader.Read(); reader.ReadToFollowing("vfx"); reader.MoveToAttribute("version"); var version = reader.Value; if (version == "GZ") { this.version = Version.Gz; } else if (version == "TPP") { this.version = Version.Tpp; } else { Console.WriteLine("No valid version specified. Add a version attribute to the <vfx> node with a value of GZ or TPP."); return(false); } reader.ReadStartElement("vfx"); reader.ReadStartElement("nodes"); while (reader.NodeType == XmlNodeType.Element) { if (reader.LocalName == "edges") { break; } var type = reader.GetAttribute("class"); var typeHash = Program.HashString(type); if (!this.Definitions.ContainsKey(typeHash)) { throw new FormatException($"Unrecognized node type {type}"); } var definition = this.Definitions[typeHash]; var node = FxVfxNode.FromTemplate(definition); node.ReadXml(reader); this.nodes.Add(node); } reader.ReadEndElement(); reader.ReadStartElement("edges"); while (reader.NodeType == XmlNodeType.Element) { var edge = new FxModuleEdge(); edge.ReadXml(reader); this.edges.Add(edge); } return(true); }
public static FxVfxNode FromTemplate(FxVfxNodeDefinition definition) { var node = new FxVfxNode { definition = definition }; foreach (var property in definition.properties) { node.properties.Add(property.name, new List <object>()); } return(node); }