protected override void OnWrite(VoidPtr address) { *(CollisionType *)address = _type; switch (_type) { case CollisionType.Type0: bint *addr = (bint *)address; foreach (BoneIndexValue b in _bones) { b.Write(addr++); } RebuildAddress = addr; sCollData0 *data1 = (sCollData0 *)addr; data1->unk1 = _length; data1->unk2 = _width; data1->unk3 = _height; if (_bones.Count > 0) { data1->_list._startOffset = Offset(address); Lookup(&data1->_list._startOffset); } data1->_list._listCount = _bones.Count; break; case CollisionType.Type1: RebuildAddress = address; sCollData1 *data2 = (sCollData1 *)address; data2->unk1 = _length; data2->unk2 = _width; data2->unk3 = _height; break; case CollisionType.Type2: RebuildAddress = address; sCollData2 *data3 = (sCollData2 *)address; data3->flags = _flags; data3->unk1 = _length; data3->unk2 = _width; data3->unk3 = _height; if ((_flags & 2) == 2) { data3->unk4 = _unknown; } break; } }
protected override void OnParse(VoidPtr address) { _bones = new List <BoneIndexValue>(); _type = *(CollisionType *)address; switch (_type) { case CollisionType.Type0: sCollData0 *hdr1 = (sCollData0 *)address; _dataOffset = hdr1->_list._startOffset; _count = hdr1->_list._listCount; _length = hdr1->unk1; _width = hdr1->unk2; _height = hdr1->unk3; for (int i = 0; i < _count; i++) { _bones.Add(Parse <BoneIndexValue>(_dataOffset + i * 4)); } break; case CollisionType.Type1: sCollData1 *hdr2 = (sCollData1 *)address; _length = hdr2->unk1; _width = hdr2->unk2; _height = hdr2->unk3; break; case CollisionType.Type2: sCollData2 *hdr3 = (sCollData2 *)address; _flags = hdr3->flags; _length = hdr3->unk1; _width = hdr3->unk2; _height = hdr3->unk3; if ((_flags & 2) == 2) { _unknown = hdr3->unk4; } if (_initSize != 24 && _initSize != 20) { throw new Exception("Incorrect size"); } break; } }