subject.py 1002B

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