CommonLibSSE (Parapets fork)
InventoryChanges.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSSimpleList.h"
4 #include "RE/F/FormTypes.h"
6 #include "RE/M/MemoryManager.h"
7 #include "RE/T/TESBoundObject.h"
8 #include "RE/T/TESContainer.h"
9 #include "RE/T/TESObjectREFR.h"
10 
11 namespace RE
12 {
13  class ExtraDataList;
14  class InventoryEntryData;
15 
17  {
18  public:
19  enum class VisitResult : std::uint32_t
20  {
21  kStop = 0,
22  kContinue = 1,
23  };
24 
26  {
27  public:
28  inline static constexpr auto RTTI = RTTI_InventoryChanges__IItemChangeVisitor;
29 
30  virtual ~IItemChangeVisitor(); // 00
31 
32  // add
33  virtual VisitResult Visit(InventoryEntryData* a_entryData) = 0; // 01
34  virtual void Unk_02(RE::FormType a_formType); // 02 - { return 1; }
35  virtual void Unk_03(void); // 03
36  };
37  static_assert(sizeof(IItemChangeVisitor) == 0x8);
38 
40  explicit InventoryChanges(TESObjectREFR* a_ref);
42 
44 #ifndef SKYRIMVR
45  TESObjectARMO* GetArmorInSlot(std::int32_t a_slot);
46 #endif
47  std::uint16_t GetNextUniqueID();
48  RE::ExtraDataList* EnchantObject(RE::TESBoundObject* a_obj, RE::ExtraDataList* a_extraList, RE::EnchantmentItem* a_enchantment, uint16_t a_charge);
51  void InitScripts();
52  void SendContainerChangedEvent(ExtraDataList* a_itemExtraList, TESObjectREFR* a_fromRefr, TESForm* a_item, std::int32_t a_count);
53  void SetUniqueID(ExtraDataList* a_itemList, TESForm* a_oldForm, TESForm* a_newForm);
54 
55  [[nodiscard]] std::int32_t GetCount(const TESBoundObject* a_object, std::predicate<const InventoryEntryData*> auto a_itemFilter) const
56  {
57  const auto container = owner ? owner->GetContainer() : nullptr;
58  std::int32_t count = container ? std::abs(container->GetObjectCount(a_object)) : 0;
59 
60  if (entryList) {
61  const InventoryEntryData* objEntry = nullptr;
62  for (const auto* const entry : *entryList) {
63  if (entry && entry->object == a_object) {
64  objEntry = entry;
65  break;
66  }
67  }
68 
69  if (objEntry) {
70  if (a_itemFilter(objEntry)) {
71  count += objEntry->countDelta;
72  }
73  }
74  }
75 
76  return count;
77  }
78 
80 
81  // members
83  TESObjectREFR* owner{ nullptr }; // 08
84  float totalWeight{ 0.0F }; // 10
85  float armorWeight{ 0.0F }; // 14
86  bool changed{ false }; // 18
87  std::uint8_t unk19{ 0 }; // 19
88  std::uint8_t unk1A{ 0 }; // 1A
89  std::uint8_t unk1B{ 0 }; // 1B
90  std::uint32_t unk1C{ 0 }; // 1C
91 
92  private:
93  InventoryChanges* Ctor(TESObjectREFR* a_ref);
94  void Dtor();
95  };
96  static_assert(sizeof(InventoryChanges) == 0x20);
97 }
Definition: BSSimpleList.h:10
Definition: EnchantmentItem.h:10
Definition: ExtraDataList.h:50
Definition: InventoryChanges.h:26
virtual void Unk_02(RE::FormType a_formType)
virtual VisitResult Visit(InventoryEntryData *a_entryData)=0
static constexpr auto RTTI
Definition: InventoryChanges.h:28
Definition: InventoryChanges.h:17
VisitResult
Definition: InventoryChanges.h:20
void SetUniqueID(ExtraDataList *a_itemList, TESForm *a_oldForm, TESForm *a_newForm)
void AddEntryData(InventoryEntryData *a_entry)
std::int32_t GetCount(const TESBoundObject *a_object, std::predicate< const InventoryEntryData * > auto a_itemFilter) const
Definition: InventoryChanges.h:55
std::uint16_t GetNextUniqueID()
float totalWeight
Definition: InventoryChanges.h:84
TESObjectARMO * GetArmorInSlot(std::int32_t a_slot)
std::uint8_t unk19
Definition: InventoryChanges.h:87
std::uint32_t unk1C
Definition: InventoryChanges.h:90
float armorWeight
Definition: InventoryChanges.h:85
TESObjectREFR * owner
Definition: InventoryChanges.h:83
bool changed
Definition: InventoryChanges.h:86
std::uint8_t unk1B
Definition: InventoryChanges.h:89
RE::ExtraDataList * EnchantObject(RE::TESBoundObject *a_obj, RE::ExtraDataList *a_extraList, RE::EnchantmentItem *a_enchantment, uint16_t a_charge)
void SendContainerChangedEvent(ExtraDataList *a_itemExtraList, TESObjectREFR *a_fromRefr, TESForm *a_item, std::int32_t a_count)
BSSimpleList< InventoryEntryData * > * entryList
Definition: InventoryChanges.h:82
std::uint8_t unk1A
Definition: InventoryChanges.h:88
InventoryChanges(TESObjectREFR *a_ref)
Definition: InventoryEntryData.h:14
std::int32_t countDelta
Definition: InventoryEntryData.h:59
Definition: TESBoundObject.h:24
Definition: TESForm.h:34
Definition: TESObjectARMO.h:37
Definition: TESObjectREFR.h:105
TESContainer * GetContainer() const
Definition: AbsorbEffect.h:6
constexpr REL::ID RTTI_InventoryChanges__IItemChangeVisitor
Definition: Offsets_RTTI.h:5071
FormType
Definition: FormTypes.h:139