Adds Death and Sickness systems

This commit is contained in:
nejdetckenobi committed 2026-10-03 23:55:52 +03:00
1 parent c22a173e52
commit 722bf6d55f
4 files changed
+46 -34

No files matched your search

+27 -2
View File
@@ -1,5 +1,5 @@
from components import Health, Hydration, Hygiene, Satiety
from ecs import World
from components import Health, Hydration, Hygiene, Satiety, Tag, Tags
from libs.ecs import World
class SatietySystem:
@@ -39,3 +39,28 @@ class HygieneSystem:
hygiene.value = 0
else:
hygiene.value -= 1
class SicknessSystem:
@classmethod
def process(cls, world: World):
for _, component_map in world.query(Health, Tags):
health = component_map[Health]
tags = component_map[Tags]
if Tag.SICK in tags.values and health.value > 0:
health.value -= 1
if health.value <= 0:
health.value = 0
tags.values.add(Tag.DEAD)
class DeathSystem:
@classmethod
def process(cls, world: World):
marked = set()
for entity, component_map in world.query(Health, Tags):
tags = component_map[Tags]
if Tag.DEAD in tags.values:
marked.add(entity)
for entity in marked:
world.get_components(entity, pop=True)