CommonLibVR
ScriptEventSourceHolder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSTEvent.h"
4 #include "RE/N/NiSmartPointer.h"
5 
6 namespace RE
7 {
8  class TESObjectREFR;
9  struct BGSEventProcessedEvent;
10  struct TESActivateEvent;
11  struct TESActiveEffectApplyRemoveEvent;
12  struct TESActorLocationChangeEvent;
13  struct TESBookReadEvent;
14  struct TESCellAttachDetachEvent;
15  struct TESCellFullyLoadedEvent;
16  struct TESCellReadyToApplyDecalsEvent;
17  struct TESCombatEvent;
18  struct TESContainerChangedEvent;
19  struct TESDeathEvent;
20  struct TESDestructionStageChangedEvent;
21  struct TESEnterBleedoutEvent;
22  struct TESEquipEvent;
23  struct TESFastTravelEndEvent;
24  struct TESFormDeleteEvent;
25  struct TESFurnitureEvent;
26  struct TESGrabReleaseEvent;
27  struct TESHitEvent;
28  struct TESInitScriptEvent;
29  struct TESLoadGameEvent;
30  struct TESLockChangedEvent;
31  struct TESMagicEffectApplyEvent;
32  struct TESMagicWardHitEvent;
33  struct TESMoveAttachDetachEvent;
34  struct TESObjectLoadedEvent;
35  struct TESObjectREFRTranslationEvent;
36  struct TESOpenCloseEvent;
37  struct TESPackageEvent;
38  struct TESPerkEntryRunEvent;
39  struct TESPlayerBowShotEvent;
40  struct TESQuestInitEvent;
41  struct TESQuestStageEvent;
42  struct TESQuestStageItemDoneEvent;
43  struct TESQuestStartStopEvent;
44  struct TESResetEvent;
45  struct TESResolveNPCTemplatesEvent;
46  struct TESSceneActionEvent;
47  struct TESSceneEvent;
48  struct TESScenePhaseEvent;
49  struct TESSellEvent;
50  struct TESSleepStartEvent;
51  struct TESSleepStopEvent;
52  struct TESSpellCastEvent;
53  struct TESSwitchRaceCompleteEvent;
54  struct TESTopicInfoEvent;
55  struct TESTrackedStatsEvent;
56  struct TESTrapHitEvent;
57  struct TESTriggerEnterEvent;
58  struct TESTriggerEvent;
59  struct TESTriggerLeaveEvent;
60  struct TESUniqueIDChangeEvent;
61  struct TESWaitStartEvent;
62  struct TESWaitStopEvent;
63 
65  public BSTEventSource<BGSEventProcessedEvent>, // 0000
66  public BSTEventSource<TESActivateEvent>, // 0058
67  public BSTEventSource<TESActiveEffectApplyRemoveEvent>, // 00B0
68  public BSTEventSource<TESActorLocationChangeEvent>, // 0108
69  public BSTEventSource<TESBookReadEvent>, // 0160
70  public BSTEventSource<TESCellAttachDetachEvent>, // 01B8
71  public BSTEventSource<TESCellFullyLoadedEvent>, // 0210
72  public BSTEventSource<TESCellReadyToApplyDecalsEvent>, // 0268
73  public BSTEventSource<TESCombatEvent>, // 02C0
74  public BSTEventSource<TESContainerChangedEvent>, // 0318
75  public BSTEventSource<TESDeathEvent>, // 0370
76  public BSTEventSource<TESDestructionStageChangedEvent>, // 03C8
77  public BSTEventSource<TESEnterBleedoutEvent>, // 0420
78  public BSTEventSource<TESEquipEvent>, // 0478
79  public BSTEventSource<TESFormDeleteEvent>, // 04D0
80  public BSTEventSource<TESFurnitureEvent>, // 0528
81  public BSTEventSource<TESGrabReleaseEvent>, // 0580
82  public BSTEventSource<TESHitEvent>, // 05D8
83  public BSTEventSource<TESInitScriptEvent>, // 0630
84  public BSTEventSource<TESLoadGameEvent>, // 0688
85  public BSTEventSource<TESLockChangedEvent>, // 06E0
86  public BSTEventSource<TESMagicEffectApplyEvent>, // 0738
87  public BSTEventSource<TESMagicWardHitEvent>, // 0790
88  public BSTEventSource<TESMoveAttachDetachEvent>, // 07E8
89  public BSTEventSource<TESObjectLoadedEvent>, // 0840
90  public BSTEventSource<TESObjectREFRTranslationEvent>, // 0898
91  public BSTEventSource<TESOpenCloseEvent>, // 08F0
92  public BSTEventSource<TESPackageEvent>, // 0948
93  public BSTEventSource<TESPerkEntryRunEvent>, // 09A0
94  public BSTEventSource<TESQuestInitEvent>, // 09F8
95  public BSTEventSource<TESQuestStageEvent>, // 0A50
96  public BSTEventSource<TESQuestStageItemDoneEvent>, // 0AA8
97  public BSTEventSource<TESQuestStartStopEvent>, // 0B00
98  public BSTEventSource<TESResetEvent>, // 0B58
99  public BSTEventSource<TESResolveNPCTemplatesEvent>, // 0BB0
100  public BSTEventSource<TESSceneEvent>, // 0C08
101  public BSTEventSource<TESSceneActionEvent>, // 0C60
102  public BSTEventSource<TESScenePhaseEvent>, // 0CB8
103  public BSTEventSource<TESSellEvent>, // 0D10
104  public BSTEventSource<TESSleepStartEvent>, // 0D68
105  public BSTEventSource<TESSleepStopEvent>, // 0DC0
106  public BSTEventSource<TESSpellCastEvent>, // 0E18
107  public BSTEventSource<TESPlayerBowShotEvent>, // 0E70
108  public BSTEventSource<TESTopicInfoEvent>, // 0EC8
109  public BSTEventSource<TESTrackedStatsEvent>, // 0F20
110  public BSTEventSource<TESTrapHitEvent>, // 0F78
111  public BSTEventSource<TESTriggerEvent>, // 0FD0
112  public BSTEventSource<TESTriggerEnterEvent>, // 1028
113  public BSTEventSource<TESTriggerLeaveEvent>, // 1080
114  public BSTEventSource<TESUniqueIDChangeEvent>, // 10D8
115  public BSTEventSource<TESWaitStartEvent>, // 1130 - ?
116  public BSTEventSource<TESWaitStopEvent>, // 1188 - ?
117 #ifndef SKYRIMVR
118  public BSTEventSource<TESSwitchRaceCompleteEvent>, // 11E0
119  public BSTEventSource<TESFastTravelEndEvent> // 1238
120 #else
121  public BSTEventSource<TESSwitchRaceCompleteEvent> // 11E0 // VR ends here
122 #endif
123  {
124  public:
126 
127 #ifdef SKYRIMVR
128  void SendActivateEvent(const NiPointer<TESObjectREFR>& a_objectActivated, const NiPointer<TESObjectREFR>& a_actionRef);
129 #endif
130  void SendOpenCloseEvent(const NiPointer<TESObjectREFR>& a_ref, const NiPointer<TESObjectREFR>& a_activeRef, bool a_isOpened);
131  void SendSpellCastEvent(const NiPointer<TESObjectREFR>& a_object, FormID a_formID);
132 
133  template <class T>
135  {
136  return static_cast<BSTEventSource<T>*>(this);
137  }
138 
139  template <class T>
140  inline void AddEventSink(BSTEventSink<T>* a_sink)
141  {
142  GetEventSource<T>()->AddEventSink(a_sink);
143  }
144 
145  template <class T>
146  inline void RemoveEventSink(BSTEventSink<T>* a_sink)
147  {
148  GetEventSource<T>()->RemoveEventSink(a_sink);
149  }
150 
151  template <class T>
152  inline void SendEvent(const T* a_event)
153  {
154  GetEventSource<T>()->SendEvent(a_event);
155  }
156 
157  private:
158  KEEP_FOR_RE()
159  };
160 #ifndef SKYRIMVR
161  static_assert(sizeof(ScriptEventSourceHolder) == 0x1290);
162 #else
163  static_assert(sizeof(ScriptEventSourceHolder) == 0x1238);
164 #endif
165 }
#define KEEP_FOR_RE()
Definition: PCH.h:713
Definition: BSTEvent.h:143
Definition: BSTEvent.h:19
Definition: NiSmartPointer.h:9
Definition: ScriptEventSourceHolder.h:123
void SendEvent(const T *a_event)
Definition: ScriptEventSourceHolder.h:152
void SendOpenCloseEvent(const NiPointer< TESObjectREFR > &a_ref, const NiPointer< TESObjectREFR > &a_activeRef, bool a_isOpened)
static ScriptEventSourceHolder * GetSingleton()
void SendSpellCastEvent(const NiPointer< TESObjectREFR > &a_object, FormID a_formID)
BSTEventSource< T > * GetEventSource()
Definition: ScriptEventSourceHolder.h:134
void AddEventSink(BSTEventSink< T > *a_sink)
Definition: ScriptEventSourceHolder.h:140
void RemoveEventSink(BSTEventSink< T > *a_sink)
Definition: ScriptEventSourceHolder.h:146
constexpr REL::Offset SendActivateEvent(static_cast< std::uint64_t >(0x2B37E0))
Definition: AbsorbEffect.h:6
std::uint32_t FormID
Definition: BSCoreTypes.h:5