-
Notifications
You must be signed in to change notification settings - Fork 3
/
onHitEventHandler.h
47 lines (36 loc) · 1.23 KB
/
onHitEventHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
using EventResult = RE::BSEventNotifyControl;
class onHitEventHandler : public RE::BSTEventSink<RE::TESHitEvent>
{
public:
virtual EventResult ProcessEvent(const RE::TESHitEvent* a_event, RE::BSTEventSource<RE::TESHitEvent>* a_eventSource);
static bool Register()
{
static onHitEventHandler singleton;
auto ScriptEventSource = RE::ScriptEventSourceHolder::GetSingleton();
if (!ScriptEventSource) {
ERROR("Script event source not found");
return false;
}
ScriptEventSource->AddEventSink(&singleton);
logger::info("Register {}.", typeid(singleton).name());
return true;
}
private:
inline void processMeleeHit(const RE::TESHitEvent* a_event, RE::Actor* hitter, RE::TESObjectWEAP* weapon);
onHitEventHandler() = default;
~onHitEventHandler() = default;
onHitEventHandler(const onHitEventHandler&) = delete;
onHitEventHandler(onHitEventHandler&&) = delete;
onHitEventHandler& operator=(const onHitEventHandler&) = delete;
onHitEventHandler& operator=(onHitEventHandler&&) = delete;
inline bool isObject(RE::TESObjectREFR* a_obj) {
if (a_obj->formType == RE::FormType::ActorCharacter) {
return false;
}
return true;
}
inline bool isAlive(RE::Actor* a_target) {
return !a_target->IsDead();
}
};