sonolus.py 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl
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.
Potentially problematic release.
This version of sonolus.py might be problematic. Click here for more details.
- sonolus/script/archetype.py +56 -3
- {sonolus_py-0.5.1.dist-info → sonolus_py-0.5.2.dist-info}/METADATA +1 -1
- {sonolus_py-0.5.1.dist-info → sonolus_py-0.5.2.dist-info}/RECORD +6 -6
- {sonolus_py-0.5.1.dist-info → sonolus_py-0.5.2.dist-info}/WHEEL +0 -0
- {sonolus_py-0.5.1.dist-info → sonolus_py-0.5.2.dist-info}/entry_points.txt +0 -0
- {sonolus_py-0.5.1.dist-info → sonolus_py-0.5.2.dist-info}/licenses/LICENSE +0 -0
sonolus/script/archetype.py
CHANGED
|
@@ -459,7 +459,7 @@ class _BaseArchetype:
|
|
|
459
459
|
still be the id of `A`.
|
|
460
460
|
"""
|
|
461
461
|
|
|
462
|
-
key: int = -1
|
|
462
|
+
key: int | float = -1
|
|
463
463
|
"""An optional key for the archetype.
|
|
464
464
|
|
|
465
465
|
May be useful to identify an archetype in an inheritance hierarchy without needing to check id.
|
|
@@ -467,7 +467,7 @@ class _BaseArchetype:
|
|
|
467
467
|
If accessed on an entity, always returns the runtime key of the entity, even if it doesn't match the type
|
|
468
468
|
that was used to access it.
|
|
469
469
|
|
|
470
|
-
E.g. if an entity of archetype `A` is accessed via [`EntityRef[B]`][sonolus.script.archetype.EntityRef], the key
|
|
470
|
+
E.g. if an entity of archetype `A` is accessed via [`EntityRef[B]`][sonolus.script.archetype.EntityRef], the key
|
|
471
471
|
will still be the key of `A`.
|
|
472
472
|
"""
|
|
473
473
|
|
|
@@ -751,8 +751,17 @@ class _BaseArchetype:
|
|
|
751
751
|
def derive[T](cls: type[T], name: str, is_scored: bool, key: int | float | None = None) -> type[T]:
|
|
752
752
|
"""Derive a new archetype class from this archetype.
|
|
753
753
|
|
|
754
|
+
Roughly equivalent to returning:
|
|
755
|
+
```python
|
|
756
|
+
class Derived(cls):
|
|
757
|
+
name = <name>
|
|
758
|
+
is_scored = <is_scored>
|
|
759
|
+
key = <key> # Only set if key is not None
|
|
760
|
+
```
|
|
761
|
+
|
|
754
762
|
This is used to create a new archetype with the same fields and callbacks, but with a different name and
|
|
755
|
-
whether it is scored.
|
|
763
|
+
whether it is scored. Compared to manually subclassing, this method also enables faster compilation when
|
|
764
|
+
the same base archetype has multiple derived archetypes by compiling callbacks only once for the base archetype.
|
|
756
765
|
|
|
757
766
|
Args:
|
|
758
767
|
name: The name of the new archetype.
|
|
@@ -943,6 +952,26 @@ class PlayArchetype(_BaseArchetype):
|
|
|
943
952
|
case _:
|
|
944
953
|
raise RuntimeError("Result is only accessible from the entity itself")
|
|
945
954
|
|
|
955
|
+
@classmethod
|
|
956
|
+
def update_life(
|
|
957
|
+
cls,
|
|
958
|
+
perfect_increment: int | None = None,
|
|
959
|
+
great_increment: int | None = None,
|
|
960
|
+
good_increment: int | None = None,
|
|
961
|
+
miss_increment: int | None = None,
|
|
962
|
+
):
|
|
963
|
+
"""Update the life of this archetype.
|
|
964
|
+
|
|
965
|
+
Values default to 0.
|
|
966
|
+
|
|
967
|
+
Args:
|
|
968
|
+
perfect_increment: The increment for perfect life.
|
|
969
|
+
great_increment: The increment for great life.
|
|
970
|
+
good_increment: The increment for good life.
|
|
971
|
+
miss_increment: The increment for miss life.
|
|
972
|
+
"""
|
|
973
|
+
archetype_life_of(cls).update(perfect_increment, great_increment, good_increment, miss_increment)
|
|
974
|
+
|
|
946
975
|
|
|
947
976
|
class WatchArchetype(_BaseArchetype):
|
|
948
977
|
"""Base class for watch mode archetypes.
|
|
@@ -1061,6 +1090,26 @@ class WatchArchetype(_BaseArchetype):
|
|
|
1061
1090
|
if cls._exported_fields_:
|
|
1062
1091
|
raise RuntimeError("Watch archetypes cannot have exported fields")
|
|
1063
1092
|
|
|
1093
|
+
@classmethod
|
|
1094
|
+
def update_life(
|
|
1095
|
+
cls,
|
|
1096
|
+
perfect_increment: int | None = None,
|
|
1097
|
+
great_increment: int | None = None,
|
|
1098
|
+
good_increment: int | None = None,
|
|
1099
|
+
miss_increment: int | None = None,
|
|
1100
|
+
):
|
|
1101
|
+
"""Update the life of this archetype.
|
|
1102
|
+
|
|
1103
|
+
Values default to 0.
|
|
1104
|
+
|
|
1105
|
+
Args:
|
|
1106
|
+
perfect_increment: The increment for perfect life.
|
|
1107
|
+
great_increment: The increment for great life.
|
|
1108
|
+
good_increment: The increment for good life.
|
|
1109
|
+
miss_increment: The increment for miss life.
|
|
1110
|
+
"""
|
|
1111
|
+
archetype_life_of(cls).update(perfect_increment, great_increment, good_increment, miss_increment)
|
|
1112
|
+
|
|
1064
1113
|
|
|
1065
1114
|
class PreviewArchetype(_BaseArchetype):
|
|
1066
1115
|
"""Base class for preview mode archetypes.
|
|
@@ -1301,3 +1350,7 @@ class StandardArchetypeName(StrEnum):
|
|
|
1301
1350
|
|
|
1302
1351
|
TIMESCALE_CHANGE = "#TIMESCALE_CHANGE"
|
|
1303
1352
|
"""Timescale change marker"""
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
type AnyArchetype = PlayArchetype | WatchArchetype | PreviewArchetype
|
|
1356
|
+
"""Union of all archetype types."""
|
|
@@ -34,7 +34,7 @@ sonolus/build/level.py,sha256=yXsQtnabkJK0vuVmZ_Wr1jx37jFLgInCS7lTlXjkv9Q,706
|
|
|
34
34
|
sonolus/build/node.py,sha256=gnX71RYDUOK_gYMpinQi-bLWO4csqcfiG5gFmhxzSec,1330
|
|
35
35
|
sonolus/build/project.py,sha256=mv2OuzgIDG-E9G4SIRiUDL5XiPCd1i81wVl1p7itFHA,6329
|
|
36
36
|
sonolus/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
-
sonolus/script/archetype.py,sha256
|
|
37
|
+
sonolus/script/archetype.py,sha256=-i7TQMI0_ztNTwd1bXu39q3wSaa70kRlPoNZFUHNbHY,48534
|
|
38
38
|
sonolus/script/array.py,sha256=9uOUHZIDMyMT9q3APcXJWXWt97yG-AZoRlxwrvSY6SU,12367
|
|
39
39
|
sonolus/script/array_like.py,sha256=jFOfXkniTLrIK4ER6HO_tUyKn_TvwjyM4B3SDd9cUS8,9678
|
|
40
40
|
sonolus/script/bucket.py,sha256=VxsSgHidYhY_Y5UXpBZY_tzjQff0TRgNJVj4Al8LVec,7654
|
|
@@ -86,8 +86,8 @@ sonolus/script/internal/simulation_context.py,sha256=LGxLTvxbqBIhoe1R-SfwGajNIDw
|
|
|
86
86
|
sonolus/script/internal/transient.py,sha256=y2AWABqF1aoaP6H4_2u4MMpNioC4OsZQCtPyNI0txqo,1634
|
|
87
87
|
sonolus/script/internal/tuple_impl.py,sha256=DPNdmmRmupU8Ah4_XKq6-PdT336l4nt15_uCJKQGkkk,3587
|
|
88
88
|
sonolus/script/internal/value.py,sha256=OngrCdmY_h6mV2Zgwqhuo4eYFad0kTk6263UAxctZcY,6963
|
|
89
|
-
sonolus_py-0.5.
|
|
90
|
-
sonolus_py-0.5.
|
|
91
|
-
sonolus_py-0.5.
|
|
92
|
-
sonolus_py-0.5.
|
|
93
|
-
sonolus_py-0.5.
|
|
89
|
+
sonolus_py-0.5.2.dist-info/METADATA,sha256=95TnAW9JgpYR6UNXhEm3rZbHCqKWkUY6cGr93eYo4Wo,302
|
|
90
|
+
sonolus_py-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
91
|
+
sonolus_py-0.5.2.dist-info/entry_points.txt,sha256=oTYspY_b7SA8TptEMTDxh4-Aj-ZVPnYC9f1lqH6s9G4,54
|
|
92
|
+
sonolus_py-0.5.2.dist-info/licenses/LICENSE,sha256=JEKpqVhQYfEc7zg3Mj462sKbKYmO1K7WmvX1qvg9IJk,1067
|
|
93
|
+
sonolus_py-0.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|