TakeableEvent.py 883B

12345678910111213141516171819202122
  1. from intelligine.synergy.event.src.NearEvent import NearEvent
  2. from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
  3. from intelligine.cst import TRANSPORTABLE, CANT_CARRY_STILL, COL_TRANSPORTER_NOT_CARRYING
  4. class TakeableEvent(NearEvent):
  5. concern = COL_TRANSPORTER_NOT_CARRYING
  6. _near_name = 'objects_ids_transportable'
  7. _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, TRANSPORTABLE)
  8. def __init__(self, actions):
  9. super().__init__(actions)
  10. self._mechanism = ArroundMechanism
  11. def _object_match(self, object_id, context, parameters={}):
  12. if context.metas.value.get(CANT_CARRY_STILL, object_id, allow_empty=True):
  13. return False
  14. self.map(context, parameters, stop_at_first=True)
  15. if self._near_name not in parameters:
  16. return False
  17. return True