CommonLibVR
TESContainer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSContainer.h"
6 
7 #include "RE/M/MemoryManager.h"
8 
9 namespace RE
10 {
11  class TESBoundObject;
12 
14  {
15  public:
17  ContainerObject(TESBoundObject* a_obj, std::int32_t a_count);
18  ContainerObject(TESBoundObject* a_obj, std::int32_t a_count, TESForm* a_owner);
19 
20  ~ContainerObject() = default;
21 
23 
24  // members
25  std::int32_t count; // 00 - CNTO~
26  std::uint32_t pad04; // 04
27  TESBoundObject* obj; // 08 - ~CNTO
29  };
30  static_assert(sizeof(ContainerObject) == 0x18);
31 
33  {
34  public:
35  inline static constexpr auto RTTI = RTTI_TESContainer;
36  inline static constexpr auto VTABLE = VTABLE_TESContainer;
37 
38  ~TESContainer() override; // 00
39 
40  // override (BaseFormComponent)
41  void InitializeDataComponent() override; // 01 - { return; }
42  void ClearDataComponent() override; // 02
43  void CopyComponent(BaseFormComponent* a_rhs) override; // 03
44 
45  inline void ForEachContainerObject(std::function<BSContainer::ForEachResult(ContainerObject&)> a_fn) const
46  {
47  for (std::uint32_t i = 0; i < numContainerObjects; ++i) {
48  auto entry = containerObjects[i];
49  if (entry) {
50  if (a_fn(*entry) == BSContainer::ForEachResult::kStop) {
51  break;
52  }
53  }
54  }
55  }
56 
57  std::optional<ContainerObject*> GetContainerObjectAt(std::uint32_t a_idx) const;
58  std::optional<std::uint32_t> GetContainerObjectIndex(TESBoundObject* a_object, std::int32_t a_count) const;
59  bool AddObjectToContainer(TESBoundObject* a_object, std::int32_t a_count, TESForm* a_owner);
60  bool AddObjectsToContainer(std::map<TESBoundObject*, std::int32_t>& a_objects, TESForm* a_owner);
61  std::int32_t CountObjectsInContainer(TESBoundObject* a_object) const;
62  bool RemoveObjectFromContainer(TESBoundObject* a_object, std::int32_t a_count);
63 
64  // members
66  std::uint32_t numContainerObjects; // 10
67  bool allowStolenItems; // 14 - new in 1.6.1130
68 
69  private:
70  void CopyObjectList(const std::vector<ContainerObject*>& a_copiedData);
71 
72  private:
73  KEEP_FOR_RE()
74  };
75  static_assert(sizeof(TESContainer) == 0x18);
76 }
#define KEEP_FOR_RE()
Definition: PCH.h:713
Definition: BaseFormComponent.h:8
Definition: TESBoundObject.h:26
Definition: TESContainer.h:33
static constexpr auto RTTI
Definition: TESContainer.h:35
void ClearDataComponent() override
void CopyComponent(BaseFormComponent *a_rhs) override
bool RemoveObjectFromContainer(TESBoundObject *a_object, std::int32_t a_count)
bool AddObjectsToContainer(std::map< TESBoundObject *, std::int32_t > &a_objects, TESForm *a_owner)
bool allowStolenItems
Definition: TESContainer.h:67
static constexpr auto VTABLE
Definition: TESContainer.h:36
std::uint32_t numContainerObjects
Definition: TESContainer.h:66
std::optional< ContainerObject * > GetContainerObjectAt(std::uint32_t a_idx) const
std::int32_t CountObjectsInContainer(TESBoundObject *a_object) const
~TESContainer() override
void ForEachContainerObject(std::function< BSContainer::ForEachResult(ContainerObject &)> a_fn) const
Definition: TESContainer.h:45
ContainerObject ** containerObjects
Definition: TESContainer.h:65
bool AddObjectToContainer(TESBoundObject *a_object, std::int32_t a_count, TESForm *a_owner)
std::optional< std::uint32_t > GetContainerObjectIndex(TESBoundObject *a_object, std::int32_t a_count) const
void InitializeDataComponent() override
Definition: TESForm.h:40
ForEachResult
Definition: BSContainer.h:6
Definition: AbsorbEffect.h:6
constexpr REL::ID RTTI_TESContainer(static_cast< std::uint64_t >(513941))
constexpr std::array< REL::ID, 1 > VTABLE_TESContainer
Definition: Offsets_VTABLE.h:12815
Definition: ContainerItemExtra.h:11
Definition: TESContainer.h:14
~ContainerObject()=default
std::int32_t count
Definition: TESContainer.h:25
ContainerItemExtra * itemExtra
Definition: TESContainer.h:28
ContainerObject(TESBoundObject *a_obj, std::int32_t a_count, TESForm *a_owner)
std::uint32_t pad04
Definition: TESContainer.h:26
TESBoundObject * obj
Definition: TESContainer.h:27
ContainerObject(TESBoundObject *a_obj, std::int32_t a_count)