-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_bundle_components.py
More file actions
48 lines (37 loc) · 914 Bytes
/
Copy pathtest_bundle_components.py
File metadata and controls
48 lines (37 loc) · 914 Bytes
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
from wonderworld import *
@dataclass
class Component1(Component):
pass
@dataclass
class Component2(Component):
value:int
@dataclass
class Label(Component):
value:str
@dataclass
class Strength(Component):
value:int
@dataclass
class Agility(Component):
value:int
@dataclass
class ExampleBundle(Bundle):
a: Component1
b: Component2
def example_system():
commands = Commands()
#Create a new entity with a single component.
commands.spawn(Component1)
#Create a new entity with a component bundle.
commands.spawn(ExampleBundle(
a = Component1(),
b = Component2(value=2)
))
commands \
.spawn((Component1, Component2)) \
.insert((Strength(1), Agility(2))) \
.insert(Label("hello world"))
if __name__ == "__main__":
App().add_plugins(DefaultPlugins())\
.add_startup_system(example_system)\
.run()