PutOutsideEvent.py 1.2KB

12345678910111213141516171819202122232425262728293031
  1. from synergine.core.exceptions import NotConcernedEvent
  2. from synergine_xyz.cst import POSITION
  3. from intelligine.cst import COL_PUT_OUTSIDE
  4. from intelligine.simulation.object.brain.part.move.AntMoveBrainPart import AntMoveBrainPart
  5. from intelligine.simulation.object.brain.part.transport.AntPutBrainPart import AntPutBrainPart
  6. from intelligine.synergy.event.Event import Event
  7. # TODO: NearEvent ?
  8. class PutOutsideEvent(Event):
  9. _concern = COL_PUT_OUTSIDE
  10. def _prepare(self, object_id, context, parameters={}):
  11. # TODO: DEV code ailleurs (._)
  12. if AntMoveBrainPart._on_home_smell(context, object_id):
  13. raise NotConcernedEvent()
  14. current_position = context.metas.value.get(POSITION, object_id)
  15. around_positions = context.get_around_points_of(current_position)
  16. for around_position in around_positions:
  17. # TODO DEV: ... ._
  18. if AntPutBrainPart._position_have_free_space_around(context, around_position):
  19. if AntPutBrainPart._position_is_enought_place(context, around_position):
  20. # TODO: Constant ?
  21. parameters['position_to_put'] = around_position
  22. return parameters
  23. raise NotConcernedEvent()