This repository has been archived on 2019-12-09. You can view files and clone it, but cannot push or open issues or pull requests.
pacman2/engine/entity.py

30 lines
656 B
Python
Raw Normal View History

from .observer import Observer
2019-12-09 15:34:37 +01:00
class Entity(Observer):
2019-12-09 12:36:42 +01:00
def __init__(self, name):
super().__init__()
2019-11-23 10:46:25 +01:00
self._components = []
2019-12-09 12:36:42 +01:00
self.name = name
self.scene = None
2019-11-23 10:46:25 +01:00
self.x = 0
self.y = 0
self.script = None
2019-12-09 12:36:42 +01:00
def load(self):
pass
2019-11-23 10:46:25 +01:00
def add(self, component):
2019-12-09 12:36:42 +01:00
component.parent = self
component.load()
2019-11-23 10:46:25 +01:00
self._components.append(component)
2019-12-09 12:36:42 +01:00
return component
2019-11-23 10:46:25 +01:00
def register(self):
for component in self._components:
component.register()
def unregister(self):
for component in self._components:
component.unregister()