Simulation.py 937B

12345678910111213141516171819
  1. from synergine.synergy.Simulation import Simulation as BaseSimulation
  2. from synergine_xyz.cst import POSITIONS
  3. from intelligine.synergy.event.transport.PutableAction import PutableAction
  4. from intelligine.synergy.event.transport.TakeableAction import TakeableAction
  5. from intelligine.cst import COL_TRANSPORTER_CARRYING, COL_TRANSPORTER_NOT_CARRYING
  6. class Simulation(BaseSimulation):
  7. def connect_actions_signals(self, Signals):
  8. Signals.signal(PutableAction).connect(lambda obj, context: \
  9. context.metas.collections.add_remove(obj.get_id(), COL_TRANSPORTER_NOT_CARRYING, COL_TRANSPORTER_CARRYING))
  10. Signals.signal(TakeableAction).connect(lambda obj, context: \
  11. context.metas.collections.add_remove(obj.get_id(), COL_TRANSPORTER_CARRYING, COL_TRANSPORTER_NOT_CARRYING))
  12. def end_cycle(self, context):
  13. if context.get_cycle() % 100 is 0:
  14. context.metas.list.clean(POSITIONS)