subject.py 986B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from sandbox.engulf.behaviour import GrowUp
  2. from synergine2.simulation import Subject
  3. from synergine2.xyz import XYZSubjectMixin
  4. COLLECTION_CELL = 'CELL'
  5. COLLECTION_ALIVE = 'ALIVE'
  6. COLLECTION_EATABLE = 'EATABLE'
  7. COLLECTION_GRASS = 'GRASS'
  8. class Cell(XYZSubjectMixin, Subject):
  9. collections = [
  10. COLLECTION_CELL,
  11. COLLECTION_ALIVE,
  12. COLLECTION_EATABLE,
  13. ]
  14. class Grass(XYZSubjectMixin, Subject):
  15. collections = [
  16. COLLECTION_EATABLE,
  17. COLLECTION_GRASS,
  18. ]
  19. behaviours_classes = [
  20. GrowUp,
  21. ]
  22. def __init__(self, *args, density=100.0, **kwargs):
  23. super().__init__(*args, **kwargs)
  24. self._density = density
  25. @property
  26. def density(self) -> float:
  27. return self._density
  28. @density.setter
  29. def density(self, value: float) -> None:
  30. if value > 100:
  31. self._density = 100
  32. elif value < 0:
  33. self._density = 0
  34. else:
  35. self._density = value