tinyecs 0.5.2__tar.gz → 0.5.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tinyecs-0.5.2/src/tinyecs.egg-info → tinyecs-0.5.3}/PKG-INFO +1 -1
- {tinyecs-0.5.2 → tinyecs-0.5.3}/pyproject.toml +1 -1
- {tinyecs-0.5.2 → tinyecs-0.5.3}/src/tinyecs/__init__.py +35 -7
- {tinyecs-0.5.2 → tinyecs-0.5.3/src/tinyecs.egg-info}/PKG-INFO +1 -1
- {tinyecs-0.5.2 → tinyecs-0.5.3}/tests/test_tinyecs.py +38 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/LICENSE +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/README.rst +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/setup.cfg +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/src/tinyecs/tutorial.py +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/src/tinyecs.egg-info/SOURCES.txt +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/src/tinyecs.egg-info/dependency_links.txt +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/src/tinyecs.egg-info/requires.txt +0 -0
- {tinyecs-0.5.2 → tinyecs-0.5.3}/src/tinyecs.egg-info/top_level.txt +0 -0
|
@@ -14,10 +14,11 @@ __all__ = ['Component', 'ComponentID', 'DomainID', 'EntityID',
|
|
|
14
14
|
'create_entity', 'eid_has', 'eid_of_comp', 'eids_by_cids',
|
|
15
15
|
'eids_by_property', 'has', 'has_property', 'healthcheck',
|
|
16
16
|
'purge_by_property', 'remove_archetype', 'remove_component',
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
17
|
+
'remove_domain', 'remove_entity', 'remove_from_archetype',
|
|
18
|
+
'remove_property', 'remove_system', 'remove_system_from_domain',
|
|
19
|
+
'reset', 'run_all_systems', 'run_bulk_system', 'run_domain',
|
|
20
|
+
'run_system', 'set_properties', 'set_property',
|
|
21
|
+
'update_component',]
|
|
21
22
|
|
|
22
23
|
type EntityID = Hashable
|
|
23
24
|
type ComponentID = Hashable
|
|
@@ -352,7 +353,7 @@ def remove_system(fn: SystemFunction) -> None:
|
|
|
352
353
|
pass
|
|
353
354
|
|
|
354
355
|
|
|
355
|
-
def add_system_to_domain(domain: DomainID, system: SystemFunction) -> None:
|
|
356
|
+
def add_system_to_domain(domain: DomainID, system: SystemFunction, after=None) -> None:
|
|
356
357
|
"""Create or extend a domain with the given system.
|
|
357
358
|
|
|
358
359
|
:param system: The system function
|
|
@@ -367,8 +368,12 @@ def add_system_to_domain(domain: DomainID, system: SystemFunction) -> None:
|
|
|
367
368
|
if system not in sidx:
|
|
368
369
|
raise UnknownSystemError(f'system {system} is not registered')
|
|
369
370
|
if domain not in didx:
|
|
370
|
-
didx[domain] =
|
|
371
|
-
|
|
371
|
+
didx[domain] = []
|
|
372
|
+
|
|
373
|
+
try:
|
|
374
|
+
didx[domain].insert(didx[domain].index(after) + 1, system)
|
|
375
|
+
except ValueError:
|
|
376
|
+
didx[domain].append(system)
|
|
372
377
|
|
|
373
378
|
|
|
374
379
|
def remove_system_from_domain(domain: DomainID, system: SystemFunction) -> None:
|
|
@@ -384,6 +389,21 @@ def remove_system_from_domain(domain: DomainID, system: SystemFunction) -> None:
|
|
|
384
389
|
return
|
|
385
390
|
try:
|
|
386
391
|
didx[domain].remove(system)
|
|
392
|
+
except ValueError:
|
|
393
|
+
pass
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def remove_domain(domain: DomainID) -> None:
|
|
397
|
+
"""Remove the given domain.
|
|
398
|
+
|
|
399
|
+
:param domain: The domain to remove
|
|
400
|
+
:return: None
|
|
401
|
+
|
|
402
|
+
.. note:: A non existing domain is silently ignored
|
|
403
|
+
"""
|
|
404
|
+
|
|
405
|
+
try:
|
|
406
|
+
del didx[domain]
|
|
387
407
|
except KeyError:
|
|
388
408
|
pass
|
|
389
409
|
|
|
@@ -637,6 +657,14 @@ def run_all_systems(**kwargs) -> dict[SystemFunction, _RunSystemResult]:
|
|
|
637
657
|
|
|
638
658
|
This calls above run_system for all registered systems with their
|
|
639
659
|
appropriate components.
|
|
660
|
+
|
|
661
|
+
.. important:: If you pass kwargs to ``run_all_systems``, naturally all
|
|
662
|
+
systems have to accept kwargs. This is in the responsibility of the
|
|
663
|
+
programmer.
|
|
664
|
+
|
|
665
|
+
This function is provided for very simple use cases, use either well
|
|
666
|
+
ordered lists of ``run_system`` calls or the domain system, which will
|
|
667
|
+
be much less error prone.
|
|
640
668
|
"""
|
|
641
669
|
|
|
642
670
|
return {fn: run_system(fn, *comps, **kwargs)
|
|
@@ -326,6 +326,44 @@ def test_run_domain():
|
|
|
326
326
|
assert res == {}
|
|
327
327
|
|
|
328
328
|
|
|
329
|
+
def test_stable_domain_order():
|
|
330
|
+
def dummy_system1b(eid, comp): pass
|
|
331
|
+
def dummy_system1a(eid, comp): pass
|
|
332
|
+
def dummy_system2a(eid, comp): pass
|
|
333
|
+
def dummy_system2b(eid, comp): pass
|
|
334
|
+
def dummy_system3(eid, comp): pass
|
|
335
|
+
|
|
336
|
+
ecs.reset()
|
|
337
|
+
ecs.add_system(dummy_system1a, 'dummy_comp')
|
|
338
|
+
ecs.add_system(dummy_system1b, 'dummy_comp')
|
|
339
|
+
ecs.add_system(dummy_system2a, 'dummy_comp')
|
|
340
|
+
ecs.add_system(dummy_system2b, 'dummy_comp')
|
|
341
|
+
ecs.add_system(dummy_system3, 'dummy_comp')
|
|
342
|
+
|
|
343
|
+
ecs.add_system_to_domain('ze_domain', dummy_system1a)
|
|
344
|
+
ecs.add_system_to_domain('ze_domain', dummy_system2a)
|
|
345
|
+
assert ecs.didx['ze_domain'] == [dummy_system1a, dummy_system2a]
|
|
346
|
+
|
|
347
|
+
ecs.add_system_to_domain('ze_domain', dummy_system1b, after=dummy_system1a)
|
|
348
|
+
assert ecs.didx['ze_domain'] == [dummy_system1a, dummy_system1b, dummy_system2a]
|
|
349
|
+
|
|
350
|
+
ecs.add_system_to_domain('ze_domain', dummy_system2b, after=dummy_system2a)
|
|
351
|
+
assert ecs.didx['ze_domain'] == [dummy_system1a, dummy_system1b, dummy_system2a, dummy_system2b]
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def test_remove_domain():
|
|
355
|
+
def dummy_system(eid, comp): pass
|
|
356
|
+
|
|
357
|
+
ecs.reset()
|
|
358
|
+
ecs.add_system(dummy_system, 'dummy_comp')
|
|
359
|
+
|
|
360
|
+
ecs.add_system_to_domain('ze_domain', dummy_system)
|
|
361
|
+
ecs.remove_domain('ze_domain')
|
|
362
|
+
assert 'ze_domain' not in ecs.didx
|
|
363
|
+
|
|
364
|
+
ecs.remove_domain('ze_domain')
|
|
365
|
+
|
|
366
|
+
|
|
329
367
|
def test_eid_has():
|
|
330
368
|
ecs.reset()
|
|
331
369
|
e1, e2 = setup()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|