AntTakeBrainPart.py 1.2KB

12345678910111213141516171819202122232425
  1. from intelligine.simulation.object.brain.part.transport.TakeBrainPart import TakeBrainPart
  2. from intelligine.synergy.object.ressource.Ressource import Resource
  3. from intelligine.cst import MOVE_MODE_EXPLO, MOVE_MODE, TYPE_RESOURCE_TRANSFORMABLE, \
  4. TYPE, MOVE_MODE_GOHOME, PHEROMON_DIR_EXPLO
  5. class AntTakeBrainPart(TakeBrainPart):
  6. # TODO: methode __nit_ pour la classe ? vt mieux surcharger !
  7. _mode_matches = {
  8. MOVE_MODE_EXPLO: [TYPE_RESOURCE_TRANSFORMABLE],
  9. }
  10. @classmethod
  11. def can_take(cls, context, object_id, object_to_take_id):
  12. # Pour le moment si le type de l'objet fait partie des types admis pour le mode courant du porteur, c'est bon.
  13. return cls._match_with_mode(context, object_id, object_to_take_id)
  14. def done(self, obj, take_object, context):
  15. # TODO: Ranger ca ? Truc plus dynamique/configurable ?
  16. if isinstance(take_object, Resource):
  17. obj.get_brain().switch_to_mode(MOVE_MODE_GOHOME)
  18. # TODO: set_last_pheromone_point ca devrait pas etre dans get_movement_pheromone_gland().appose() ?
  19. obj.set_last_pheromone_point(PHEROMON_DIR_EXPLO, obj.get_position())
  20. obj.get_movement_pheromone_gland().appose()