-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathangelbehaviour.h
More file actions
98 lines (68 loc) · 2.58 KB
/
angelbehaviour.h
File metadata and controls
98 lines (68 loc) · 2.58 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef ANGELBEHAVIOUR_H
#define ANGELBEHAVIOUR_H
#include "components/nativebehaviour.h"
class asIScriptObject;
class asIScriptFunction;
class AngelBehaviour : public NativeBehaviour {
A_PROPERTIES(
A_PROPERTYEX(string, script, AngelBehaviour::script, AngelBehaviour::setScript, "ReadOnly")
)
A_NOMETHODS()
public:
AngelBehaviour();
~AngelBehaviour();
std::string script() const;
void setScript(const std::string value);
asIScriptObject *scriptObject() const;
void setScriptObject(asIScriptObject *object);
asIScriptFunction *scriptStart() const;
asIScriptFunction *scriptUpdate() const;
void createObject();
public:
static void registerClassFactory(ObjectSystem *system);
static void unregisterClassFactory(ObjectSystem *system);
private:
friend class AngelSystem;
static void *construct() { return new AngelBehaviour(); }
void setScriptStart(asIScriptFunction *function);
void setScriptUpdate(asIScriptFunction *function);
const MetaObject *metaObject() const override;
VariantList saveData() const override;
void loadData(const VariantList &data) override;
void setType(const std::string &type) override;
void setSystem(ObjectSystem *system) override;
void scriptSlot();
void onReferenceDestroyed() override;
Variant readProperty(const MetaProperty &property) const;
void writeProperty(const MetaProperty &property, const Variant value);
void methodCallEvent(MethodCallEvent *event) override;
void subscribe(AngelBehaviour *observer, void *ptr);
void notifyObservers();
public:
static const MetaObject *metaClass() {
OBJECT_CHECK(AngelBehaviour)
static const MetaObject staticMetaData(
"AngelBehaviour",
NativeBehaviour::metaClass(),
&AngelBehaviour::construct,
reinterpret_cast<const MetaMethod::Table *>(expose_method<AngelBehaviour>::exec()),
reinterpret_cast<const MetaProperty::Table *>(expose_props_method<AngelBehaviour>::exec()),
reinterpret_cast<const MetaEnum::Table *>(expose_enum<AngelBehaviour>::exec())
);
return &staticMetaData;
}
protected:
std::string m_script;
struct PropertyFields {
Object *object;
void *address;
bool isObject;
bool isScript;
};
std::unordered_map<const char *, PropertyFields> m_propertyFields;
std::list<std::pair<AngelBehaviour *, void *>> m_obsevers;
asIScriptObject *m_object;
asIScriptFunction *m_start;
asIScriptFunction *m_update;
};
#endif // ANGELBEHAVIOUR_H