2021-06-11 19:24:52 +02:00
|
|
|
// MassBuilderSaveTool
|
|
|
|
// Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <Corrade/Containers/Array.h>
|
|
|
|
#include <Corrade/Utility/Directory.h>
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
#include "../UESaveFile/Types/ArrayProperty.h"
|
2021-10-03 16:32:47 +02:00
|
|
|
#include "../UESaveFile/Types/BoolProperty.h"
|
|
|
|
#include "../UESaveFile/Types/ByteProperty.h"
|
2021-09-27 17:52:47 +02:00
|
|
|
#include "../UESaveFile/Types/ColourStructProperty.h"
|
|
|
|
#include "../UESaveFile/Types/FloatProperty.h"
|
|
|
|
#include "../UESaveFile/Types/GenericStructProperty.h"
|
|
|
|
#include "../UESaveFile/Types/IntProperty.h"
|
2021-10-03 16:32:47 +02:00
|
|
|
#include "../UESaveFile/Types/RotatorStructProperty.h"
|
2021-09-27 17:52:47 +02:00
|
|
|
#include "../UESaveFile/Types/StringProperty.h"
|
2021-10-03 16:32:47 +02:00
|
|
|
#include "../UESaveFile/Types/VectorStructProperty.h"
|
|
|
|
#include "../UESaveFile/Types/Vector2DStructProperty.h"
|
2021-08-19 20:33:59 +02:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
#include "Mass.h"
|
|
|
|
|
|
|
|
std::string Mass::_lastError;
|
|
|
|
|
2021-08-19 20:33:59 +02:00
|
|
|
Mass::Mass(const std::string& path) {
|
|
|
|
_folder = Utility::Directory::path(path);
|
|
|
|
_filename = Utility::Directory::filename(path);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-08-28 20:20:09 +02:00
|
|
|
refreshValues();
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::lastError() -> std::string const& {
|
|
|
|
return _lastError;
|
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto Mass::getNameFromFile(const std::string& path) -> Containers::Optional<std::string> {
|
2021-08-19 20:33:59 +02:00
|
|
|
if(!Utility::Directory::exists(path)) {
|
|
|
|
_lastError = path + " couldn't be found.";
|
2021-09-27 17:52:47 +02:00
|
|
|
return Containers::NullOpt;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
UESaveFile mass{path};
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
if(!mass.valid()) {
|
|
|
|
_lastError = "The unit file seems to be corrupt.";
|
|
|
|
return Containers::NullOpt;
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto unit_data = mass.at<GenericStructProperty>("UnitData");
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
if(!unit_data) {
|
|
|
|
_lastError = "Couldn't find unit data in the file.";
|
|
|
|
return Containers::NullOpt;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
|
|
|
|
|
|
|
|
if(!name_prop) {
|
|
|
|
_lastError = "Couldn't find the name in the file.";
|
|
|
|
return Containers::NullOpt;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
return name_prop->value;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
2021-08-28 20:20:09 +02:00
|
|
|
void Mass::refreshValues() {
|
2021-09-27 17:52:47 +02:00
|
|
|
if(!Utility::Directory::exists(Utility::Directory::join(_folder, _filename))) {
|
|
|
|
_state = State::Empty;
|
2021-08-28 20:21:13 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
if(!_mass) {
|
|
|
|
_mass.emplace(Utility::Directory::join(_folder, _filename));
|
|
|
|
if(!_mass->valid()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
2021-08-28 20:21:13 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
else {
|
|
|
|
if(!_mass->reloadData()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
2021-08-28 20:21:13 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
2021-08-28 20:21:13 +02:00
|
|
|
_state = State::Invalid;
|
2021-09-27 17:52:47 +02:00
|
|
|
return;
|
2021-08-28 20:21:13 +02:00
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
if(!name_prop) {
|
|
|
|
_name = Containers::NullOpt;
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
_name = name_prop->value;
|
2021-10-02 19:23:35 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
getJointSliders();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
getFrameStyles();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
2021-10-03 16:32:47 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
getEyeFlareColour();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
2021-10-03 16:32:47 +02:00
|
|
|
}
|
2021-10-02 19:23:35 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
getFrameCustomStyles();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
getArmourParts();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
getArmourCustomStyles();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
|
|
|
|
2021-10-17 08:37:12 +02:00
|
|
|
getMeleeWeapons();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getShields();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getBulletShooters();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getEnergyShooters();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getBulletLaunchers();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getEnergyLaunchers();
|
|
|
|
if(_state == State::Invalid) {
|
|
|
|
return;
|
|
|
|
}
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
if(!_demo)
|
2021-10-02 14:52:48 +02:00
|
|
|
{
|
2021-10-04 18:18:53 +02:00
|
|
|
getGlobalStyles();
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: tuning
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto account_prop = _mass->at<StringProperty>("Account");
|
|
|
|
if(!account_prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
_steamId = account_prop->value;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
_state = State::Valid;
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto Mass::filename() -> std::string const&{
|
|
|
|
return _filename;
|
|
|
|
}
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto Mass::name() -> Containers::Optional<std::string> const& {
|
|
|
|
return _name;
|
|
|
|
}
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto Mass::setName(std::string new_name) -> bool {
|
|
|
|
_name = new_name;
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
2021-08-28 20:20:09 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
|
|
|
|
|
|
|
|
if(!name_prop) {
|
2021-08-28 20:20:09 +02:00
|
|
|
_state = State::Invalid;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
2021-08-28 20:20:09 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
name_prop->value = std::move(new_name);
|
|
|
|
|
|
|
|
return _mass->saveToFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::state() -> State {
|
|
|
|
return _state;
|
2021-08-28 20:20:09 +02:00
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto Mass::demo() const -> bool {
|
|
|
|
return _demo;
|
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto Mass::dirty() const -> bool {
|
|
|
|
return _dirty;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
void Mass::setDirty(bool dirty) {
|
|
|
|
_dirty = dirty;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto Mass::jointSliders() -> Joints& {
|
2021-09-27 17:52:47 +02:00
|
|
|
return _frame.joints;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getJointSliders() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
|
|
|
if(!frame_prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto length = frame_prop->at<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
|
|
|
|
_frame.joints.neck = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
|
|
|
|
_frame.joints.body = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
|
|
|
|
_frame.joints.shoulders = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
|
|
|
|
_frame.joints.hips = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
|
|
|
|
_frame.joints.upperArms = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
|
|
|
|
_frame.joints.lowerArms = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
|
|
|
|
_frame.joints.upperLegs = (length ? length->value : 0.0f);
|
|
|
|
length = frame_prop->at<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
|
|
|
|
_frame.joints.lowerLegs = (length ? length->value : 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::writeJointSliders() -> bool {
|
2021-09-27 17:52:47 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
2021-10-04 18:18:53 +02:00
|
|
|
_lastError = "No unit data in " + _filename;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
if(!frame_prop) {
|
|
|
|
_state = State::Invalid;
|
2021-10-04 18:18:53 +02:00
|
|
|
_lastError = "No frame data in " + _filename;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto length = frame_prop->at<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
|
|
|
|
if(!length && _frame.joints.neck != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.neck;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
|
|
|
|
if(!length && _frame.joints.body != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.body;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
|
|
|
|
if(!length && _frame.joints.shoulders != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
|
|
|
}
|
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.shoulders;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
|
|
|
|
if(!length && _frame.joints.hips != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.hips;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
|
|
|
|
if(!length && _frame.joints.upperArms != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
|
|
|
}
|
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.upperArms;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
|
|
|
|
if(!length && _frame.joints.lowerArms != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.lowerArms;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
|
|
|
|
if(!length && _frame.joints.upperLegs != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
|
|
|
}
|
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.upperLegs;
|
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
length = frame_prop->at<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
|
|
|
|
if(!length && _frame.joints.lowerLegs != 0.0f) {
|
|
|
|
length = new FloatProperty;
|
|
|
|
auto length_prop = FloatProperty::ptr{length};
|
|
|
|
length_prop->name.emplace("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
|
|
|
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
if(length) {
|
|
|
|
length->value = _frame.joints.lowerLegs;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
if(!_mass->saveToFile()) {
|
|
|
|
_lastError = "Couldn't write data to " + _filename;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2021-09-27 17:52:47 +02:00
|
|
|
}
|
2021-09-10 16:13:29 +02:00
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::frameStyles() -> Containers::ArrayView<Int> {
|
2021-09-27 17:52:47 +02:00
|
|
|
return _frame.styles;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getFrameStyles() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
|
|
|
if(!frame_prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto frame_styles = frame_prop->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
|
|
|
|
if(!frame_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
if(frame_styles->items.size() != _frame.styles.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_frame.styles[i] = frame_styles->at<IntProperty>(i)->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::writeFrameStyles() -> bool {
|
2021-09-27 17:52:47 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
2021-10-04 18:18:53 +02:00
|
|
|
_lastError = "No unit data in " + _filename;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
auto frame = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
|
|
|
if(!frame) {
|
|
|
|
_state = State::Invalid;
|
2021-10-04 18:18:53 +02:00
|
|
|
_lastError = "No frame data in " + _filename;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
auto frame_styles = frame->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
|
|
|
|
if(!frame_styles) {
|
|
|
|
_state = State::Invalid;
|
2021-10-04 18:18:53 +02:00
|
|
|
_lastError = "No frame styles in " + _filename;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) {
|
|
|
|
frame_styles->at<IntProperty>(i)->value = _frame.styles[i];
|
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
if(!_mass->saveToFile()) {
|
|
|
|
_lastError = "Couldn't write data to " + _filename;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2021-09-10 16:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto Mass::eyeFlareColour() -> Color4& {
|
2021-09-27 17:52:47 +02:00
|
|
|
return _frame.eyeFlare;
|
|
|
|
}
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getEyeFlareColour() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
|
|
|
if(!frame_prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto eye_flare_prop = frame_prop->at<ColourStructProperty>("EyeFlareColor_36_AF79999C40FCA0E88A2F9A84488A38CA");
|
|
|
|
if(!eye_flare_prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a};
|
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
auto Mass::writeEyeFlareColour() -> bool {
|
2021-09-27 17:52:47 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
2021-08-28 20:20:09 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto frame = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
|
|
|
if(!frame) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto eye_flare_prop = frame->at<ColourStructProperty>("EyeFlareColor_36_AF79999C40FCA0E88A2F9A84488A38CA");
|
|
|
|
if(!eye_flare_prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
eye_flare_prop->r = _frame.eyeFlare.r();
|
|
|
|
eye_flare_prop->g = _frame.eyeFlare.g();
|
|
|
|
eye_flare_prop->b = _frame.eyeFlare.b();
|
|
|
|
eye_flare_prop->a = _frame.eyeFlare.a();
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
return _mass->saveToFile();
|
|
|
|
}
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::frameCustomStyles() -> Containers::ArrayView<CustomStyle> {
|
2021-10-02 14:52:48 +02:00
|
|
|
return _frame.customStyles;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getFrameCustomStyles() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto frame_styles = unit_data->at<ArrayProperty>("FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA");
|
|
|
|
if(!frame_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
if(frame_styles->items.size() != _frame.customStyles.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:28:54 +02:00
|
|
|
getCustomStyles(_frame.customStyles, frame_styles);
|
2021-10-04 18:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::writeFrameCustomStyle(UnsignedLong index) -> bool {
|
2021-10-02 14:52:48 +02:00
|
|
|
if(index > _frame.customStyles.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:52:57 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto frame_styles = unit_data->at<ArrayProperty>("FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA");
|
|
|
|
if(!frame_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return setCustomStyle(_frame.customStyles[index], index, frame_styles);
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::armourParts() -> Containers::ArrayView<ArmourPart> {
|
2021-10-03 16:32:47 +02:00
|
|
|
return _armour.parts;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getArmourParts() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto armour_array = unit_data->at<ArrayProperty>("Armor_10_12E266C44116DDAF57E99ABB575A4B3C");
|
|
|
|
if(!armour_array) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:21:48 +02:00
|
|
|
if(armour_array->items.size() != _armour.parts.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(UnsignedInt i = 0; i < armour_array->items.size(); i++) {
|
|
|
|
auto part_prop = armour_array->at<GenericStructProperty>(i);
|
2021-10-17 09:21:48 +02:00
|
|
|
auto& part = _armour.parts[i];
|
2021-10-04 18:18:53 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:21:48 +02:00
|
|
|
if(part_styles->items.size() != part.styles.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:21:48 +02:00
|
|
|
if(decals_array->items.size() != part.decals.size()) {
|
2021-10-12 16:35:49 +02:00
|
|
|
part.demoDecals = decals_array->items.size();
|
2021-10-05 10:03:52 +02:00
|
|
|
_demo = true;
|
2021-10-04 18:18:53 +02:00
|
|
|
}
|
|
|
|
|
2021-10-18 14:53:35 +02:00
|
|
|
getDecals(part.decals, decals_array);
|
2021-10-04 18:18:53 +02:00
|
|
|
|
|
|
|
if(!_demo) {
|
|
|
|
auto accs_array = part_prop->at<ArrayProperty>("Accessories_52_D902DD4241FA0050C2529596255153F3");
|
|
|
|
if(!accs_array) {
|
|
|
|
_demo = true;
|
2021-10-17 09:21:48 +02:00
|
|
|
continue;
|
2021-10-04 18:18:53 +02:00
|
|
|
}
|
|
|
|
|
2021-10-17 09:21:48 +02:00
|
|
|
if(accs_array->items.size() != part.accessories.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:53:35 +02:00
|
|
|
getAccessories(part.accessories, accs_array);
|
2021-10-04 18:18:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-11 17:17:14 +02:00
|
|
|
auto Mass::writeArmourPart(UnsignedLong index) -> bool {
|
|
|
|
if(index > _armour.parts.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
|
|
|
|
auto armour_array = unit_data->at<ArrayProperty>("Armor_10_12E266C44116DDAF57E99ABB575A4B3C");
|
|
|
|
|
|
|
|
auto part_prop = armour_array->at<GenericStructProperty>(index);
|
|
|
|
|
|
|
|
auto& part = _armour.parts[index];
|
|
|
|
|
|
|
|
if(part_prop->at<ByteProperty>("Slot_3_408BA56F4C9605C7E805CF91B642249C")->enumValue != part.slot) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
part_prop->at<IntProperty>("ID_5_ACD101864D3481DE96EDACACC09BDD25")->value = part.id;
|
|
|
|
|
|
|
|
auto part_styles = part_prop->at<ArrayProperty>("Styles_47_3E31870441DFD7DB8BEE5C85C26B365B");
|
|
|
|
for(UnsignedInt i = 0; i < part.styles.size(); i++) {
|
|
|
|
part_styles->at<IntProperty>(i)->value = part.styles[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
auto decals_array = part_prop->at<ArrayProperty>("Decals_42_F358794A4F18497970F56BA9627D3603");
|
|
|
|
for(UnsignedInt i = 0; i < decals_array->items.size(); i++) {
|
|
|
|
auto decal_prop = decals_array->at<GenericStructProperty>(i);
|
|
|
|
auto& decal = part.decals[i];
|
|
|
|
|
|
|
|
decal_prop->at<IntProperty>("ID_3_694C0B35404D8A3168AEC89026BC8CF9")->value = decal.id;
|
|
|
|
auto colour_prop = decal_prop->at<ColourStructProperty>("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606");
|
|
|
|
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<VectorStructProperty>("Position_41_022C8FE84E1AAFE587261E88F2C72250");
|
|
|
|
pos_prop->x = decal.position.x();
|
|
|
|
pos_prop->y = decal.position.y();
|
|
|
|
pos_prop->z = decal.position.z();
|
|
|
|
auto u_prop = decal_prop->at<VectorStructProperty>("UAxis_37_EBEB715F45491AECACCC07A1AE4646D1");
|
|
|
|
u_prop->x = decal.uAxis.x();
|
|
|
|
u_prop->y = decal.uAxis.y();
|
|
|
|
u_prop->z = decal.uAxis.z();
|
|
|
|
auto v_prop = decal_prop->at<VectorStructProperty>("VAxis_39_C31EB2664EE202CAECFBBB84100B5E35");
|
|
|
|
v_prop->x = decal.vAxis.x();
|
|
|
|
v_prop->y = decal.vAxis.y();
|
|
|
|
v_prop->z = decal.vAxis.z();
|
|
|
|
auto offset_prop = decal_prop->at<Vector2DStructProperty>("Offset_29_B02BBBB74FC60F5EDBEBAB8020738020");
|
|
|
|
offset_prop->x = decal.offset.x();
|
|
|
|
offset_prop->y = decal.offset.y();
|
|
|
|
decal_prop->at<FloatProperty>("Scale_32_959D1C2747AFD8D62808468235CBBA40")->value = decal.scale;
|
|
|
|
decal_prop->at<FloatProperty>("Rotation_27_12D7C314493D203D5C2326A03C5F910F")->value = decal.rotation;
|
|
|
|
decal_prop->at<BoolProperty>("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1")->value = decal.flip;
|
|
|
|
decal_prop->at<BoolProperty>("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62")->value = decal.wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!_demo) {
|
|
|
|
auto accs_array = part_prop->at<ArrayProperty>("Accessories_52_D902DD4241FA0050C2529596255153F3");
|
|
|
|
|
|
|
|
for(UnsignedInt i = 0; i < accs_array->items.size(); i++) {
|
|
|
|
auto acc_prop = accs_array->at<GenericStructProperty>(i);
|
|
|
|
|
|
|
|
auto& accessory = part.accessories[i];
|
|
|
|
|
|
|
|
acc_prop->at<IntProperty>("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20")->value = accessory.attachIndex;
|
|
|
|
acc_prop->at<IntProperty>("ID_4_5757B32647BAE263266259B8A7DFFFC1")->value = accessory.id;
|
|
|
|
auto acc_styles = acc_prop->at<ArrayProperty>("Styles_7_91DEB0F24E24D13FC9472882C11D0DFD");
|
|
|
|
for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) {
|
|
|
|
acc_styles->at<IntProperty>(j)->value = accessory.styles[j];
|
|
|
|
}
|
|
|
|
auto rel_pos_prop = acc_prop->at<VectorStructProperty>("RelativePosition_14_BE8FB2A94074F34B3EDA6683B227D3A1");
|
|
|
|
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<VectorStructProperty>("RelativePositionOffset_15_98FD0CE74E44BBAFC2D46FB4CA4E0ED6");
|
|
|
|
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<RotatorStructProperty>("RelativeRotation_20_C78C73274E6E78E7878F8C98ECA342C0");
|
|
|
|
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<RotatorStructProperty>("RelativeRotationOffset_21_E07FA0EC46728B7BA763C6861249ABAA");
|
|
|
|
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<VectorStructProperty>("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53");
|
|
|
|
local_scale_prop->x = accessory.localScale.x();
|
|
|
|
local_scale_prop->y = accessory.localScale.y();
|
|
|
|
local_scale_prop->z = accessory.localScale.z();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return _mass->saveToFile();
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::armourCustomStyles() -> Containers::ArrayView<CustomStyle> {
|
2021-10-02 14:52:48 +02:00
|
|
|
return _armour.customStyles;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getArmourCustomStyles() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto armour_styles = unit_data->at<ArrayProperty>("ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E");
|
|
|
|
if(!armour_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
if(armour_styles->items.size() != _armour.customStyles.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:28:54 +02:00
|
|
|
getCustomStyles(_armour.customStyles, armour_styles);
|
2021-10-04 18:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool {
|
2021-10-02 14:52:48 +02:00
|
|
|
if(index > _armour.customStyles.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:52:57 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto armour_styles = unit_data->at<ArrayProperty>("ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E");
|
|
|
|
if(!armour_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return setCustomStyle(_armour.customStyles[index], index, armour_styles);
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::meleeWeapons() -> Containers::ArrayView<Weapon> {
|
2021-10-17 08:37:12 +02:00
|
|
|
return _weapons.melee;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getMeleeWeapons() {
|
|
|
|
getWeaponType("WeaponCC_22_0BBEC58C4A0EA1DB9E037B9339EE26A7", _weapons.melee);
|
|
|
|
}
|
|
|
|
|
2021-10-29 10:23:34 +02:00
|
|
|
auto Mass::writeMeleeWeapons() -> bool {
|
|
|
|
return writeWeaponType("WeaponCC_22_0BBEC58C4A0EA1DB9E037B9339EE26A7", _weapons.melee);
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::shields() -> Containers::ArrayView<Weapon> {
|
2021-10-17 08:37:12 +02:00
|
|
|
return _weapons.shields;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getShields() {
|
|
|
|
getWeaponType("Shield_53_839BFD7945481BAEA3E43A9C5CA8E92E", _weapons.shields);
|
|
|
|
}
|
|
|
|
|
2021-10-29 10:23:34 +02:00
|
|
|
auto Mass::writeShields() -> bool {
|
|
|
|
return writeWeaponType("Shield_53_839BFD7945481BAEA3E43A9C5CA8E92E", _weapons.shields);
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::bulletShooters() -> Containers::ArrayView<Weapon> {
|
2021-10-17 08:37:12 +02:00
|
|
|
return _weapons.bulletShooters;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getBulletShooters() {
|
|
|
|
getWeaponType("WeaponBS_35_6EF6E0104FD7A138DF47F88CB57A83ED", _weapons.bulletShooters);
|
|
|
|
}
|
|
|
|
|
2021-10-29 10:23:34 +02:00
|
|
|
auto Mass::writeBulletShooters() -> bool {
|
|
|
|
return writeWeaponType("WeaponBS_35_6EF6E0104FD7A138DF47F88CB57A83ED", _weapons.bulletShooters);
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::energyShooters() -> Containers::ArrayView<Weapon> {
|
2021-10-17 08:37:12 +02:00
|
|
|
return _weapons.energyShooters;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getEnergyShooters() {
|
|
|
|
getWeaponType("WeaponES_37_1A295D544528623880A0B1AC2C7DEE99", _weapons.energyShooters);
|
|
|
|
}
|
|
|
|
|
2021-10-29 10:23:34 +02:00
|
|
|
auto Mass::writeEnergyShooters() -> bool {
|
|
|
|
return writeWeaponType("WeaponES_37_1A295D544528623880A0B1AC2C7DEE99", _weapons.energyShooters);
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::bulletLaunchers() -> Containers::ArrayView<Weapon> {
|
2021-10-17 08:37:12 +02:00
|
|
|
return _weapons.bulletLaunchers;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getBulletLaunchers() {
|
|
|
|
getWeaponType("WeaponBL_36_5FD7C41E4613A75B44AB0E90B362846E", _weapons.bulletLaunchers);
|
|
|
|
}
|
|
|
|
|
2021-10-29 10:23:34 +02:00
|
|
|
auto Mass::writeBulletLaunchers() -> bool {
|
|
|
|
return writeWeaponType("WeaponBL_36_5FD7C41E4613A75B44AB0E90B362846E", _weapons.bulletLaunchers);
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::energyLaunchers() -> Containers::ArrayView<Weapon> {
|
2021-10-17 08:37:12 +02:00
|
|
|
return _weapons.energyLaunchers;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getEnergyLaunchers() {
|
|
|
|
getWeaponType("WeaponEL_38_9D23F3884ACA15902C9E6CA6E4995995", _weapons.energyLaunchers);
|
|
|
|
}
|
|
|
|
|
2021-10-29 10:23:34 +02:00
|
|
|
auto Mass::writeEnergyLaunchers() -> bool {
|
|
|
|
return writeWeaponType("WeaponEL_38_9D23F3884ACA15902C9E6CA6E4995995", _weapons.energyLaunchers);
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
auto Mass::globalStyles() -> Containers::ArrayView<CustomStyle> {
|
2021-10-02 14:52:48 +02:00
|
|
|
return _globalStyles;
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:18:53 +02:00
|
|
|
void Mass::getGlobalStyles() {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto global_styles = unit_data->at<ArrayProperty>("GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B");
|
|
|
|
if(!global_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:29:16 +02:00
|
|
|
if(global_styles->items.size() != _globalStyles.size()) {
|
2021-10-04 18:18:53 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:28:54 +02:00
|
|
|
getCustomStyles(_globalStyles, global_styles);
|
2021-10-04 18:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Mass::writeGlobalStyle(UnsignedLong index) -> bool {
|
2021-10-02 14:52:48 +02:00
|
|
|
if(index > _globalStyles.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:52:57 +02:00
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto global_styles = unit_data->at<ArrayProperty>("GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B");
|
|
|
|
if(!global_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return setCustomStyle(_globalStyles[index], index, global_styles);
|
2021-10-02 14:52:48 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:52:47 +02:00
|
|
|
auto Mass::updateSteamId(const std::string& steam_id) -> bool {
|
|
|
|
_steamId = steam_id;
|
2021-08-28 20:20:09 +02:00
|
|
|
|
2021-10-14 15:06:03 +02:00
|
|
|
auto account = _mass->at<StringProperty>("Account");
|
|
|
|
if(!account) {
|
2021-08-28 20:20:09 +02:00
|
|
|
_state = State::Invalid;
|
2021-09-27 17:52:47 +02:00
|
|
|
return false;
|
2021-08-28 20:20:09 +02:00
|
|
|
}
|
2021-09-27 17:52:47 +02:00
|
|
|
|
2021-10-14 15:06:03 +02:00
|
|
|
account->value = steam_id;
|
2021-09-27 17:52:47 +02:00
|
|
|
|
|
|
|
return _mass->saveToFile();
|
2021-08-28 20:20:09 +02:00
|
|
|
}
|
2021-10-02 14:52:48 +02:00
|
|
|
|
2021-10-17 15:28:54 +02:00
|
|
|
void Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array) {
|
|
|
|
for(UnsignedInt i = 0; i < style_array->items.size(); i++) {
|
|
|
|
auto style_prop = style_array->at<GenericStructProperty>(i);
|
|
|
|
auto& style = styles[i];
|
|
|
|
|
|
|
|
style.name = style_prop->at<StringProperty>("Name_27_1532115A46EF2B2FA283908DF561A86B")->value;
|
|
|
|
auto colour_prop = style_prop->at<ColourStructProperty>("Color_5_F0D383DF40474C9464AE48A0984A212E");
|
|
|
|
style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
|
|
|
|
style.metallic = style_prop->at<FloatProperty>("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value;
|
|
|
|
style.gloss = style_prop->at<FloatProperty>("Gloss_11_9769599842CC275A401C4282A236E240")->value;
|
|
|
|
style.glow = colour_prop->a == 0.0f ? false : true;
|
|
|
|
|
|
|
|
style.patternId = style_prop->at<IntProperty>("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value;
|
|
|
|
style.opacity = style_prop->at<FloatProperty>("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value;
|
|
|
|
style.offset = Vector2{
|
|
|
|
style_prop->at<FloatProperty>("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value,
|
|
|
|
style_prop->at<FloatProperty>("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value
|
|
|
|
};
|
|
|
|
style.rotation = style_prop->at<FloatProperty>("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value;
|
|
|
|
style.scale = style_prop->at<FloatProperty>("Scale_26_19DF0708409262183E1247B317137671")->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:52:57 +02:00
|
|
|
auto Mass::setCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool {
|
|
|
|
if(!style_array) {
|
2021-10-02 14:52:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:52:57 +02:00
|
|
|
auto style_prop = style_array->at<GenericStructProperty>(index);
|
2021-10-02 14:52:48 +02:00
|
|
|
|
|
|
|
style_prop->at<StringProperty>("Name_27_1532115A46EF2B2FA283908DF561A86B")->value = style.name;
|
|
|
|
auto colour_prop = style_prop->at<ColourStructProperty>("Color_5_F0D383DF40474C9464AE48A0984A212E");
|
|
|
|
colour_prop->r = style.colour.r();
|
|
|
|
colour_prop->g = style.colour.g();
|
|
|
|
colour_prop->b = style.colour.b();
|
|
|
|
colour_prop->a = style.glow ? 1.0f : 0.0f;
|
|
|
|
style_prop->at<FloatProperty>("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value = style.metallic;
|
|
|
|
style_prop->at<FloatProperty>("Gloss_11_9769599842CC275A401C4282A236E240")->value = style.gloss;
|
|
|
|
|
|
|
|
style_prop->at<IntProperty>("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value = style.patternId;
|
|
|
|
style_prop->at<FloatProperty>("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value = style.opacity;
|
|
|
|
style_prop->at<FloatProperty>("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value = style.offset.x();
|
|
|
|
style_prop->at<FloatProperty>("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value = style.offset.y();
|
|
|
|
style_prop->at<FloatProperty>("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value = style.rotation;
|
|
|
|
style_prop->at<FloatProperty>("Scale_26_19DF0708409262183E1247B317137671")->value = style.scale;
|
|
|
|
|
|
|
|
return _mass->saveToFile();
|
|
|
|
}
|
2021-10-17 08:37:12 +02:00
|
|
|
|
2021-10-18 14:53:35 +02:00
|
|
|
void Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) {
|
|
|
|
for(UnsignedInt i = 0; i < decal_array->items.size(); i++) {
|
|
|
|
auto decal_prop = decal_array->at<GenericStructProperty>(i);
|
|
|
|
auto& decal = decals[i];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array) {
|
|
|
|
for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) {
|
|
|
|
auto acc_prop = accessory_array->at<GenericStructProperty>(i);
|
|
|
|
auto& accessory = accessories[i];
|
|
|
|
|
|
|
|
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 j = 0; j < acc_styles->items.size(); j++) {
|
|
|
|
accessory.styles[j] = acc_styles->at<IntProperty>(j)->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};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 08:37:12 +02:00
|
|
|
void Mass::getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array) {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto prop = unit_data->at<ArrayProperty>(prop_name);
|
|
|
|
if(!prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prop->items.size() != weapon_array.size()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(UnsignedInt i = 0; i < weapon_array.size(); i++) {
|
|
|
|
auto weapon_prop = prop->at<GenericStructProperty>(i);
|
|
|
|
auto& weapon = weapon_array[i];
|
|
|
|
|
|
|
|
weapon.name = weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value;
|
|
|
|
weapon.type = weapon_prop->at<ByteProperty>("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue;
|
|
|
|
|
|
|
|
auto parts_prop = weapon_prop->at<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0");
|
|
|
|
weapon.parts = Containers::Array<WeaponPart>{ValueInit, parts_prop->items.size()};
|
|
|
|
|
|
|
|
for(UnsignedInt j = 0; j < parts_prop->items.size(); j++) {
|
|
|
|
auto part_prop = parts_prop->at<GenericStructProperty>(j);
|
|
|
|
auto& part = weapon.parts[j];
|
|
|
|
|
|
|
|
part.id = part_prop->at<IntProperty>("ID_2_A74D75434308158E5926178822DD28EE")->value;
|
|
|
|
|
|
|
|
auto part_styles = part_prop->at<ArrayProperty>("Styles_17_994C97C34A90667BE5B716BFD0B97588");
|
|
|
|
for(UnsignedInt k = 0; k < part_styles->items.size(); k++) {
|
|
|
|
part.styles[k] = part_styles->at<IntProperty>(k)->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto part_decals = part_prop->at<ArrayProperty>("Decals_13_8B81112B453D7230C0CDE982185E14F1");
|
2021-10-18 14:53:35 +02:00
|
|
|
if(part_decals->items.size() != part.decals.size()) {
|
2021-10-17 08:37:12 +02:00
|
|
|
_demo = true;
|
|
|
|
part.demoDecals = part_decals->items.size();
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:53:35 +02:00
|
|
|
getDecals(part.decals, part_decals);
|
2021-10-17 08:37:12 +02:00
|
|
|
|
|
|
|
if(!_demo) {
|
|
|
|
auto part_accs = part_prop->at<ArrayProperty>("Accessories_21_3878DE8B4ED0EA0DB725E98BCDC20E0C");
|
|
|
|
if(!part_accs) {
|
|
|
|
_demo = true;
|
2021-10-17 08:44:23 +02:00
|
|
|
continue;
|
2021-10-17 08:37:12 +02:00
|
|
|
}
|
|
|
|
|
2021-10-18 14:53:35 +02:00
|
|
|
if(part_accs->items.size() != part.accessories.size()) {
|
2021-10-17 08:44:23 +02:00
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:53:35 +02:00
|
|
|
getAccessories(part.accessories, part_accs);
|
2021-10-17 08:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 14:54:28 +02:00
|
|
|
|
|
|
|
auto custom_styles = weapon_prop->at<ArrayProperty>("Styles_10_8C3C82444B986AD7A99595AD4985912D");
|
|
|
|
if(!custom_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(custom_styles->items.size() != weapon.customStyles.size()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getCustomStyles(weapon.customStyles, custom_styles);
|
|
|
|
|
|
|
|
weapon.attached = weapon_prop->at<BoolProperty>("Attach_15_D00AABBD4AD6A04778D56D81E51927B3")->value;
|
|
|
|
weapon.damageType = weapon_prop->at<ByteProperty>("DamageType_18_E1FFA53540591A9087EC698117A65C83")->enumValue;
|
|
|
|
weapon.dualWield = weapon_prop->at<BoolProperty>("DualWield_20_B2EB2CEA4A6A233DC7575996B6DD1222")->value;
|
|
|
|
weapon.effectColourMode = weapon_prop->at<ByteProperty>("ColorEfxMode_24_D254BCF943E852BF9ADB8AAA8FD80014")->enumValue;
|
|
|
|
auto effect_colour = weapon_prop->at<ColourStructProperty>("ColorEfx_26_D921B62946C493E487455A831F4520AC");
|
|
|
|
weapon.effectColour = Color4{effect_colour->r, effect_colour->g, effect_colour->b, effect_colour->a};
|
2021-10-17 08:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-29 10:23:34 +02:00
|
|
|
|
|
|
|
auto Mass::writeWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool {
|
|
|
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
|
|
|
if(!unit_data) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto prop = unit_data->at<ArrayProperty>(prop_name);
|
|
|
|
if(!prop) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prop->items.size() != weapon_array.size()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(UnsignedInt i = 0; i < weapon_array.size(); i++) {
|
|
|
|
auto weapon_prop = prop->at<GenericStructProperty>(i);
|
|
|
|
auto& weapon = weapon_array[i];
|
|
|
|
|
|
|
|
weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value = weapon.name;
|
|
|
|
weapon_prop->at<ByteProperty>("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue = weapon.type;
|
|
|
|
|
|
|
|
auto parts_prop = weapon_prop->at<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0");
|
|
|
|
if(parts_prop->items.size() != weapon_array.size()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(UnsignedInt j = 0; j < parts_prop->items.size(); j++) {
|
|
|
|
auto part_prop = parts_prop->at<GenericStructProperty>(j);
|
|
|
|
auto& part = weapon.parts[j];
|
|
|
|
|
|
|
|
part_prop->at<IntProperty>("ID_2_A74D75434308158E5926178822DD28EE")->value = part.id;
|
|
|
|
|
|
|
|
auto part_styles = part_prop->at<ArrayProperty>("Styles_17_994C97C34A90667BE5B716BFD0B97588");
|
|
|
|
for(UnsignedInt k = 0; k < part_styles->items.size(); k++) {
|
|
|
|
part_styles->at<IntProperty>(k)->value = part.styles[k];
|
|
|
|
}
|
|
|
|
|
|
|
|
auto part_decals = part_prop->at<ArrayProperty>("Decals_13_8B81112B453D7230C0CDE982185E14F1");
|
|
|
|
for(UnsignedInt k = 0; k < part_decals->items.size(); k++) {
|
|
|
|
auto decal_prop = part_decals->at<GenericStructProperty>(k);
|
|
|
|
auto& decal = part.decals[k];
|
|
|
|
|
|
|
|
decal_prop->at<IntProperty>("ID_3_694C0B35404D8A3168AEC89026BC8CF9")->value = decal.id;
|
|
|
|
auto colour_prop = decal_prop->at<ColourStructProperty>("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606");
|
|
|
|
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<VectorStructProperty>("Position_41_022C8FE84E1AAFE587261E88F2C72250");
|
|
|
|
pos_prop->x = decal.position.x();
|
|
|
|
pos_prop->y = decal.position.y();
|
|
|
|
pos_prop->z = decal.position.z();
|
|
|
|
auto u_prop = decal_prop->at<VectorStructProperty>("UAxis_37_EBEB715F45491AECACCC07A1AE4646D1");
|
|
|
|
u_prop->x = decal.uAxis.x();
|
|
|
|
u_prop->y = decal.uAxis.y();
|
|
|
|
u_prop->z = decal.uAxis.z();
|
|
|
|
auto v_prop = decal_prop->at<VectorStructProperty>("VAxis_39_C31EB2664EE202CAECFBBB84100B5E35");
|
|
|
|
v_prop->x = decal.vAxis.x();
|
|
|
|
v_prop->y = decal.vAxis.y();
|
|
|
|
v_prop->z = decal.vAxis.z();
|
|
|
|
auto offset_prop = decal_prop->at<Vector2DStructProperty>("Offset_29_B02BBBB74FC60F5EDBEBAB8020738020");
|
|
|
|
offset_prop->x = decal.offset.x();
|
|
|
|
offset_prop->y = decal.offset.y();
|
|
|
|
decal_prop->at<FloatProperty>("Scale_32_959D1C2747AFD8D62808468235CBBA40")->value = decal.scale;
|
|
|
|
decal_prop->at<FloatProperty>("Rotation_27_12D7C314493D203D5C2326A03C5F910F")->value = decal.rotation;
|
|
|
|
decal_prop->at<BoolProperty>("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1")->value = decal.flip;
|
|
|
|
decal_prop->at<BoolProperty>("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62")->value = decal.wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!_demo) {
|
|
|
|
auto part_accs = part_prop->at<ArrayProperty>("Accessories_21_3878DE8B4ED0EA0DB725E98BCDC20E0C");
|
|
|
|
if(!part_accs) {
|
|
|
|
_demo = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(part_accs->items.size() != part.accessories.size()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
getAccessories(part.accessories, part_accs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto custom_styles = weapon_prop->at<ArrayProperty>("Styles_10_8C3C82444B986AD7A99595AD4985912D");
|
|
|
|
if(!custom_styles) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(custom_styles->items.size() != weapon.customStyles.size()) {
|
|
|
|
_state = State::Invalid;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(UnsignedInt j = 0; j < weapon.customStyles.size(); j++) {
|
|
|
|
setCustomStyle(weapon.customStyles[j], j, custom_styles);
|
|
|
|
}
|
|
|
|
|
|
|
|
weapon_prop->at<BoolProperty>("Attach_15_D00AABBD4AD6A04778D56D81E51927B3")->value = weapon.attached;
|
|
|
|
weapon_prop->at<ByteProperty>("DamageType_18_E1FFA53540591A9087EC698117A65C83")->enumValue = weapon.damageType;
|
|
|
|
weapon_prop->at<BoolProperty>("DualWield_20_B2EB2CEA4A6A233DC7575996B6DD1222")->value = weapon.dualWield;
|
|
|
|
weapon_prop->at<ByteProperty>("ColorEfxMode_24_D254BCF943E852BF9ADB8AAA8FD80014")->enumValue = weapon.effectColourMode;
|
|
|
|
auto effect_colour = weapon_prop->at<ColourStructProperty>("ColorEfx_26_D921B62946C493E487455A831F4520AC");
|
|
|
|
effect_colour->r = weapon.effectColour.r();
|
|
|
|
effect_colour->g = weapon.effectColour.g();
|
|
|
|
effect_colour->b = weapon.effectColour.b();
|
|
|
|
effect_colour->a = weapon.effectColour.a();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _mass->saveToFile();
|
|
|
|
}
|