Adds boilerplate for game state
This commit is contained in:
1 parent
4769b8d707
commit
8ad4106b36
2 files changed
+10
-5
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class BaseGameState:
|
||||||
|
pass
|
||||||
@@ -41,13 +41,12 @@ class World:
|
|||||||
yield entity, component_storage
|
yield entity, component_storage
|
||||||
|
|
||||||
def get_components(self, entity: int, pop=False):
|
def get_components(self, entity: int, pop=False):
|
||||||
for componentstorage in self.registry.values():
|
for archetype in self.registry.values():
|
||||||
if entity in componentstorage:
|
if entity in archetype:
|
||||||
if pop:
|
if pop:
|
||||||
return componentstorage.pop(entity, None)
|
return archetype.pop(entity, None)
|
||||||
else:
|
else:
|
||||||
return componentstorage[entity]
|
return archetype[entity]
|
||||||
return None
|
|
||||||
|
|
||||||
def tick(self, *args, **kwargs):
|
def tick(self, *args, **kwargs):
|
||||||
for system in self.systems:
|
for system in self.systems:
|
||||||
|
|||||||
Reference in new issue
Block a user