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
|
|
@ -33,10 +33,8 @@ program NpcAiDemo {
|
|||
@OnSpawn(Ally) handler AInit { }
|
||||
@OnSpawn(Dummy) handler DInit { }
|
||||
|
||||
state NpcaidemoState {
|
||||
spotted: int = 0
|
||||
}
|
||||
@On(TargetSpotted) handler OnSpot(npcaidemo_st: mut NpcaidemoState) { npcaidemo_st.spotted += 1 }
|
||||
var spotted: int = 0
|
||||
@On(TargetSpotted) handler OnSpot { spotted += 1 }
|
||||
|
||||
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
|
||||
function bi(b: bool) -> int { if b { return 1 }; return 0 }
|
||||
|
|
@ -57,7 +55,7 @@ program NpcAiDemo {
|
|||
return -1
|
||||
}
|
||||
|
||||
entry (npcaidemo_st: NpcaidemoState) {
|
||||
entry {
|
||||
let PBr = World.prop_id("Brain")
|
||||
|
||||
Weapon.def("blaster", 4, 10, 10, 0, 1, 0)
|
||||
|
|
@ -74,7 +72,7 @@ program NpcAiDemo {
|
|||
|
||||
# ---- A. perception: the enemy spots the hostile dummy -------------------
|
||||
tick_n(4)
|
||||
print(bi(npcaidemo_st.spotted >= 1)) # 1 — TargetSpotted fired
|
||||
print(bi(spotted >= 1)) # 1 — TargetSpotted fired
|
||||
print(bi(Ai.target(enemy) == dummy)) # 1 — remembers the right target
|
||||
|
||||
# ---- B. FSM attack: in range -> auto-aim + fire -> dummy takes damage ---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue