-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginComponent.cpp
More file actions
57 lines (44 loc) · 1.43 KB
/
PluginComponent.cpp
File metadata and controls
57 lines (44 loc) · 1.43 KB
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
48
49
50
51
52
53
54
55
56
57
#include "PluginComponent.h"
StringView PluginComponent::componentName() const {
return PLUGIN_NAME;
}
SemanticVersion PluginComponent::componentVersion() const {
return {PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_PATCH, PLUGIN_VERSION_TWEAK};
}
void PluginComponent::onLoad(ICore *c) {
core = c;
setAmxLookups(core);
}
void PluginComponent::onInit(IComponentList *components) {
pawnComponent = components->queryComponent<IPawnComponent>();
if (pawnComponent == nullptr) return;
pawnComponent->getEventDispatcher().addEventHandler(this);
setAmxFunctions(pawnComponent->getAmxFunctions());
setAmxLookups(components);
componentsLoad(core, components);
}
void PluginComponent::onAmxLoad(IPawnScript& script) {
pawn_natives::AmxLoad(script.GetAMX());
}
void PluginComponent::onAmxUnload(IPawnScript &script) {
/* Nothing to do */
}
void PluginComponent::onFree(IComponent *component) {
if (component == pawnComponent) {
pawnComponent = nullptr;
setAmxFunctions();
setAmxLookups();
}
}
void PluginComponent::reset() {
/* Nothing to do */
}
void PluginComponent::free() {
componentsUnload();
if (pawnComponent) pawnComponent->getEventDispatcher().removeEventHandler(this);
}
PluginComponent *PluginComponent::instance() {
static PluginComponent component;
return &component;
}
COMPONENT_ENTRY_POINT() { return PluginComponent::instance(); }