ksys/phys: Add RagdollControllerKeyList-Resource

This commit is contained in:
MonsterDruide1
2021-07-09 12:29:51 +02:00
parent e5e8804fa9
commit 3be9a6927d
4 changed files with 118 additions and 14 deletions
+2
View File
@@ -21,6 +21,8 @@ target_sources(uking PRIVATE
System/physDefines.h
System/physParamSet.cpp
System/physParamSet.h
System/physRagdollControllerKeyList.h
System/physRagdollControllerKeyList.cpp
System/physShapeParam.cpp
System/physShapeParam.h
)
@@ -0,0 +1,56 @@
#include "KingSystem/Physics/System/physRagdollControllerKeyList.h"
namespace ksys::phys {
RagdollControllerKeyList::RagdollControllerKey::RagdollControllerKey()
: key(sead::SafeString::cEmptyString, "key", this), hierarchy_gain(0, "hierarchy_gain", this),
velocity_damping(0, "velocity_damping", this),
acceleration_gain(0, "acceleration_gain", this), velocity_gain(0, "velocity_gain", this),
position_gain(0, "position_gain", this),
position_max_linear_velocity(0, "position_max_linear_velocity", this),
position_max_angular_velocity(0, "position_max_angular_velocity", this),
snap_gain(0, "snap_gain", this),
snap_max_linear_velocity(0, "snap_max_linear_velocity", this),
snap_max_angular_velocity(0, "snap_max_angular_velocity", this),
snap_max_linear_distance(0, "snap_max_linear_distance", this),
snap_max_angular_distance(0, "snap_max_angular_distance", this) {}
RagdollControllerKeyList::RagdollControllerKeyList() = default;
RagdollControllerKeyList::~RagdollControllerKeyList() {
buffer.freeBuffer();
}
RagdollControllerKeyList::RagdollControllerKey*
RagdollControllerKeyList::getControllerKeyByKey(const sead::SafeString& key) {
int buffer_size = buffer.size();
for (int i = 0; i < buffer_size; i++) {
if (buffer[i].key.ref() == key) {
return &buffer[i];
}
}
return nullptr;
}
bool RagdollControllerKeyList::parse_(u8* data, size_t actualFileSize, sead::Heap* heap) {
if (!data)
return false;
auto archive = agl::utl::ResParameterArchive(data);
auto key_list = agl::utl::getResParameterList(archive.getRootList(), "RagCtrlKeyList");
if (!key_list)
return false;
int key_count = key_list.getResParameterObjNum();
if (key_count == 0)
return false;
buffer.allocBufferAssert(key_count, heap);
for (int i = 0; i < key_count; i++) {
buffer[i].applyResParameterObj(key_list.getResParameterObj(i));
}
return true;
}
} // namespace ksys::phys
@@ -0,0 +1,46 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterObj.h>
#include <container/seadBuffer.h>
#include "KingSystem/Resource/resResource.h"
namespace ksys::phys {
class RagdollControllerKeyList : public ksys::res::Resource {
SEAD_RTTI_OVERRIDE(RagdollControllerKeyList, ksys::res::Resource)
struct RagdollControllerKey : public agl::utl::ParameterObj {
RagdollControllerKey();
agl::utl::Parameter<sead::SafeString> key;
agl::utl::Parameter<float> hierarchy_gain;
agl::utl::Parameter<float> velocity_damping;
agl::utl::Parameter<float> acceleration_gain;
agl::utl::Parameter<float> velocity_gain;
agl::utl::Parameter<float> position_gain;
agl::utl::Parameter<float> position_max_linear_velocity;
agl::utl::Parameter<float> position_max_angular_velocity;
agl::utl::Parameter<float> snap_gain;
agl::utl::Parameter<float> snap_max_linear_velocity;
agl::utl::Parameter<float> snap_max_angular_velocity;
agl::utl::Parameter<float> snap_max_linear_distance;
agl::utl::Parameter<float> snap_max_angular_distance;
};
KSYS_CHECK_SIZE_NX150(RagdollControllerKey, 0x1D8);
public:
RagdollControllerKeyList();
~RagdollControllerKeyList();
RagdollControllerKey* getControllerKeyByKey(const sead::SafeString& key);
private:
bool parse_(u8* data, size_t actualFileSize, sead::Heap* heap) override;
bool needsParse() const override { return true; }
sead::Buffer<RagdollControllerKey> buffer;
};
} // namespace ksys::phys