Pygame.py 1.7KB

12345678910111213141516171819202122232425262728293031323334
  1. from xyzworld.display.Pygame import Pygame as XyzPygame
  2. from intelligine.cst import PHEROMON_INFOS, PHEROMON_DIRECTION, PHEROMON_DIR_EXPLO, PHEROMON_POSITIONS
  3. from intelligine.synergy.object.ant.Pheromon import Pheromon
  4. class Pygame(XyzPygame):
  5. def receive(self, synergy_object_manager, context):
  6. super().receive(synergy_object_manager, context)
  7. self._display_pheromones(context.metas.list.get(PHEROMON_POSITIONS, PHEROMON_POSITIONS, allow_empty=True), context)
  8. def _display_pheromones(self, pheromones_positions, context):
  9. for point in pheromones_positions:
  10. ######
  11. # refact
  12. point_pheromones_infos = context.metas.value.get(PHEROMON_INFOS, point, allow_empty=True,
  13. empty_value={})
  14. # TODO: Tout ca dans un get_pheromone_info(PHEROMON_DIRECTION, PHEROMON_DIR_EXPLO, direction)
  15. #point_pheromones_infos={}
  16. if PHEROMON_DIRECTION not in point_pheromones_infos:
  17. point_pheromones_infos[PHEROMON_DIRECTION] = {}
  18. direction_pheromone = point_pheromones_infos[PHEROMON_DIRECTION]
  19. if PHEROMON_DIR_EXPLO not in direction_pheromone:
  20. direction_pheromone[PHEROMON_DIR_EXPLO] = {}
  21. exploration_info = direction_pheromone[PHEROMON_DIR_EXPLO]
  22. ########
  23. for direction in exploration_info:
  24. intensity = exploration_info[direction]
  25. # TODO: ne pas avoir a creer d'objet, voir comment dans display
  26. pheromon = Pheromon(object(), context)
  27. pheromon.set_direction(direction)
  28. self._draw_objects_with_decal(point, [pheromon])