diff --git a/include/RE/B/BGSKeywordForm.h b/include/RE/B/BGSKeywordForm.h index 3564293..66168e8 100644 --- a/include/RE/B/BGSKeywordForm.h +++ b/include/RE/B/BGSKeywordForm.h @@ -23,12 +23,14 @@ namespace RE void InitializeDataComponent() override; // 02 - { return; } // add - virtual BGSKeyword* GetDefaultKeyword() const; // 0B - + virtual BGSKeyword* GetDefaultKeyword() const; // 0B + bool AddKeyword(BGSKeyword* keyword); [[nodiscard]] bool ContainsKeywordString(std::string_view a_editorID); void ForEachKeyword(std::function a_callback); [[nodiscard]] std::uint32_t GetNumKeywords() const; + [[nodiscard]] bool HasKeyword(BGSKeyword* keyword) const; [[nodiscard]] bool HasKeywordString(std::string_view a_editorID); + bool RemoveKeyword(BGSKeyword* keyword); // members BSTArray formFolderKeywordLists; // 10 diff --git a/include/RE/B/BSTArray.h b/include/RE/B/BSTArray.h index ae7514d..b2ed670 100644 --- a/include/RE/B/BSTArray.h +++ b/include/RE/B/BSTArray.h @@ -182,6 +182,7 @@ namespace RE for (const auto& i : a_rhs) { emplace_back(i); } + return *this; } BSTArray& operator=(BSTArray&& a_rhs) diff --git a/src/RE/B/BGSKeywordForm.cpp b/src/RE/B/BGSKeywordForm.cpp index c62ecc1..64a95eb 100644 --- a/src/RE/B/BGSKeywordForm.cpp +++ b/src/RE/B/BGSKeywordForm.cpp @@ -4,6 +4,22 @@ namespace RE { + bool BGSKeywordForm::AddKeyword(BGSKeyword* keyword) + { + if (!keyword) { + return false; + } + + for (const auto& existing : keywords) { + if (existing == keyword) { + return false; + } + } + + keywords.push_back(keyword); + return true; + } + bool BGSKeywordForm::ContainsKeywordString(std::string_view a_editorID) { bool result{}; @@ -39,6 +55,33 @@ namespace RE return keywords.size(); } + bool BGSKeywordForm::HasKeyword(BGSKeyword* keyword) const + { + if (!keyword) { + return false; + } + + for (const auto& existing : keywords) { + if (existing == keyword) { + return true; + } + } + + for (const auto& formFolderKeywordList : formFolderKeywordLists) { + if (!formFolderKeywordList) { + continue; + } + + for (const auto& existing : formFolderKeywordList->keywords) { + if (existing == keyword) { + return true; + } + } + } + + return false; + } + bool BGSKeywordForm::HasKeywordString(std::string_view a_editorID) { bool result{}; @@ -50,4 +93,20 @@ namespace RE }); return result; } + + bool BGSKeywordForm::RemoveKeyword(BGSKeyword* keyword) + { + if (!keyword) { + return false; + } + + for (auto it = keywords.begin(); it != keywords.end(); ++it) { + if (*it == keyword) { + keywords.erase(it); + return true; + } + } + + return false; + } }