#include "GameDependencies.h" #include "DestroyableComponent.h" #include "Entity.h" #include // How a level object's config changes its DestroyableComponent, as the client's // LWODestroyableComponent::LoadConfigData (0x00c44cb0) and LoadDataFromTemplate (0x00c9f900) resolve it. class DestroyableLevelConfigTests : public GameDependenciesTest { protected: std::unique_ptr entity; void SetUp() override { SetUpDependencies(); entity = std::make_unique(1, info); } void TearDown() override { entity.reset(); TearDownDependencies(); } }; TEST_F(DestroyableLevelConfigTests, NoSetFactionKeepsTheTemplateFactions) { EXPECT_FALSE(DestroyableComponent::GetLevelFactions(*entity)); entity->SetVar(u"override_faction", true); EXPECT_FALSE(DestroyableComponent::GetLevelFactions(*entity)); } TEST_F(DestroyableLevelConfigTests, SetFactionWithoutOverrideFactionIsUsed) { entity->SetVar(u"set_faction", "6 "); EXPECT_EQ(DestroyableComponent::GetLevelFactions(*entity), std::vector{ 6 }); } TEST_F(DestroyableLevelConfigTests, SetFactionWithOverrideFactionTrueIsUsed) { entity->SetVar(u"set_faction", "4; 6"); entity->SetVar(u"override_faction", true); EXPECT_EQ(DestroyableComponent::GetLevelFactions(*entity), (std::vector{ 4, 6 })); } TEST_F(DestroyableLevelConfigTests, OverrideFactionFalseIgnoresSetFaction) { entity->SetVar(u"set_faction", "-1"); entity->SetVar(u"override_faction", false); EXPECT_FALSE(DestroyableComponent::GetLevelFactions(*entity)); } TEST_F(DestroyableLevelConfigTests, NoLootMatrixKeysKeepTheTemplateLootMatrix) { EXPECT_FALSE(DestroyableComponent::GetLevelLootMatrix(*entity)); entity->SetVar(u"smashable_loot_matrix_set", true); EXPECT_FALSE(DestroyableComponent::GetLevelLootMatrix(*entity)); } TEST_F(DestroyableLevelConfigTests, LootMatrixWithoutTheSetKeyIsUsed) { entity->SetVar(u"smashable_loot_matrix", 748); EXPECT_EQ(DestroyableComponent::GetLevelLootMatrix(*entity), 748); } TEST_F(DestroyableLevelConfigTests, LootMatrixWithTheSetKeyTrueIsUsed) { entity->SetVar(u"smashable_loot_matrix", 352); entity->SetVar(u"smashable_loot_matrix_set", true); EXPECT_EQ(DestroyableComponent::GetLevelLootMatrix(*entity), 352); } TEST_F(DestroyableLevelConfigTests, LootMatrixWithTheSetKeyFalseIsIgnored) { entity->SetVar(u"smashable_loot_matrix", 227); entity->SetVar(u"smashable_loot_matrix_set", false); EXPECT_FALSE(DestroyableComponent::GetLevelLootMatrix(*entity)); } TEST_F(DestroyableLevelConfigTests, LootMatrixMinusOneIsIgnored) { entity->SetVar(u"smashable_loot_matrix", -1); EXPECT_FALSE(DestroyableComponent::GetLevelLootMatrix(*entity)); entity->SetVar(u"smashable_loot_matrix_set", true); EXPECT_FALSE(DestroyableComponent::GetLevelLootMatrix(*entity)); }