DarkflameServer/dDatabase/Tables/CDPhysicsComponentTable.cpp

50 lines
1.6 KiB
C++
Raw Normal View History

#include "CDPhysicsComponentTable.h"
CDPhysicsComponentTable::CDPhysicsComponentTable(void) {
2022-07-28 13:39:57 +00:00
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
while (!tableData.eof()) {
CDPhysicsComponent* entry = new CDPhysicsComponent();
2022-07-28 13:39:57 +00:00
entry->id = tableData.getIntField(0, -1);
entry->bStatic = tableData.getIntField(1, -1) != 0;
entry->physicsAsset = tableData.getStringField(2, "");
UNUSED(entry->jump = tableData.getIntField(3, -1) != 0);
UNUSED(entry->doublejump = tableData.getIntField(4, -1) != 0);
entry->speed = tableData.getFloatField(5, -1);
UNUSED(entry->rotSpeed = tableData.getFloatField(6, -1));
entry->playerHeight = tableData.getFloatField(7);
entry->playerRadius = tableData.getFloatField(8);
entry->pcShapeType = tableData.getIntField(9);
entry->collisionGroup = tableData.getIntField(10);
UNUSED(entry->airSpeed = tableData.getFloatField(11));
UNUSED(entry->boundaryAsset = tableData.getStringField(12));
UNUSED(entry->jumpAirSpeed = tableData.getFloatField(13));
UNUSED(entry->friction = tableData.getFloatField(14));
UNUSED(entry->gravityVolumeAsset = tableData.getStringField(15));
m_entries.insert(std::make_pair(entry->id, entry));
2022-07-28 13:39:57 +00:00
tableData.nextRow();
}
tableData.finalize();
}
CDPhysicsComponentTable::~CDPhysicsComponentTable(void) {
2022-07-28 13:39:57 +00:00
for (auto e : m_entries) {
if (e.second) delete e.second;
}
m_entries.clear();
}
std::string CDPhysicsComponentTable::GetName(void) const {
2022-07-28 13:39:57 +00:00
return "PhysicsComponent";
}
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
2022-07-28 13:39:57 +00:00
for (auto e : m_entries) {
if (e.first == componentID) return e.second;
2022-07-28 13:39:57 +00:00
}
return nullptr;
}