ChestFilter.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "ChestFilter.h"
  2. namespace cheat::game
  3. {
  4. ChestFilter::ChestFilter(game::Chest::ChestRarity rarity) : m_ItemType(Chest::ItemType::Chest), m_Rarity(rarity)
  5. { }
  6. ChestFilter::ChestFilter(game::Chest::ItemType itemType) : m_ItemType(itemType)
  7. { }
  8. ChestFilter::ChestFilter(game::Chest::ChestState state) : m_ItemType(Chest::ItemType::Chest), m_State(state)
  9. { }
  10. bool ChestFilter::IsValid(game::Entity* entity) const
  11. {
  12. if (!entity->isChest())
  13. return false;
  14. game::Chest* chest = reinterpret_cast<game::Chest*>(entity);
  15. return
  16. (!m_ItemType || chest->itemType() == *m_ItemType) &&
  17. (!m_Rarity || chest->chestRarity() == *m_Rarity);
  18. //(!m_State || chest->chestState() == *m_State);
  19. }
  20. ChestFilter operator+(ChestFilter lFilter, const ChestFilter& rFilter)
  21. {
  22. if (rFilter.m_ItemType != Chest::ItemType::Chest)
  23. return lFilter;
  24. lFilter.m_ItemType = Chest::ItemType::Chest;
  25. if (rFilter.m_Rarity)
  26. lFilter.m_Rarity = rFilter.m_Rarity;
  27. if (rFilter.m_State)
  28. lFilter.m_State = rFilter.m_State;
  29. return lFilter;
  30. }
  31. }