private static void RecursiveGetClassIDsClasses(ref Dictionary <HavokClassNode, int> classIDs, HavokNode node, ResourceNode e) { if (e is hkClassNode) { hkClassNode type = e as hkClassNode; if (!string.IsNullOrEmpty(type.ParentClass)) { HavokClassNode c = node.GetClassNode(type.ParentClass); classIDs.Add(c, classIDs.Count + 1); } ResourceNode members = type.FindChild("Members", false); foreach (hkClassMemberNode member in members.Children) { if (!string.IsNullOrEmpty(member._class)) { HavokClassNode c = node.GetClassNode(member._class); classIDs.Add(c, classIDs.Count + 1); } if (!string.IsNullOrEmpty(member._enum)) { HavokClassNode c = node.GetClassNode(member._enum); classIDs.Add(c, classIDs.Count + 1); } } if (!classIDs.ContainsKey(type)) { classIDs.Add(type, classIDs.Count + 1); } } }
public void WriteParams(System.Xml.XmlWriter writer, Dictionary <HavokClassNode, int> classNodes) { writer.WriteStartElement("hkobject"); { writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "name"); writer.WriteString(Name); writer.WriteEndElement(); HavokClassNode c = string.IsNullOrEmpty(_class) ? null : HavokNode.GetClassNode(_class); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "class"); writer.WriteString(c != null ? HavokXML.GetObjectName(classNodes, c) : "null"); writer.WriteEndElement(); HavokClassNode e = string.IsNullOrEmpty(_enum) ? null : HavokNode.GetClassNode(_enum); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "enum"); writer.WriteString(e != null ? HavokXML.GetObjectName(classNodes, e) : "null"); writer.WriteEndElement(); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "type"); string type = Type.ToString(); if (type == "TYPE_CSTRING") { type = "TYPE_STRINGPTR"; } writer.WriteString(type); writer.WriteEndElement(); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "subtype"); writer.WriteString(SubType.ToString()); writer.WriteEndElement(); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "cArraySize"); writer.WriteString(ArraySize.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "flags"); writer.WriteString(((int)Flags).ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); writer.WriteStartElement("hkparam"); writer.WriteAttributeString("name", "offset"); writer.WriteString(OffsetInStruct.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); writer.WriteComment(" attributes SERIALIZE_IGNORED "); } writer.WriteEndElement(); }
public override void OnPopulate() { hkVariant * v = (hkVariant *)Data; hkClass * classData = (hkClass *)v->_classPtr.OffsetAddress; HavokClassNode entry = HavokNode.GetClassNode(new String((sbyte *)classData->_namePtr.OffsetAddress), true); if (entry != null) { new HavokMetaObjectNode(entry as hkClassNode) .Initialize(this, v->_objectPtr.OffsetAddress, classData->_size); } }
private static void RecursiveGetClassIDsData(ref Dictionary <HavokClassNode, int> classIDs, HavokNode node, ResourceNode e) { if (e is HavokMetaObjectNode || e is hkClassNode) { HavokClassNode data = e as HavokClassNode; HavokClassNode type = node.GetClassNode(data._className); RecursiveGetClassIDsClasses(ref classIDs, node, type); classIDs.Add(data, classIDs.Count + 1); } for (int i = e.Children.Count - 1; i >= 0; i--) { RecursiveGetClassIDsData(ref classIDs, node, e.Children[i]); } }
public void GetInheritance() { _inheritance = new List <hkClassNode>(); ResourceNode current = this; //First, get classes inheriting this one TOP: bool found = false; if (current != null) { foreach (HavokSectionNode section in HavokNode.Children) { if (section._classCache != null && section != HavokNode._dataSection) { foreach (HavokClassNode c in section._classCache) { hkClassNode x = c as hkClassNode; if (x != null && x != this && x.ParentClass == current.Name) { current = x; _inheritance.Insert(0, x); found = true; break; } } } if (found) { break; } } } if (found) { goto TOP; } current = this; //Now add this class and the classes it inherits while (current != null && current is hkClassNode) { hkClassNode cNode = (hkClassNode)current; _inheritance.Add(cNode); if (HavokNode.AssignClassParents) { current = current.Parent; } else if (!String.IsNullOrEmpty(cNode.ParentClass)) { current = null; HavokClassNode parent = HavokNode.GetClassNode(cNode.ParentClass); if (parent is hkClassNode) { current = parent; } } } //Start with the eldest class, added last _inheritance.Reverse(); }
public override void OnPopulate() { VoidPtr addr = WorkingUncompressed.Address; foreach (hkClassMemberNode member in _memberArray) { hkClassMember.Type type = member.Type; bool zero = type == hkClassMember.Type.TYPE_ZERO; if (zero) { type = member.SubType; } hkClassNode memberClass = null; hkClassEnumNode memberEnum = null; if (!string.IsNullOrEmpty(member._class)) { HavokClassNode c = HavokNode.GetClassNode(member._class); if (c is hkClassNode) { memberClass = c as hkClassNode; } if (memberClass == null) { Console.WriteLine("Could not find " + member._class + " class"); } } if (!string.IsNullOrEmpty(member._enum)) { //Loop through inheritance starting with the eldest class, added last foreach (hkClassNode c in _classNode._inheritance) { ResourceNode enums = c.FindChild("Enums", false); if (enums != null) { foreach (hkClassEnumNode e in enums.Children) { if (e.Name == member._enum) { memberEnum = e; break; } } } } if (memberEnum == null) { Console.WriteLine("Could not find " + member._enum + " enum in " + _classNode.Name + " class"); } } ClassMemberInstanceNode instance = TryGetMember(type); if (instance != null) { switch (type) { case hkClassMember.Type.TYPE_SIMPLEARRAY: case hkClassMember.Type.TYPE_ARRAY: case hkClassMember.Type.TYPE_INPLACEARRAY: case hkClassMember.Type.TYPE_HOMOGENEOUSARRAY: case hkClassMember.Type.TYPE_POINTER: case hkClassMember.Type.TYPE_FUNCTIONPOINTER: type = member.SubType; break; } instance._isZero = zero; instance._name = member._name; instance._memberType = type; instance._memberFlags = member._flags; instance._classNode = memberClass; instance._enumNode = memberEnum; instance.Initialize(this, addr + member._structOffset, instance.GetSize()); } } }