NearAttackableEvent.py 925B

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