subject.py 876B

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