예제 #1
0
파일: entity.py 프로젝트: speeddown/SimSkia
 def remove_component(self, comp_type: Type[Component]):
     if comp_type in self.components.keys():
         del self.components[comp_type]
         keys = self.key.get_keys()
         keys.remove(comp_type)
         self.key = ComponentKey(keys)
         PyBus.Instance().post(ComponentRemovedEvent(self))
예제 #2
0
파일: entity.py 프로젝트: speeddown/SimSkia
 def add_component(self, comp_type: Type[Component]):
     if comp_type not in self.components.keys():
         keys = self.key.get_keys()
         keys.append(comp_type)
         self.key = ComponentKey(keys)
         self.components[comp_type] = comp_type()
         PyBus.Instance().post(ComponentAddedEvent(self))
예제 #3
0
    def __init__(self, process):
        self._callbacks: Dict[str, List[Callable[[Message], None]]] = {}
        self.process: BaseProcess = process
        self.broadcast_sync_message = None
        self.letterbox = deque()
        self.state = None
        self.answered_process = set()
        self.answered_process_broadcast_sync = set()
        self.answered_process_heartbit = set()
        self.have_process_sync_responded = False
        self.process_number = 1

        self.heartbit_process = HeartbitProcess(self.process, self)

        PyBus.Instance().register(self, self)
예제 #4
0
 def post(self):
     """Post this message on the bus"""
     PyBus.Instance().post(self)
예제 #5
0
	def __init__(self):
		super(TestScene, self).__init__([WorldSystem, RenderSystem, InputSystem], [Player])
		PyBus.Instance().register(self, self.__class__.__name__)
		self.player: Player
		self.player_transform: Transform
예제 #6
0
 def destroy(self, entity: Entity):
     del self.current_scene.entities[entity.id]
     PyBus.Instance().post(EntityRemovedEvent(self, entity))
예제 #7
0
 def instantiate(self, entity: Type[E]) -> E:
     new_ent: E = entity()
     self.current_scene.entities[new_ent.id] = new_ent
     PyBus.Instance().post(EntityAddedEvent(self, new_ent))
     return new_ent
예제 #8
0
 def load_system(self, system_type: Type[S]) -> S:
     if system_type not in self.current_scene.systems.keys():
         new_sys: S = system_type()
         PyBus.Instance().register(new_sys, system_type)
         self.current_scene.systems[system_type] = new_sys
         return system_type()
예제 #9
0
 def key_pressed(self, window, key, scancode, action, mods):
     PyBus.Instance().post(KeyEvent(Key(key), Action(action)))