SmellAction.py 1.1KB

1234567891011121314151617181920212223242526272829
  1. from intelligine.cst import POINT_SMELL, POINTS_SMELL
  2. from intelligine.synergy.event.smell.SmellEvent import SmellEvent
  3. from synergine.synergy.event.Action import Action
  4. class SmellAction(Action):
  5. _listen = SmellEvent
  6. def run(self, obj, context, synergy_manager):
  7. points_distances = self._parameters['points_distances']
  8. smell_type = obj.get_smell()
  9. for smell_point in points_distances:
  10. where_to_put_smells = context.metas.value.get(POINT_SMELL, smell_point, allow_empty=True, empty_value={})
  11. current_point_smell = points_distances[smell_point]
  12. if smell_type not in where_to_put_smells:
  13. where_to_put_smells[smell_type] = current_point_smell
  14. else:
  15. where_to_put_smell = where_to_put_smells[smell_type]
  16. if current_point_smell < where_to_put_smell:
  17. where_to_put_smells[smell_type] = where_to_put_smell
  18. context.metas.value.set(POINT_SMELL, smell_point, where_to_put_smells)
  19. context.metas.list.add(POINTS_SMELL, POINTS_SMELL, smell_point, assert_not_in=False)