forked from FabianTerhorst/cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIResource.h
More file actions
80 lines (66 loc) · 1.64 KB
/
IResource.h
File metadata and controls
80 lines (66 loc) · 1.64 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
#pragma once
#include "types/StringView.h"
#include "types/String.h"
#include "types/MValue.h"
#include "types/MValueList.h"
#include "types/MValueDict.h"
namespace alt
{
class IPackage;
class CEvent;
class IResource
{
public:
enum class State
{
STOPPED,
INSTANTIATING,
STARTED
};
struct CreationInfo
{
String type;
String name;
String path;
String main;
Array<String> deps;
IPackage* pkg;
};
virtual ~IResource() = default;
State GetState() const { return state; }
bool IsStarted() const { return state == State::STARTED; }
StringView GetType() const { return type; }
StringView GetName() const { return name; }
StringView GetPath() const { return path; }
StringView GetMain() const { return main; }
IPackage* GetPackage() const { return pkg; }
MValueDict GetExports() { return exports; }
#ifdef ALT_SERVER_API
virtual void MakeClient(CreationInfo* info, Array<String> files) { };
#endif
virtual bool Instantiate() { state = State::INSTANTIATING; return true; }
virtual bool Start() { state = State::STARTED; return true; };
virtual bool Stop() { state = State::STOPPED; return true; };
virtual bool OnEvent(const CEvent* ev) { return true; };
virtual void OnTick() { };
virtual void OnCreateBaseObject(IBaseObject* object) { };
virtual void OnRemoveBaseObject(IBaseObject* object) { };
protected:
String type;
String name;
String path;
String main;
IPackage* pkg;
State state;
MValueDict exports;
IResource(CreationInfo* info) :
type(info->type),
name(info->name),
path(info->path),
main(info->main),
pkg(info->pkg),
state(State::STOPPED)
{
}
};
}