]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/ecs/README.md
Add an option (off by default) to allow the vortex to charge even while not in hand
[xonotic/xonotic-data.pk3dir.git] / qcsrc / ecs / README.md
1 # Xonotic entity component system
2
3 ## guidelines
4
5 * avoid #if and #ifdef
6 * avoid string
7 * avoid declaring entity fields outside of components
8 * uncrustify relentlessly
9 * shared code in $file, prog specific code uses prefix: { client: cl_, server: sv_, menu: ui_ }. $file must exist
10 * component naming =~ com_$component_$name
11 * system naming =~ sys_$system_$name
12 * event naming =~ evt_$component_$name
13 * global naming =~ g_$name
14 * cvar naming =~ xon_$name
15
16 ## components
17
18     COMPONENT($component);
19     .int com_$component_$property;
20
21 ## entities
22
23     entity e = new(foo);
24     e.com_$component = true;
25     e.com_$component_$property = 42;
26
27 ## systems
28
29     SYSTEM($system, 30, 10);
30     sys_$system_update(entity this, float dt) {
31         code;
32     }
33
34 ## events
35
36 ### declaring
37
38     EVENT($component_$name, (entity this));
39
40 ### emitting
41
42     emit($event, it);
43
44 ### listening
45
46     entity listener = new_pure(someListener);
47     subscribe(listener, $event, void(entity this) { code; });