2023-08-31 21:54:25 +08:00
|
|
|
#include "CKSceneObject.hpp"
|
|
|
|
#include "../CKStateChunk.hpp"
|
2023-09-06 10:42:23 +08:00
|
|
|
#include "../CKContext.hpp"
|
|
|
|
#include "../MgrImpls/CKObjectManager.hpp"
|
2023-08-31 21:54:25 +08:00
|
|
|
#include "CKBeObject.hpp"
|
2023-09-01 13:27:46 +08:00
|
|
|
#include "CKGroup.hpp"
|
2023-08-31 21:54:25 +08:00
|
|
|
|
|
|
|
namespace LibCmo::CK2::ObjImpls {
|
|
|
|
|
2023-09-06 10:42:23 +08:00
|
|
|
CKBeObject::CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name) :
|
|
|
|
CKSceneObject(ctx, ckid, name) {}
|
|
|
|
|
|
|
|
CKBeObject::~CKBeObject() {
|
|
|
|
// remove self from all group
|
|
|
|
for (size_t i = 0; i < m_Groups.size(); ++i) {
|
|
|
|
if (m_Groups[i]) {
|
|
|
|
CKGroup* group = static_cast<CKGroup*>(m_Context->GetObjectManager()->GetGroupByGlobalIndex(static_cast<CKDWORD>(i)));
|
|
|
|
group->RemoveObject(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-31 21:54:25 +08:00
|
|
|
bool CKBeObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) {
|
|
|
|
bool suc = CKSceneObject::Save(chunk, file, flags);
|
|
|
|
if (!suc) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CKBeObject::Load(CKStateChunk* chunk, CKFileVisitor* file) {
|
|
|
|
bool suc = CKSceneObject::Load(chunk, file);
|
|
|
|
if (!suc) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CKBeObject::IsInGroup(CKGroup* group) {
|
2023-09-01 13:27:46 +08:00
|
|
|
if (group == nullptr) return false;
|
|
|
|
CKDWORD idx = group->CKBeObject_GetGroupIndex();
|
|
|
|
if (idx >= m_Groups.size()) return false;
|
|
|
|
return m_Groups[idx];
|
2023-08-31 21:54:25 +08:00
|
|
|
}
|
|
|
|
|
2023-09-01 12:19:06 +08:00
|
|
|
void CKBeObject::CKGroup_SetGroups(CKDWORD pos, bool val) {
|
|
|
|
if (pos >= m_Groups.size()) m_Groups.resize(pos + 1);
|
|
|
|
m_Groups[pos] = val;
|
|
|
|
}
|
|
|
|
|
2023-08-31 21:54:25 +08:00
|
|
|
}
|