-
Notifications
You must be signed in to change notification settings - Fork 10
/
world.py
48 lines (38 loc) · 1.33 KB
/
world.py
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
# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
# Author (©): Alvaro del Castillo
# TODO: at some point this must be a real Singleton
class World:
"""
A world is a container for all the scenes built using McThings. Its mapping
is direct to Minecraft world concept.
Before adding Things to the World, it must have a renderer
"""
scenes = []
""" Scenes included in the world """
renderer = None
""" Render used to render the scenes """
@classmethod
def set_renderer(cls, renderer):
cls.renderer = renderer
# TODO: Hack for Minecraft renderer to use McDrawing
from mcthings.renderers.raspberry_pi import RaspberryPi
if isinstance(renderer, RaspberryPi):
World.drawing = renderer.drawing
@classmethod
def add_scene(cls, scene):
""" Add a new scene to the world """
cls.scenes.append(scene)
@classmethod
def first_scene(cls):
""" Return the first scene used be default """
return cls.scenes[0]
@classmethod
def build(cls):
""" Build all the scenes inside the world """
for scene in cls.scenes:
scene.build()
@classmethod
def unbuild(cls):
""" Unbuild all the scenes inside the world """
for scene in cls.scene:
scene.unbuild()