AntTakeBrainPart.py 1.1KB

123456789101112131415161718192021222324
  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, MOVE_MODE_NURSE, TYPE_NURSERY
  5. class AntTakeBrainPart(TakeBrainPart):
  6. # TODO: methode __init_ pour la classe ? Pour surcharger ici.
  7. _mode_matches = {
  8. MOVE_MODE_EXPLO: [TYPE_RESOURCE_TRANSFORMABLE],
  9. MOVE_MODE_NURSE: [TYPE_NURSERY]
  10. }
  11. @classmethod
  12. def can_take(cls, context, object_id, object_to_take_id):
  13. # Pour le moment si le type de l'objet fait partie des types admis pour le mode courant du porteur, c'est bon.
  14. return cls._match_with_mode(context, object_id, object_to_take_id)
  15. def done(self, obj, take_object, context):
  16. # TODO: Ranger ca ? Truc plus dynamique/configurable ?
  17. if isinstance(take_object, Resource):
  18. obj.get_brain().switch_to_mode(MOVE_MODE_GOHOME)
  19. obj.get_movement_pheromone_gland().appose()