TakeableEvent.py 1.3KB

1234567891011121314151617181920212223242526
  1. from synergine.synergy.event.Event import Event
  2. from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
  3. from intelligine.cst import TRANSPORTABLE, TRANSPORTER, ALIVE, CARRYING, CANT_CARRY_STILL
  4. class TakeableEvent(Event):
  5. def concern(self, object_id, context):
  6. return context.metas.states.have_list(object_id, [TRANSPORTER, ALIVE]) and \
  7. context.metas.states.dont_have(object_id, CARRYING) and not \
  8. context.metas.value.get(CANT_CARRY_STILL, object_id, allow_empty=True) # TODO: si COLS: ca plus dans concern mais dans object_match
  9. def __init__(self, actions):
  10. super().__init__(actions)
  11. self._mechanism = ArroundMechanism
  12. def _object_match(self, object_id, context, parameters={}):
  13. # TODO: Nettoyer (refact possible sur ces objets ont tel states, comme dans concern)
  14. for obj_near_id in parameters['objects_ids_near']:
  15. if context.metas.states.have(obj_near_id, TRANSPORTABLE):
  16. if 'objects_ids_transportable' not in parameters:
  17. parameters['objects_ids_transportable'] = []
  18. parameters['objects_ids_transportable'].append(obj_near_id)
  19. if 'objects_ids_transportable' not in parameters:
  20. return False
  21. return True