-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserScripts.h
More file actions
55 lines (45 loc) 路 1.06 KB
/
Copy pathUserScripts.h
File metadata and controls
55 lines (45 loc) 路 1.06 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
#pragma once
/// @file
/// The UserScripts feature: bridges the Python scripting layer into the feature
/// loop, ticking every loaded user script once per frame while enabled.
#include "Feature.h"
#include "../scripting/Scripts.h"
#include "../scripting/Events.h"
/// Drives user-supplied Python scripts each frame: runs every script's main()
/// (legacy per-frame model) and dispatches the Render event to those that
/// subscribe via the event bus.
class UserScripts : public Feature
{
public:
UserScripts()
{
Name = "UserScripts";
UpdateEnabled();
Log("Created");
};
void UpdateEnabled()
{
Enabled = Settings.MISC.UserScriptsEnabled;
};
bool Check()
{
return Initialized;
};
void Init()
{
Initialized = true;
Log("Initialized");
};
void Destroy() {
};
void Run()
{
// Legacy per-frame model: every script's main() runs each frame.
for (int i = 0; i < Scripts::scriptList.size(); i++)
{
Scripts::Execute(i);
}
// Event model: scripts subscribed to Render run each frame too.
Events::Dispatch(Events::Type::Render);
};
};