mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 23:36:43 +02:00
25 lines
524 B
Python
25 lines
524 B
Python
|
|
|
|
# noinspection PyAttributeOutsideInit
|
|
class BoundEntityMixin:
|
|
|
|
@property
|
|
def bound_entity(self):
|
|
return self._bound_entity
|
|
|
|
@property
|
|
def name(self):
|
|
if self.bound_entity:
|
|
return f'{self.__class__.__name__}({self.bound_entity.name})'
|
|
else:
|
|
print()
|
|
|
|
def belongs_to_entity(self, entity):
|
|
return entity == self.bound_entity
|
|
|
|
def bind_to(self, entity):
|
|
self._bound_entity = entity
|
|
|
|
def unbind(self):
|
|
self._bound_entity = None
|