TransportBrainPart.py 1.1KB

1234567891011121314151617181920212223242526
  1. from intelligine.cst import MOVE_MODE, TYPE
  2. from intelligine.simulation.object.brain.part.BrainPart import BrainPart
  3. class TransportBrainPart(BrainPart):
  4. _mode_matches = {}
  5. @classmethod
  6. def _match_with_mode(cls, context, object_id, concerned_object_id):
  7. move_mode = context.metas.value.get(MOVE_MODE, object_id)
  8. for takable_type in cls._mode_matches[move_mode]:
  9. if context.metas.list.have(TYPE, concerned_object_id, takable_type, allow_empty=True):
  10. return True
  11. return False
  12. @classmethod
  13. def _objects_have_same_type(cls, context, object_carried_id, object_to_put_id):
  14. # BUG: On considere ici que c une liste de type pour obj. J'ai fait l'inverse.
  15. # Une listde de objid pour un type.
  16. # TODO: Il faut inverser !
  17. object_carried_types = context.metas.list.get(TYPE, object_carried_id)
  18. for object_carried_type in object_carried_types:
  19. if context.metas.list.have(TYPE, object_to_put_id, object_carried_type):
  20. return True
  21. return False