wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -8,11 +8,9 @@ program Prefabs {
|
|||
model Creature { Position, Enemy }
|
||||
prefab Foe: Creature { Enemy { team: 2, hp: 1 }, Position { y: 9 } }
|
||||
prefab Grunt: Foe { Enemy { kind: 1, hp: 30 } }
|
||||
state PrefabsState {
|
||||
last: int = -1
|
||||
}
|
||||
@OnSpawn(Creature) handler Remember(prefabs_st: mut PrefabsState) { prefabs_st.last = self() }
|
||||
entry (prefabs_st: PrefabsState) {
|
||||
var last: int = -1
|
||||
@OnSpawn(Creature) handler Remember { last = self() }
|
||||
entry {
|
||||
let g = spawn Grunt { Position { x: 5 } } # Foe's presets, Grunt's, then this
|
||||
print(Enemy.of(g).team * 100000 + Enemy.of(g).hp * 1000 + Enemy.of(g).kind * 100 + Position.of(g).x * 10 + Position.of(g).y)
|
||||
let n = Prefab.spawn(name: "Grunt")
|
||||
|
|
@ -22,6 +20,6 @@ program Prefabs {
|
|||
print(Position.of(placed).x)
|
||||
print(Position.of(placed).y)
|
||||
print(Prefab.spawn(name: "Nope")) # no such prefab
|
||||
print(prefabs_st.last) # self() in the hook: the last spawn
|
||||
print(last) # self() in the hook: the last spawn
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue