// MassBuilderSaveTool // Copyright (C) 2021-2022 Guillaume Jacquemin // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include "../UESaveFile/Types/ArrayProperty.h" #include "../UESaveFile/Types/BoolProperty.h" #include "../UESaveFile/Types/ColourStructProperty.h" #include "../UESaveFile/Types/FloatProperty.h" #include "../UESaveFile/Types/GenericStructProperty.h" #include "../UESaveFile/Types/RotatorStructProperty.h" #include "../UESaveFile/Types/VectorStructProperty.h" #include "../UESaveFile/Types/Vector2DStructProperty.h" #include "../UESaveFile/Types/IntProperty.h" #include "Mass.h" using namespace Containers::Literals; void Mass::getDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { for(UnsignedInt i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); auto& decal = decals[i]; decal.id = decal_prop->at("ID_3_694C0B35404D8A3168AEC89026BC8CF9"_s)->value; auto colour_prop = decal_prop->at("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606"_s); decal.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; auto pos_prop = decal_prop->at("Position_41_022C8FE84E1AAFE587261E88F2C72250"_s); decal.position = Vector3{pos_prop->x, pos_prop->y, pos_prop->z}; auto u_prop = decal_prop->at("UAxis_37_EBEB715F45491AECACCC07A1AE4646D1"_s); decal.uAxis = Vector3{u_prop->x, u_prop->y, u_prop->z}; auto v_prop = decal_prop->at("VAxis_39_C31EB2664EE202CAECFBBB84100B5E35"_s); decal.vAxis = Vector3{v_prop->x, v_prop->y, v_prop->z}; auto offset_prop = decal_prop->at("Offset_29_B02BBBB74FC60F5EDBEBAB8020738020"_s); decal.offset = Vector2{offset_prop->x, offset_prop->y}; decal.scale = decal_prop->at("Scale_32_959D1C2747AFD8D62808468235CBBA40"_s)->value; decal.rotation = decal_prop->at("Rotation_27_12D7C314493D203D5C2326A03C5F910F"_s)->value; decal.flip = decal_prop->at("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1"_s)->value; decal.wrap = decal_prop->at("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62"_s)->value; } } void Mass::writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { for(UnsignedInt i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); auto& decal = decals[i]; decal_prop->at("ID_3_694C0B35404D8A3168AEC89026BC8CF9"_s)->value = decal.id; auto colour_prop = decal_prop->at("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606"_s); colour_prop->r = decal.colour.r(); colour_prop->g = decal.colour.g(); colour_prop->b = decal.colour.b(); colour_prop->a = decal.colour.a(); auto pos_prop = decal_prop->at("Position_41_022C8FE84E1AAFE587261E88F2C72250"_s); pos_prop->x = decal.position.x(); pos_prop->y = decal.position.y(); pos_prop->z = decal.position.z(); auto u_prop = decal_prop->at("UAxis_37_EBEB715F45491AECACCC07A1AE4646D1"_s); u_prop->x = decal.uAxis.x(); u_prop->y = decal.uAxis.y(); u_prop->z = decal.uAxis.z(); auto v_prop = decal_prop->at("VAxis_39_C31EB2664EE202CAECFBBB84100B5E35"_s); v_prop->x = decal.vAxis.x(); v_prop->y = decal.vAxis.y(); v_prop->z = decal.vAxis.z(); auto offset_prop = decal_prop->at("Offset_29_B02BBBB74FC60F5EDBEBAB8020738020"_s); offset_prop->x = decal.offset.x(); offset_prop->y = decal.offset.y(); decal_prop->at("Scale_32_959D1C2747AFD8D62808468235CBBA40"_s)->value = decal.scale; decal_prop->at("Rotation_27_12D7C314493D203D5C2326A03C5F910F"_s)->value = decal.rotation; decal_prop->at("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1"_s)->value = decal.flip; decal_prop->at("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62"_s)->value = decal.wrap; } } void Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty* accessory_array) { for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) { auto acc_prop = accessory_array->at(i); auto& accessory = accessories[i]; accessory.attachIndex = acc_prop->at("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20"_s)->value; accessory.id = acc_prop->at("ID_4_5757B32647BAE263266259B8A7DFFFC1"_s)->value; auto acc_styles = acc_prop->at("Styles_7_91DEB0F24E24D13FC9472882C11D0DFD"_s); for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) { accessory.styles[j] = acc_styles->at(j)->value; } auto rel_pos_prop = acc_prop->at("RelativePosition_14_BE8FB2A94074F34B3EDA6683B227D3A1"_s); accessory.relativePosition = Vector3{rel_pos_prop->x, rel_pos_prop->y, rel_pos_prop->z}; auto rel_pos_offset_prop = acc_prop->at("RelativePositionOffset_15_98FD0CE74E44BBAFC2D46FB4CA4E0ED6"_s); accessory.relativePositionOffset = Vector3{rel_pos_offset_prop->x, rel_pos_offset_prop->y, rel_pos_offset_prop->z}; auto rel_rot_prop = acc_prop->at("RelativeRotation_20_C78C73274E6E78E7878F8C98ECA342C0"_s); accessory.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z}; auto rel_rot_offset_prop = acc_prop->at("RelativeRotationOffset_21_E07FA0EC46728B7BA763C6861249ABAA"_s); accessory.relativeRotationOffset = Vector3{rel_rot_offset_prop->x, rel_rot_offset_prop->y, rel_rot_offset_prop->z}; auto local_scale_prop = acc_prop->at("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53"_s); accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z}; } } void Mass::writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array) { for(UnsignedInt i = 0; i < accs_array->items.size(); i++) { auto acc_prop = accs_array->at(i); auto& accessory = accessories[i]; acc_prop->at("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20"_s)->value = accessory.attachIndex; acc_prop->at("ID_4_5757B32647BAE263266259B8A7DFFFC1"_s)->value = accessory.id; auto acc_styles = acc_prop->at("Styles_7_91DEB0F24E24D13FC9472882C11D0DFD"_s); for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) { acc_styles->at(j)->value = accessory.styles[j]; } auto rel_pos_prop = acc_prop->at("RelativePosition_14_BE8FB2A94074F34B3EDA6683B227D3A1"_s); rel_pos_prop->x = accessory.relativePosition.x(); rel_pos_prop->y = accessory.relativePosition.y(); rel_pos_prop->z = accessory.relativePosition.z(); auto rel_pos_offset_prop = acc_prop->at("RelativePositionOffset_15_98FD0CE74E44BBAFC2D46FB4CA4E0ED6"_s); rel_pos_offset_prop->x = accessory.relativePositionOffset.x(); rel_pos_offset_prop->y = accessory.relativePositionOffset.y(); rel_pos_offset_prop->z = accessory.relativePositionOffset.z(); auto rel_rot_prop = acc_prop->at("RelativeRotation_20_C78C73274E6E78E7878F8C98ECA342C0"_s); rel_rot_prop->x = accessory.relativeRotation.x(); rel_rot_prop->y = accessory.relativeRotation.y(); rel_rot_prop->z = accessory.relativeRotation.z(); auto rel_rot_offset_prop = acc_prop->at("RelativeRotationOffset_21_E07FA0EC46728B7BA763C6861249ABAA"_s); rel_rot_offset_prop->x = accessory.relativeRotationOffset.x(); rel_rot_offset_prop->y = accessory.relativeRotationOffset.y(); rel_rot_offset_prop->z = accessory.relativeRotationOffset.z(); auto local_scale_prop = acc_prop->at("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53"_s); local_scale_prop->x = accessory.localScale.x(); local_scale_prop->y = accessory.localScale.y(); local_scale_prop->z = accessory.localScale.z(); } }