diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91555ba..4b7d4fe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,7 @@ add_executable(MassBuilderSaveTool WIN32 MassManager/MassManager.cpp Mass/Accessory.h Mass/ArmourPart.h + Mass/BulletLauncherAttachment.h Mass/CustomStyle.h Mass/Decal.h Mass/Joints.h @@ -145,6 +146,8 @@ add_executable(MassBuilderSaveTool WIN32 Maps/Accessories.h Maps/ArmourSets.h Maps/ArmourSlots.hpp + Maps/BulletLauncherAttachmentStyles.hpp + Maps/BulletLauncherSockets.hpp Maps/DamageTypes.hpp Maps/EffectColourModes.hpp Maps/LastMissionId.h diff --git a/src/Maps/BulletLauncherAttachmentStyles.hpp b/src/Maps/BulletLauncherAttachmentStyles.hpp new file mode 100644 index 0000000..53dd9db --- /dev/null +++ b/src/Maps/BulletLauncherAttachmentStyles.hpp @@ -0,0 +1,22 @@ +// 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 . + +#ifdef c +c(NotFound, "NotARealValue"_s) +c(ActiveOne, "enuBLAttachmentStyle::NewEnumerator0"_s) +c(ActiveOnePerSlot, "enuBLAttachmentStyle::NewEnumerator1"_s) +c(AllEquipped, "enuBLAttachmentStyle::NewEnumerator2"_s) +#endif diff --git a/src/Maps/BulletLauncherSockets.hpp b/src/Maps/BulletLauncherSockets.hpp new file mode 100644 index 0000000..1aa99b9 --- /dev/null +++ b/src/Maps/BulletLauncherSockets.hpp @@ -0,0 +1,24 @@ +// 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 . + +#ifdef c +c(Auto, "None"_s) +c(Shoulders, "Shoulder"_s) +c(Body, "Body"_s) +c(Backpack, "Backpack"_s) +c(Hip, "Hip"_s) +c(LowerLegs, "LowerLeg"_s) +#endif diff --git a/src/Mass/BulletLauncherAttachment.h b/src/Mass/BulletLauncherAttachment.h new file mode 100644 index 0000000..1882070 --- /dev/null +++ b/src/Mass/BulletLauncherAttachment.h @@ -0,0 +1,46 @@ +#pragma once + +// 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 + +#include +#include + +using namespace Corrade; +using namespace Magnum; + +enum class BulletLauncherAttachmentStyle { + #define c(enumerator, enumstr) enumerator, + #include "../Maps/BulletLauncherAttachmentStyles.hpp" + #undef c +}; + +enum class BulletLauncherSocket { + #define c(enumerator, enumstr) enumerator, + #include "../Maps/BulletLauncherSockets.hpp" + #undef c +}; + +struct BulletLauncherAttachment { + BulletLauncherSocket socket = BulletLauncherSocket::Auto; + Vector3 relativeLocation; + Vector3 offsetLocation; + Vector3 relativeRotation; + Vector3 offsetRotation; + Vector3 relativeScale; +}; diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 7df01e8..3966e9c 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -139,6 +139,11 @@ void Mass::refreshValues() { return; } + getBulletLauncherAttachments(); + if(_state == State::Invalid) { + return; + } + getArmourCustomStyles(); if(_state == State::Invalid) { return; diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index 2c2dd9e..733c07f 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -28,6 +28,7 @@ #include #include "Joints.h" +#include "BulletLauncherAttachment.h" #include "CustomStyle.h" #include "Decal.h" #include "Accessory.h" @@ -92,6 +93,11 @@ class Mass { void getArmourParts(); auto writeArmourPart(ArmourSlot slot) -> bool; + auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&; + auto bulletLauncherAttachments() -> Containers::ArrayView; + void getBulletLauncherAttachments(); + auto writeBulletLauncherAttachments() -> bool; + auto armourCustomStyles() -> Containers::ArrayView; void getArmourCustomStyles(); auto writeArmourCustomStyle(UnsignedLong index) -> bool; @@ -176,6 +182,8 @@ class Mass { struct { Containers::StaticArray<38, ArmourPart> parts; Containers::StaticArray<16, CustomStyle> customStyles; + BulletLauncherAttachmentStyle blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound; + Containers::StaticArray<4, BulletLauncherAttachment> blAttachment; } _armour; struct { diff --git a/src/Mass/Mass_Armour.cpp b/src/Mass/Mass_Armour.cpp index 5f3eaa9..94a2d74 100644 --- a/src/Mass/Mass_Armour.cpp +++ b/src/Mass/Mass_Armour.cpp @@ -21,6 +21,7 @@ #include "../UESaveFile/Types/GenericStructProperty.h" #include "../UESaveFile/Types/IntProperty.h" #include "../UESaveFile/Types/StringProperty.h" +#include "../UESaveFile/Types/VectorStructProperty.h" #include "Mass.h" @@ -162,6 +163,83 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool { return true; } +auto Mass::bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle& { + return _armour.blAttachmentStyle; +} + +auto Mass::bulletLauncherAttachments() -> Containers::ArrayView { + return _armour.blAttachment; +} + +void Mass::getBulletLauncherAttachments() { + auto unit_data = _mass->at("UnitData"_s); + if(!unit_data) { + _state = State::Invalid; + return; + } + + auto attach_style_prop = _mass->at("WeaponBLAttachmentStyle_65_5943FCE8406F18D2C3F69285EB23A699"_s); + auto attach_array = _mass->at("WeaponBLAttachment_61_442D08F547510A4CEE1501BBAF297BA0"_s); + + if(!attach_style_prop && !attach_array) { + _armour.blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound; + return; + } + + if(attach_style_prop && !attach_array) { + _armour.blAttachmentStyle = BulletLauncherAttachmentStyle::NotFound; + _state = State::Invalid; + return; + } + + if(attach_array->items.size() != _weapons.bulletLaunchers.size() && + attach_array->items.size() != _armour.blAttachment.size()) + { + for(UnsignedInt i = 0; i < attach_array->items.size(); i++) { + auto attachment_prop = attach_array->at(i); + auto& attachment = _armour.blAttachment[i]; + + Containers::StringView socket = attachment_prop->at("Socket_9_B9DBF30D4A1F0032A2BE2F8B342B35A9"_s)->value; + #define c(enumerator, strenum) if(socket == (strenum)) { attachment.socket = BulletLauncherSocket::enumerator; } else + #include "../Maps/BulletLauncherSockets.hpp" + #undef c + { + Utility::Error{} << "Invalid BL attachment socket."; + _state = State::Invalid; + return; + } + + auto rel_loc_prop = attachment_prop->at("RelativeLocation_10_2F6E75DF4C40622658340E9A22D38B02"_s); + attachment.relativeLocation = Vector3{rel_loc_prop->x, rel_loc_prop->y, rel_loc_prop->z}; + auto off_loc_prop = attachment_prop->at("OffsetLocation_11_F42B3DA3436948FF85752DB33722382F"_s); + attachment.offsetLocation = Vector3{off_loc_prop->x, off_loc_prop->y, off_loc_prop->z}; + auto rel_rot_prop = attachment_prop->at("RelativeRotation_12_578140464621245132CFF2A2AD85E735"_s); + attachment.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z}; + auto off_rot_prop = attachment_prop->at("OffsetRotation_13_B5980BCD47905D842D1490A1A520B064"_s); + attachment.offsetRotation = Vector3{off_rot_prop->x, off_rot_prop->y, off_rot_prop->z}; + auto rel_scale_prop = attachment_prop->at("RelativeScale_16_37BC80EF42699F79533F7AA7B3094E38"_s); + attachment.relativeScale = Vector3{rel_scale_prop->x, rel_scale_prop->y, rel_scale_prop->z}; + } + } + + if(attach_style_prop) { + Containers::StringView attach_style = attach_style_prop->enumValue; + #define c(enumerator, strenum) if(attach_style == (strenum)) { _armour.blAttachmentStyle = BulletLauncherAttachmentStyle::enumerator; } else + #include "../Maps/BulletLauncherAttachmentStyles.hpp" + #undef c + { + Utility::Error{} << "Unknown BL attachment style enumerator."; + } + } + else { + _armour.blAttachmentStyle = BulletLauncherAttachmentStyle::ActiveOne; + } +} + +auto Mass::writeBulletLauncherAttachments() -> bool { + return false; +} + auto Mass::armourCustomStyles() -> Containers::ArrayView { return _armour.customStyles; }