Mass: add support for reading armour parts.

This commit is contained in:
Guillaume Jacquemin 2021-10-03 16:32:47 +02:00
parent 0904384e0d
commit 8c81b7811b
2 changed files with 123 additions and 1 deletions

View file

@ -22,11 +22,16 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "../UESaveFile/Types/ArrayProperty.h" #include "../UESaveFile/Types/ArrayProperty.h"
#include "../UESaveFile/Types/BoolProperty.h"
#include "../UESaveFile/Types/ByteProperty.h"
#include "../UESaveFile/Types/ColourStructProperty.h" #include "../UESaveFile/Types/ColourStructProperty.h"
#include "../UESaveFile/Types/FloatProperty.h" #include "../UESaveFile/Types/FloatProperty.h"
#include "../UESaveFile/Types/GenericStructProperty.h" #include "../UESaveFile/Types/GenericStructProperty.h"
#include "../UESaveFile/Types/IntProperty.h" #include "../UESaveFile/Types/IntProperty.h"
#include "../UESaveFile/Types/RotatorStructProperty.h"
#include "../UESaveFile/Types/StringProperty.h" #include "../UESaveFile/Types/StringProperty.h"
#include "../UESaveFile/Types/VectorStructProperty.h"
#include "../UESaveFile/Types/Vector2DStructProperty.h"
#include "Mass.h" #include "Mass.h"
@ -205,7 +210,117 @@ void Mass::refreshValues() {
} }
// endregion // endregion
// TODO: armour // region ArmourParts
{
auto armour_array = unit_data->at<ArrayProperty>("Armor_10_12E266C44116DDAF57E99ABB575A4B3C");
if(!armour_array) {
_state = State::Invalid;
return;
}
if(armour_array->items.size() != 38) {
_state = State::Invalid;
return;
}
for(UnsignedInt i = 0; i < armour_array->items.size(); i++) {
auto part_prop = armour_array->at<GenericStructProperty>(i);
ArmourPart part;
part.slot = part_prop->at<ByteProperty>("Slot_3_408BA56F4C9605C7E805CF91B642249C")->enumValue;
part.id = part_prop->at<IntProperty>("ID_5_ACD101864D3481DE96EDACACC09BDD25")->value;
auto part_styles = part_prop->at<ArrayProperty>("Styles_47_3E31870441DFD7DB8BEE5C85C26B365B");
if(!part_styles) {
_state = State::Invalid;
return;
}
if(part_styles->items.size() != 4) {
_state = State::Invalid;
return;
}
for(UnsignedInt j = 0; j < part_styles->items.size(); j++) {
part.styles[j] = part_styles->at<IntProperty>(j)->value;
}
auto decals_array = part_prop->at<ArrayProperty>("Decals_42_F358794A4F18497970F56BA9627D3603");
if(!decals_array) {
_state = State::Invalid;
return;
}
if(decals_array->items.size() != 8) {
_state = State::Invalid;
return;
}
for(UnsignedInt j = 0; j < decals_array->items.size(); j++) {
auto decal_prop = decals_array->at<GenericStructProperty>(j);
Decal decal;
decal.id = decal_prop->at<IntProperty>("ID_3_694C0B35404D8A3168AEC89026BC8CF9")->value;
auto colour_prop = decal_prop->at<ColourStructProperty>("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606");
decal.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
auto pos_prop = decal_prop->at<VectorStructProperty>("Position_41_022C8FE84E1AAFE587261E88F2C72250");
decal.position = Vector3{pos_prop->x, pos_prop->y, pos_prop->z};
auto u_prop = decal_prop->at<VectorStructProperty>("UAxis_37_EBEB715F45491AECACCC07A1AE4646D1");
decal.uAxis = Vector3{u_prop->x, u_prop->y, u_prop->z};
auto v_prop = decal_prop->at<VectorStructProperty>("VAxis_39_C31EB2664EE202CAECFBBB84100B5E35");
decal.vAxis = Vector3{v_prop->x, v_prop->y, v_prop->z};
auto offset_prop = decal_prop->at<Vector2DStructProperty>("Offset_29_B02BBBB74FC60F5EDBEBAB8020738020");
decal.offset = Vector2{offset_prop->x, offset_prop->y};
decal.scale = decal_prop->at<FloatProperty>("Scale_32_959D1C2747AFD8D62808468235CBBA40")->value;
decal.rotation = decal_prop->at<FloatProperty>("Rotation_27_12D7C314493D203D5C2326A03C5F910F")->value;
decal.flip = decal_prop->at<BoolProperty>("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1")->value;
decal.wrap = decal_prop->at<BoolProperty>("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62")->value;
part.decals[j] = decal;
}
auto accs_array = part_prop->at<ArrayProperty>("Accessories_52_D902DD4241FA0050C2529596255153F3");
if(!accs_array) {
_state = State::Invalid;
return;
}
if(accs_array->items.size() != 8) {
_state = State::Invalid;
return;
}
for(UnsignedInt j = 0; j < accs_array->items.size(); j++) {
auto acc_prop = accs_array->at<GenericStructProperty>(j);
Accessory accessory;
accessory.attachIndex = acc_prop->at<IntProperty>("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20")->value;
accessory.id = acc_prop->at<IntProperty>("ID_4_5757B32647BAE263266259B8A7DFFFC1")->value;
auto acc_styles = acc_prop->at<ArrayProperty>("Styles_7_91DEB0F24E24D13FC9472882C11D0DFD");
for(UnsignedInt k = 0; k < acc_styles->items.size(); k++) {
accessory.styles[k] = acc_styles->at<IntProperty>(k)->value;
}
auto rel_pos_prop = acc_prop->at<VectorStructProperty>("RelativePosition_14_BE8FB2A94074F34B3EDA6683B227D3A1");
accessory.relativePosition = Vector3{rel_pos_prop->x, rel_pos_prop->y, rel_pos_prop->z};
auto rel_pos_offset_prop = acc_prop->at<VectorStructProperty>("RelativePositionOffset_15_98FD0CE74E44BBAFC2D46FB4CA4E0ED6");
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<RotatorStructProperty>("RelativeRotation_20_C78C73274E6E78E7878F8C98ECA342C0");
accessory.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z};
auto rel_rot_offset_prop = acc_prop->at<RotatorStructProperty>("RelativeRotationOffset_21_E07FA0EC46728B7BA763C6861249ABAA");
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<VectorStructProperty>("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53");
accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z};
part.accessories[j] = std::move(accessory);
}
_armour.parts[i] = std::move(part);
}
}
// endregion
// region ArmourStyles // region ArmourStyles
{ {
@ -531,6 +646,10 @@ auto Mass::setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool {
return setCustomStyle(_frame.customStyles[index], index, "FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA"); return setCustomStyle(_frame.customStyles[index], index, "FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA");
} }
auto Mass::armourParts() -> Containers::StaticArrayView<38, ArmourPart> {
return _armour.parts;
}
auto Mass::armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> { auto Mass::armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> {
return _armour.customStyles; return _armour.customStyles;
} }

View file

@ -150,6 +150,9 @@ class Mass {
auto frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>; auto frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>;
auto setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool; auto setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool;
auto armourParts() -> Containers::StaticArrayView<38, ArmourPart>;
auto setArmourPart(ArmourPart& part, UnsignedLong index) -> bool;
auto armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>; auto armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>;
auto setArmourCustomStyle(CustomStyle style, UnsignedLong index) -> bool; auto setArmourCustomStyle(CustomStyle style, UnsignedLong index) -> bool;