public override void OnPopulate() { VoidPtr dataPtr = dataAddr; int size = 0; for (int i = 0; i < count; i++, dataPtr += size) { switch (_memberType) { case hkClassMember.Type.TYPE_STRUCT: new HavokMetaObjectNode(_classNode) .Initialize(this, dataPtr, size = _classNode == null ? 0 : _classNode.Size); break; case hkClassMember.Type.TYPE_ENUM: case hkClassMember.Type.TYPE_FLAGS: new cmEnumNode() { _enumNode = _enumNode } .Initialize(this, dataPtr, size = (int)_memberFlags & 0x3F); break; case hkClassMember.Type.TYPE_ARRAY: case hkClassMember.Type.TYPE_HOMOGENEOUSARRAY: case hkClassMember.Type.TYPE_INPLACEARRAY: case hkClassMember.Type.TYPE_SIMPLEARRAY: case hkClassMember.Type.TYPE_FUNCTIONPOINTER: case hkClassMember.Type.TYPE_ZERO: Console.WriteLine("This shouldn't happen"); break; default: ClassMemberInstanceNode instance = HavokMetaObjectNode.TryGetMember(_memberType); if (instance != null) { hkClassMember.Type tempType = _memberType; if (tempType == hkClassMember.Type.TYPE_POINTER) { tempType = hkClassMember.Type.TYPE_STRUCT; //Pointer to class object } instance._isZero = false; instance._name = "Entry" + i; instance._memberType = tempType; instance._memberFlags = _memberFlags; instance._classNode = _classNode; instance._enumNode = _enumNode; instance.Initialize(this, dataPtr, size = instance.GetSize()); } break; } } }
public static ClassMemberInstanceNode TryGetMember(hkClassMember.Type type) { ClassMemberInstanceNode m = null; int index = (int)type; if (index >= 0 && index < MemberTypes.Length) { Type t = MemberTypes[index]; if (t != null) { m = Activator.CreateInstance(t) as ClassMemberInstanceNode; } } if (m == null) { Console.WriteLine("Problem creating class member instance of " + type); } return(m); }
public override bool OnInitialize() { _name = new String((sbyte *)Header->_namePtr.OffsetAddress); _type = (hkClassMember.Type)Header->_type; _subType = (hkClassMember.Type)Header->_pointedType; _structOffset = Header->_structOffset; _flags = (hkClassMember.Flags)(ushort) Header->_flags; _arraySize = Header->_arraySize; if (Header->_enumPtr != 0) { hkClassEnum *e = (hkClassEnum *)Header->_enumPtr.OffsetAddress; _enum = new String((sbyte *)e->_namePtr.OffsetAddress); } if (Header->_classPtr != 0) { hkClass *c = (hkClass *)Header->_classPtr.OffsetAddress; _class = new String((sbyte *)c->_namePtr.OffsetAddress); } return(false); }
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()); } } }