public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath) { TransformAsset transformAsset = new TransformAsset(); transformAsset.Identifier = identifier; transformAsset.GameObjectIdentifier = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64()); transformAsset.LocalRotation = new NitroxQuaternion( reader.ReadSingle(), // Quaternion X reader.ReadSingle(), // Quaternion Y reader.ReadSingle(), // Quaternion Z reader.ReadSingle()); // Quaternion W transformAsset.LocalPosition = new NitroxVector3( reader.ReadSingle(), // Position X reader.ReadSingle(), // Position Y reader.ReadSingle()); // Position Z transformAsset.LocalScale = new NitroxVector3( reader.ReadSingle(), // Scale X reader.ReadSingle(), // Scale Y reader.ReadSingle()); // Scale Z // Children may be parsed out of order so we don't directly assign them to TransformAsset // instead, we rely on a call back to index ChildrenIdsByPatentId (same access pattern as // the other data structures throughout this process). List <AssetIdentifier> children = new List <AssetIdentifier>(); ChildrenIdsByParentId.Add(identifier, children); int childrenCount = reader.ReadInt32(); for (int i = 0; i < childrenCount; i++) { AssetIdentifier child = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64()); ChildrenIdToParentId.Add(child, identifier); children.Add(child); } transformAsset.ParentIdentifier = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64()); TransformsByAssetId.Add(identifier, transformAsset); }
public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjectIdentifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath) { reader.Align(); uint size = reader.ReadUInt32(); WorldEntityInfo wei; for (int i = 0; i < size; i++) { wei = new WorldEntityInfo(); wei.classId = reader.ReadCountStringInt32(); wei.techType = (TechType)reader.ReadInt32(); wei.slotType = (EntitySlot.Type)reader.ReadInt32(); wei.prefabZUp = reader.ReadBoolean(); reader.Align(); wei.cellLevel = (LargeWorldEntity.CellLevel)reader.ReadInt32(); wei.localScale = new UnityEngine.Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); resourceAssets.WorldEntitiesByClassId.Add(wei.classId, wei); } }
public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets) { TransformAsset transformAsset = new TransformAsset(); transformAsset.Identifier = identifier; reader.Position += 12; transformAsset.LocalRotation = new NitroxQuaternion( reader.ReadSingle(), // Quaternion X reader.ReadSingle(), // Quaternion Y reader.ReadSingle(), // Quaternion Z reader.ReadSingle()); // Quaternion W transformAsset.LocalPosition = new NitroxVector3( reader.ReadSingle(), // Position X reader.ReadSingle(), // Position Y reader.ReadSingle()); // Position Z transformAsset.LocalScale = new NitroxVector3( reader.ReadSingle(), // Scale X reader.ReadSingle(), // Scale Y reader.ReadSingle()); // Scale Z int childrenCount = reader.ReadInt32(); for (int i = 0; i < childrenCount; i++) { AssetIdentifier child = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64()); ChildrenIdToParentId.Add(child, identifier); } transformAsset.ParentIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64()); TransformsByAssetId.Add(identifier, transformAsset); }
public AssetTypeValueField ReadType(AssetsFileReader reader, ulong filePos, AssetTypeValueField valueField, bool bigEndian) { if (valueField.templateField.isArray) { if (valueField.templateField.childrenCount == 2) { EnumValueTypes sizeType = valueField.templateField.children[0].valueType; if (sizeType == EnumValueTypes.ValueType_Int32 || sizeType == EnumValueTypes.ValueType_UInt32) { valueField.childrenCount = reader.ReadUInt32(); valueField.pChildren = new AssetTypeValueField[valueField.childrenCount]; for (int i = 0; i < valueField.childrenCount; i++) { valueField.pChildren[i] = new AssetTypeValueField(); valueField.pChildren[i].templateField = valueField.templateField.children[1]; valueField.pChildren[i] = ReadType(reader, reader.Position, valueField.pChildren[i], bigEndian); } if (valueField.templateField.align) { reader.Align(); } AssetTypeArray ata = new AssetTypeArray(); ata.size = valueField.childrenCount; valueField.value = new AssetTypeValue(EnumValueTypes.ValueType_Array, 0); valueField.value.Set(ata); } else { Debug.WriteLine("Invalid array value type! Found an unexpected " + sizeType.ToString() + " type instead!"); } } else { Debug.WriteLine("Invalid array!"); } } else { EnumValueTypes type = valueField.templateField.valueType; if (type != 0) { valueField.value = new AssetTypeValue(type, 0); } if (type == EnumValueTypes.ValueType_String) { valueField.value.Set(reader.ReadCountStringInt32()); reader.Align(); } else { valueField.childrenCount = valueField.templateField.childrenCount; if (valueField.childrenCount == 0) { valueField.pChildren = new AssetTypeValueField[0]; switch (valueField.templateField.valueType) { case EnumValueTypes.ValueType_Int8: valueField.value.Set(reader.ReadSByte()); if (valueField.templateField.align) { reader.Align(); } break; case EnumValueTypes.ValueType_UInt8: case EnumValueTypes.ValueType_Bool: valueField.value.Set(reader.ReadByte()); if (valueField.templateField.align) { reader.Align(); } break; case EnumValueTypes.ValueType_Int16: valueField.value.Set(reader.ReadInt16()); if (valueField.templateField.align) { reader.Align(); } break; case EnumValueTypes.ValueType_UInt16: valueField.value.Set(reader.ReadUInt16()); if (valueField.templateField.align) { reader.Align(); } break; case EnumValueTypes.ValueType_Int32: valueField.value.Set(reader.ReadInt32()); break; case EnumValueTypes.ValueType_UInt32: valueField.value.Set(reader.ReadUInt32()); break; case EnumValueTypes.ValueType_Int64: valueField.value.Set(reader.ReadInt64()); break; case EnumValueTypes.ValueType_UInt64: valueField.value.Set(reader.ReadUInt64()); break; case EnumValueTypes.ValueType_Float: valueField.value.Set(reader.ReadSingle()); break; case EnumValueTypes.ValueType_Double: valueField.value.Set(reader.ReadDouble()); break; } } else { valueField.pChildren = new AssetTypeValueField[valueField.childrenCount]; for (int i = 0; i < valueField.childrenCount; i++) { valueField.pChildren[i] = new AssetTypeValueField(); valueField.pChildren[i].templateField = valueField.templateField.children[i]; valueField.pChildren[i] = ReadType(reader, reader.Position, valueField.pChildren[i], bigEndian); } } } } return(valueField); }