Initial commit
This commit is contained in:
1 parent
afe548e9f8
commit
e4184b7cde
7 files changed
+213
-17
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
from components import Health, Hydration, Hygiene, Satiety
|
||||
from ecs import World
|
||||
|
||||
|
||||
class SatietySystem:
|
||||
@classmethod
|
||||
def process(cls, world: World):
|
||||
for _, component_map in world.query(Satiety):
|
||||
health: Health = component_map[Health]
|
||||
hunger: Satiety = component_map[Satiety]
|
||||
if hunger.value <= 0:
|
||||
health.value -= 1
|
||||
hunger.value = 0
|
||||
else:
|
||||
hunger.value -= 1
|
||||
|
||||
|
||||
class HydrationSystem:
|
||||
@classmethod
|
||||
def process(cls, world: World):
|
||||
for _, component_map in world.query(Hydration):
|
||||
health: Health = component_map[Health]
|
||||
hydration: Hydration = component_map[Hydration]
|
||||
if hydration.value <= 0:
|
||||
health.value -= 1
|
||||
hydration.value = 0
|
||||
else:
|
||||
hydration.value -= 1
|
||||
|
||||
|
||||
class HygieneSystem:
|
||||
@classmethod
|
||||
def process(cls, world: World):
|
||||
for _, component_map in world.query(Hygiene):
|
||||
health: Health = component_map[Health]
|
||||
hygiene: Hygiene = component_map[Hygiene]
|
||||
if hygiene.value <= 0:
|
||||
health.value -= 1
|
||||
hygiene.value = 0
|
||||
else:
|
||||
hygiene.value -= 1
|
||||
Reference in new issue
Block a user