sonolus.py 0.6.3__py3-none-any.whl → 0.6.5__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 +91 -39
- sonolus/script/easing.py +2 -2
- sonolus/script/internal/context.py +9 -4
- {sonolus_py-0.6.3.dist-info → sonolus_py-0.6.5.dist-info}/METADATA +1 -1
- {sonolus_py-0.6.3.dist-info → sonolus_py-0.6.5.dist-info}/RECORD +8 -8
- {sonolus_py-0.6.3.dist-info → sonolus_py-0.6.5.dist-info}/WHEEL +0 -0
- {sonolus_py-0.6.3.dist-info → sonolus_py-0.6.5.dist-info}/entry_points.txt +0 -0
- {sonolus_py-0.6.3.dist-info → sonolus_py-0.6.5.dist-info}/licenses/LICENSE +0 -0
sonolus/script/archetype.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# type: ignore
|
|
2
1
|
from __future__ import annotations
|
|
3
2
|
|
|
4
3
|
import inspect
|
|
@@ -120,7 +119,7 @@ class _ArchetypeField(SonolusDescriptor):
|
|
|
120
119
|
if ctx():
|
|
121
120
|
return result._get_readonly_()
|
|
122
121
|
else:
|
|
123
|
-
return result._as_py_()
|
|
122
|
+
return result._as_py_() # type: ignore
|
|
124
123
|
|
|
125
124
|
def __set__(self, instance: _BaseArchetype, value):
|
|
126
125
|
if instance is None:
|
|
@@ -207,7 +206,7 @@ class _IsScoredDescriptor(SonolusDescriptor):
|
|
|
207
206
|
if instance is None:
|
|
208
207
|
return self.value
|
|
209
208
|
elif ctx():
|
|
210
|
-
|
|
209
|
+
return ctx().global_state.is_scored_by_archetype_id[instance.id]
|
|
211
210
|
else:
|
|
212
211
|
return self.value
|
|
213
212
|
|
|
@@ -237,7 +236,7 @@ class _KeyDescriptor(SonolusDescriptor):
|
|
|
237
236
|
|
|
238
237
|
def __get__(self, instance, owner):
|
|
239
238
|
if instance is not None and ctx():
|
|
240
|
-
return ctx().global_state.
|
|
239
|
+
return ctx().global_state.keys_by_archetype_id[instance.id]
|
|
241
240
|
else:
|
|
242
241
|
return self.value
|
|
243
242
|
|
|
@@ -362,37 +361,6 @@ _annotation_defaults: dict[Callable, _ArchetypeFieldInfo] = {
|
|
|
362
361
|
}
|
|
363
362
|
|
|
364
363
|
|
|
365
|
-
class StandardImport:
|
|
366
|
-
"""Standard import annotations for Archetype fields.
|
|
367
|
-
|
|
368
|
-
Usage:
|
|
369
|
-
```python
|
|
370
|
-
class MyArchetype(WatchArchetype):
|
|
371
|
-
judgment: StandardImport.JUDGMENT
|
|
372
|
-
```
|
|
373
|
-
"""
|
|
374
|
-
|
|
375
|
-
BEAT = Annotated[float, imported(name="#BEAT")]
|
|
376
|
-
"""The beat of the entity."""
|
|
377
|
-
|
|
378
|
-
BPM = Annotated[float, imported(name="#BPM")]
|
|
379
|
-
"""The bpm, for bpm change markers."""
|
|
380
|
-
|
|
381
|
-
TIMESCALE = Annotated[float, imported(name="#TIMESCALE")]
|
|
382
|
-
"""The timescale, for timescale change markers."""
|
|
383
|
-
|
|
384
|
-
JUDGMENT = Annotated[int, imported(name="#JUDGMENT")]
|
|
385
|
-
"""The judgment of the entity.
|
|
386
|
-
|
|
387
|
-
Automatically supported in watch mode for archetypes with a corresponding scored play mode archetype.
|
|
388
|
-
"""
|
|
389
|
-
ACCURACY = Annotated[float, imported(name="#ACCURACY")]
|
|
390
|
-
"""The accuracy of the entity.
|
|
391
|
-
|
|
392
|
-
Automatically supported in watch mode for archetypes with a corresponding scored play mode archetype.
|
|
393
|
-
"""
|
|
394
|
-
|
|
395
|
-
|
|
396
364
|
def callback[T: Callable](*, order: int = 0) -> Callable[[T], T]:
|
|
397
365
|
"""Annotate a callback with its order.
|
|
398
366
|
|
|
@@ -604,6 +572,7 @@ class _BaseArchetype:
|
|
|
604
572
|
cls._key_ = cls.key
|
|
605
573
|
cls.key = _KeyDescriptor(cls.key)
|
|
606
574
|
cls.name = _NameDescriptor(cls.name)
|
|
575
|
+
cls._is_scored_ = cls.is_scored
|
|
607
576
|
cls.is_scored = _IsScoredDescriptor(cls.is_scored)
|
|
608
577
|
cls.life = _ArchetypeLifeDescriptor()
|
|
609
578
|
|
|
@@ -624,6 +593,7 @@ class _BaseArchetype:
|
|
|
624
593
|
"life",
|
|
625
594
|
"is_scored",
|
|
626
595
|
"_key_",
|
|
596
|
+
"_is_scored_",
|
|
627
597
|
"_derived_base_",
|
|
628
598
|
"_is_derived_",
|
|
629
599
|
"_default_callbacks_",
|
|
@@ -842,12 +812,14 @@ class PlayArchetype(_BaseArchetype):
|
|
|
842
812
|
|
|
843
813
|
Runs when the level is loaded after [`preprocess`][sonolus.script.archetype.PlayArchetype.preprocess].
|
|
844
814
|
"""
|
|
815
|
+
return 0.0
|
|
845
816
|
|
|
846
817
|
def should_spawn(self) -> bool:
|
|
847
818
|
"""Return whether the entity should be spawned.
|
|
848
819
|
|
|
849
820
|
Runs each frame while the entity is the first entity in the spawn queue.
|
|
850
821
|
"""
|
|
822
|
+
return True
|
|
851
823
|
|
|
852
824
|
def initialize(self):
|
|
853
825
|
"""Initialize this entity.
|
|
@@ -995,9 +967,11 @@ class WatchArchetype(_BaseArchetype):
|
|
|
995
967
|
|
|
996
968
|
def spawn_time(self) -> float:
|
|
997
969
|
"""Return the spawn time of the entity."""
|
|
970
|
+
return 0.0
|
|
998
971
|
|
|
999
972
|
def despawn_time(self) -> float:
|
|
1000
973
|
"""Return the despawn time of the entity."""
|
|
974
|
+
return 0.0
|
|
1001
975
|
|
|
1002
976
|
def initialize(self):
|
|
1003
977
|
"""Initialize this entity.
|
|
@@ -1134,16 +1108,16 @@ def get_archetype_by_name(name: str) -> AnyArchetype:
|
|
|
1134
1108
|
"""Return the archetype with the given name in the current mode."""
|
|
1135
1109
|
if not ctx():
|
|
1136
1110
|
raise RuntimeError("Archetypes by name are only available during compilation.")
|
|
1137
|
-
name = validate_value(name)
|
|
1138
|
-
if not name._is_py_():
|
|
1111
|
+
name = validate_value(name) # type: ignore
|
|
1112
|
+
if not name._is_py_(): # type: ignore
|
|
1139
1113
|
raise TypeError(f"Invalid name: '{name}'")
|
|
1140
|
-
name = name._as_py_()
|
|
1114
|
+
name = name._as_py_() # type: ignore
|
|
1141
1115
|
if not isinstance(name, str):
|
|
1142
1116
|
raise TypeError(f"Invalid name: '{name}'")
|
|
1143
1117
|
archetypes_by_name = ctx().global_state.archetypes_by_name
|
|
1144
1118
|
if name not in archetypes_by_name:
|
|
1145
1119
|
raise KeyError(f"Unknown archetype: '{name}'")
|
|
1146
|
-
return archetypes_by_name[name]
|
|
1120
|
+
return archetypes_by_name[name] # type: ignore
|
|
1147
1121
|
|
|
1148
1122
|
|
|
1149
1123
|
@meta_fn
|
|
@@ -1313,6 +1287,84 @@ class StandardArchetypeName(StrEnum):
|
|
|
1313
1287
|
TIMESCALE_CHANGE = "#TIMESCALE_CHANGE"
|
|
1314
1288
|
"""Timescale change marker"""
|
|
1315
1289
|
|
|
1290
|
+
TIMESCALE_GROUP = "#TIMESCALE_GROUP"
|
|
1291
|
+
"""Entity referenced by the timescale changes in a group"""
|
|
1292
|
+
|
|
1316
1293
|
|
|
1317
1294
|
type AnyArchetype = PlayArchetype | WatchArchetype | PreviewArchetype
|
|
1318
1295
|
"""Union of all archetype types."""
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
class StandardImportName:
|
|
1299
|
+
"""Standard import names for Archetype fields.
|
|
1300
|
+
|
|
1301
|
+
Usage:
|
|
1302
|
+
```python
|
|
1303
|
+
class MyArchetype(WatchArchetype):
|
|
1304
|
+
judgment: int = imported(name=StandardImportName.JUDGMENT)
|
|
1305
|
+
```
|
|
1306
|
+
"""
|
|
1307
|
+
|
|
1308
|
+
BEAT = "#BEAT"
|
|
1309
|
+
"""The beat of the entity."""
|
|
1310
|
+
|
|
1311
|
+
BPM = "#BPM"
|
|
1312
|
+
"""The bpm, for bpm change markers."""
|
|
1313
|
+
|
|
1314
|
+
TIMESCALE = "#TIMESCALE"
|
|
1315
|
+
"""The timescale, for timescale change markers."""
|
|
1316
|
+
|
|
1317
|
+
TIMESCALE_SKIP = "#TIMESCALE_SKIP"
|
|
1318
|
+
"""The scaled time to skip, for timescale change markers."""
|
|
1319
|
+
|
|
1320
|
+
TIMESCALE_GROUP = "#TIMESCALE_GROUP"
|
|
1321
|
+
"""The timescale group, for timescale change markers."""
|
|
1322
|
+
|
|
1323
|
+
JUDGMENT = "#JUDGMENT"
|
|
1324
|
+
"""The judgment of the entity.
|
|
1325
|
+
|
|
1326
|
+
Automatically set in watch mode for archetypes with a corresponding scored play mode archetype.
|
|
1327
|
+
"""
|
|
1328
|
+
|
|
1329
|
+
ACCURACY = "#ACCURACY"
|
|
1330
|
+
"""The accuracy of the entity.
|
|
1331
|
+
|
|
1332
|
+
Automatically set in watch mode for archetypes with a corresponding scored play mode archetype.
|
|
1333
|
+
"""
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
class StandardImport:
|
|
1337
|
+
"""Standard import annotations for Archetype fields.
|
|
1338
|
+
|
|
1339
|
+
Usage:
|
|
1340
|
+
```python
|
|
1341
|
+
class MyArchetype(WatchArchetype):
|
|
1342
|
+
judgment: StandardImport.JUDGMENT
|
|
1343
|
+
```
|
|
1344
|
+
"""
|
|
1345
|
+
|
|
1346
|
+
BEAT = Annotated[float, imported(name=StandardImportName.BEAT)]
|
|
1347
|
+
"""The beat of the entity."""
|
|
1348
|
+
|
|
1349
|
+
BPM = Annotated[float, imported(name=StandardImportName.BPM)]
|
|
1350
|
+
"""The bpm, for bpm change markers."""
|
|
1351
|
+
|
|
1352
|
+
TIMESCALE = Annotated[float, imported(name=StandardImportName.TIMESCALE)]
|
|
1353
|
+
"""The timescale, for timescale change markers."""
|
|
1354
|
+
|
|
1355
|
+
TIMESCALE_SKIP = Annotated[float, imported(name=StandardImportName.TIMESCALE_SKIP)]
|
|
1356
|
+
"""The scaled time to skip, for timescale change markers."""
|
|
1357
|
+
|
|
1358
|
+
TIMESCALE_GROUP = Annotated[EntityRef[Any], imported(name=StandardImportName.TIMESCALE_GROUP)]
|
|
1359
|
+
"""The timescale group, for timescale change markers."""
|
|
1360
|
+
|
|
1361
|
+
JUDGMENT = Annotated[int, imported(name=StandardImportName.JUDGMENT)]
|
|
1362
|
+
"""The judgment of the entity.
|
|
1363
|
+
|
|
1364
|
+
Automatically set in watch mode for archetypes with a corresponding scored play mode archetype.
|
|
1365
|
+
"""
|
|
1366
|
+
ACCURACY = Annotated[float, imported(name=StandardImportName.ACCURACY)]
|
|
1367
|
+
"""The accuracy of the entity.
|
|
1368
|
+
|
|
1369
|
+
Automatically set in watch mode for archetypes with a corresponding scored play mode archetype.
|
|
1370
|
+
"""
|
sonolus/script/easing.py
CHANGED
|
@@ -355,8 +355,8 @@ def smootherstep(x: float) -> float:
|
|
|
355
355
|
|
|
356
356
|
|
|
357
357
|
def step_start(x: float) -> float:
|
|
358
|
-
"""Step function returning 1.0 if x
|
|
359
|
-
return 1.0 if x
|
|
358
|
+
"""Step function returning 1.0 if x >= 0, otherwise 0.0."""
|
|
359
|
+
return 1.0 if x >= 0 else 0.0
|
|
360
360
|
|
|
361
361
|
|
|
362
362
|
def step_end(x: float) -> float:
|
|
@@ -42,7 +42,8 @@ debug_var = ContextVar("debug_var", default=_disabled_debug_config)
|
|
|
42
42
|
class GlobalContextState:
|
|
43
43
|
archetypes: dict[type, int]
|
|
44
44
|
archetypes_by_name: dict[str, type]
|
|
45
|
-
|
|
45
|
+
keys_by_archetype_id: Sequence[int]
|
|
46
|
+
is_scored_by_archetype_id: Sequence[bool]
|
|
46
47
|
rom: ReadOnlyMemory
|
|
47
48
|
const_mappings: dict[Any, int]
|
|
48
49
|
environment_mappings: dict[_GlobalInfo, int]
|
|
@@ -55,10 +56,14 @@ class GlobalContextState:
|
|
|
55
56
|
|
|
56
57
|
self.archetypes = archetypes or {}
|
|
57
58
|
self.archetypes_by_name = {type_.name: type_ for type_, _ in self.archetypes.items()} # type: ignore
|
|
58
|
-
self.
|
|
59
|
-
|
|
59
|
+
ordered_archetypes = sorted(self.archetypes, key=lambda a: self.archetypes[a])
|
|
60
|
+
self.keys_by_archetype_id = (
|
|
61
|
+
Array(*((getattr(a, "_key_", -1)) for a in ordered_archetypes)) if archetypes else Array[int, Literal[0]]()
|
|
62
|
+
)
|
|
63
|
+
self.is_scored_by_archetype_id = (
|
|
64
|
+
Array(*((getattr(a, "_is_scored_", False)) for a in ordered_archetypes))
|
|
60
65
|
if archetypes
|
|
61
|
-
else Array[
|
|
66
|
+
else Array[bool, Literal[0]]()
|
|
62
67
|
)
|
|
63
68
|
self.rom = ReadOnlyMemory() if rom is None else rom
|
|
64
69
|
self.const_mappings = {}
|
|
@@ -34,13 +34,13 @@ 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=eHh4ioOjaFtt26bcefUuDZhMhFw8NXnjRTYPiEInQV8,6505
|
|
36
36
|
sonolus/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
-
sonolus/script/archetype.py,sha256=
|
|
37
|
+
sonolus/script/archetype.py,sha256=HBg2cS6ZDy0zBbHH8Ieke5QOWR71PwFCmtJie8zDXiI,48957
|
|
38
38
|
sonolus/script/array.py,sha256=9uOUHZIDMyMT9q3APcXJWXWt97yG-AZoRlxwrvSY6SU,12367
|
|
39
39
|
sonolus/script/array_like.py,sha256=hUDdDaP306kflVv9YomdHIMXogrVjxsBXCrLvB9QpuE,9681
|
|
40
40
|
sonolus/script/bucket.py,sha256=SNqnfLGpnO_u-3LFFazdgzNk332OdDUIlmZHsuoVZuE,7674
|
|
41
41
|
sonolus/script/containers.py,sha256=L3rzPfN1cDb2m02k9qRyjnGxJx07X3q3MccCaL5tNJ8,18773
|
|
42
42
|
sonolus/script/debug.py,sha256=Vi97opuk9fMB5bdpzPCBpa2oZeTff7FQ4WzdeDE5trk,4557
|
|
43
|
-
sonolus/script/easing.py,sha256=
|
|
43
|
+
sonolus/script/easing.py,sha256=2FUJI_nfp990P_armCcRqHm2329O985glJAhSC6tnxs,11379
|
|
44
44
|
sonolus/script/effect.py,sha256=RQdsABqfi3sIku1jJDwyeD81devVyBhWQ47HIjfiMy0,5978
|
|
45
45
|
sonolus/script/engine.py,sha256=etI9dJsQ7V9YZICVNZg54WqpLijPxG8eTPHiV-_EiG8,10687
|
|
46
46
|
sonolus/script/globals.py,sha256=nlXSNS4NRXsgQU2AJImVIs752h1WqsMnShSKgU011c4,10270
|
|
@@ -71,7 +71,7 @@ sonolus/script/internal/__init__.py,sha256=T6rzLoiOUaiSQtaHMZ88SNO-ijSjSSv33TKtU
|
|
|
71
71
|
sonolus/script/internal/builtin_impls.py,sha256=R1h3IOlWzolPfc9yoma2cBN0F5cBhj_JNP-TTdKoBlc,13186
|
|
72
72
|
sonolus/script/internal/callbacks.py,sha256=vWzJG8uiJoEtsNnbeZPqOHogCwoLpz2D1MnHY2wVV8s,2801
|
|
73
73
|
sonolus/script/internal/constant.py,sha256=3ycbGkDJVUwcrCZ96vLjAoAARgsvaqDM8rJ_YCrLrvo,4289
|
|
74
|
-
sonolus/script/internal/context.py,sha256=
|
|
74
|
+
sonolus/script/internal/context.py,sha256=Cd9US3GNHxs_96UcVdBAXGD-H4gCNnV9h5OfCWbtoOg,17668
|
|
75
75
|
sonolus/script/internal/descriptor.py,sha256=XRFey-EjiAm_--KsNl-8N0Mi_iyQwlPh68gDp0pKf3E,392
|
|
76
76
|
sonolus/script/internal/dict_impl.py,sha256=alu_wKGSk1kZajNf64qbe7t71shEzD4N5xNIATH8Swo,1885
|
|
77
77
|
sonolus/script/internal/error.py,sha256=ZNnsvQVQAnFKzcvsm6-sste2lo-tP5pPI8sD7XlAZWc,490
|
|
@@ -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.6.
|
|
90
|
-
sonolus_py-0.6.
|
|
91
|
-
sonolus_py-0.6.
|
|
92
|
-
sonolus_py-0.6.
|
|
93
|
-
sonolus_py-0.6.
|
|
89
|
+
sonolus_py-0.6.5.dist-info/METADATA,sha256=cU1Ruyl2Nt__z5kalCBRw6jvSiIyq-WcShZvUyM8KgY,302
|
|
90
|
+
sonolus_py-0.6.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
91
|
+
sonolus_py-0.6.5.dist-info/entry_points.txt,sha256=oTYspY_b7SA8TptEMTDxh4-Aj-ZVPnYC9f1lqH6s9G4,54
|
|
92
|
+
sonolus_py-0.6.5.dist-info/licenses/LICENSE,sha256=JEKpqVhQYfEc7zg3Mj462sKbKYmO1K7WmvX1qvg9IJk,1067
|
|
93
|
+
sonolus_py-0.6.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|