Commit fd822a9
refactor: sequence-driven architecture with dynamic modes and extensible dispatch (#75)
* refactor(sequencer): move sequencer from battle to core
Move sequencer module and chapter_schema from app_state/battle/ to
core/sequencer/ to make it reusable across AppStates.
- Rename BattleContext → SequenceContext
- Rename BattleExecutionState → SequenceExecutionState
- Add SequencerUpdate SystemSet (callers configure when it runs)
- Move SequenceAsset type into core::sequencer
- BattlePlugin configures SequencerUpdate.in_set(BattleUpdate)
- Update all imports in core/view/ files
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(sequencer): move sequencer to core and add overworld sequence support
Phase 1: Move battle/sequencer/ to core/sequencer/
- Rename BattleContext → SequenceContext
- Rename BattleExecutionState → SequenceExecutionState
- Create SequencerUpdate SystemSet (state-agnostic)
- SequenceAsset and chapter_schema now live in core
- BattlePlugin configures SequencerUpdate via lib.rs run_if
Phase 2: Add LoadMap and SetBgm Chapter variants
- LoadMap: spawns TiledMap entity from .tmx path
- SetBgm: plays/stops BGM via bevy_kira_audio
- New processing systems: load_map.rs, bgm.rs
Phase 3: Overworld sequence entry support
- Add load_overworld_sequence_system on OnEnter(Overworld)
- Sequence-driven mode skips hardcoded player spawning
- Create example overworld_entry.sequence.ron
Phase 4: Config integration
- Add initial_sequence_path to GameConfig
- Generalize BattleRulesHandle → SequenceRulesHandle
- Configure SequencerUpdate for both Overworld and Battle
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chore: remove overworld_sequence_refactor.md from git tracking
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(overworld): remove hardcoded OnEnter setup, require sequence-driven entry
- Remove create_overworld_entities_system (hardcoded SpawnPlayerRequest)
- Remove setup_tilemap_system from OnEnter(Overworld) (LoadMap chapter replaces this)
- load_overworld_sequence_system now errors when no initial_sequence_path configured
- Move example sequence to actual mod (projects/example_mod/)
- Delete doc/examples/ directory
- Remove overworld_sequence_refactor.md from .gitignore (just not committed instead)
- Update app_setup state transition to check initial_sequence_path
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(config): add initial_sequence_path to GameConfigPartial for mod.toml loading
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(sequencer): make player spawn sequence-driven for overworld
- PlayerAction::Spawn fields are now Option (config_path, position)
- config_path: Some → battle player spawn (BattlePlayerConfig)
- config_path: None → overworld player spawn (PlayerBehavior via SpawnPlayerRequest)
- Remove hardcoded SpawnPlayerRequest from load_overworld_sequence_system
- Add process_overworld_player_spawn_system for overworld chapter handling
- Re-export ActiveChapter, ChapterFinished, WaitTimer from sequencer module
- Update entry.sequence.ron to include SetPlayer(Spawn())
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: replace AppState::Overworld/Battle with GameMode state
- AppState now only has AppSetup, Menu, Playing (lifecycle only)
- New GameMode state: None, Overworld, Battle (sequence-controlled)
- All system sets gate on GameMode instead of AppState
- All OnEnter/OnExit use GameMode for mode-specific transitions
- Remove dead code: setup_tilemap_system, PreloadedMaps, preload_maps_system
- Make player config_path required (explicit reference in sequence RON)
- Update 17 files across the codebase
- Debug panel now shows both AppState and GameMode
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: mark TiledMap entities with OverworldEntity for cleanup on mode switch
TiledMap entities spawned by core sequencer's LoadMap lacked the
OverworldEntity marker, preventing cleanup when switching to Battle.
Added reactive mark_tilemap_as_overworld_entity system.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(sequencer): reorganize imports and adjust system ordering
* refactor: implement Architecture v2 - sequence-driven dynamic modes
- Replace GameMode enum with SequenceMode(Option<String>) resource
- Replace OverworldEntity/BattleEntity with ModeScoped(String) component
- Replace OverworldSubState with generic SequenceSubState(String) state
- Add ModeChanged message for mode transition detection
- Add detect_mode_changes and cleanup_mode_scoped_entities systems
- Add mode/exits fields to SequenceAsset for data-driven mode control
- Set SequenceMode automatically when loading sequence assets
- Rename AppState::AppSetup→Loading, AppState::Playing→Running
- Update 35 files across all modules (view, fre_bridge, debug, etc.)
- All tests pass, zero hardcoded mode references remain
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(debug): remove stale AppState::Menu reference from fre_panel
The AppState enum was simplified to Loading/Running in the sequence-driven
architecture refactor, but the debug FRE panel still referenced the removed
Menu variant, causing a compile error with --all-features.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(fre): update stale @overworld_state fact reference to @sequence_sub_state
The FRE rule 'overworld_open_backpack' in demo.fre.ron referenced the old
fact name `@overworld_state` which was renamed to `@sequence_sub_state`
during the Sequence-Driven Architecture v2 refactor. This caused the
backpack to never open because the condition never matched.
Also updated stale doc comments in fre_bridge.rs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(fre): rename action types to match sequence-driven architecture
- SetOverworldState → SetSubState (operates on SequenceSubState, mode-agnostic)
- StartBattle → SetMode (generic mode switch with 'mode' param, replaces hardcoded 'battle')
- Update demo.fre.ron to use new action names (gitignored, local only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(chase): move hardcoded visual params to ChaseConfig
Move overlay_size, z_offset, and outline padding from hardcoded values
to configurable fields in DarkOverlayConfig and OutlineConfig:
- DarkOverlayConfig: +overlay_size (default: 10000.0), +z_offset (default: 50.0)
- OutlineConfig: +padding (default: 2.0), +z_offset (default: 100.0)
All values retain their original defaults via serde(default).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(am): move default battle box size to AmBattleConfig
Add default_battle_box_size field to AmBattleConfig (default: 565x140).
Previously hardcoded as fallback when AM layer size couldn't be determined.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(fre): extract hardcoded fact keys to fre_facts constants
Create core::fre_facts module with centralized constants for all FRE
fact key strings (~30 keys across dialogue, state, view, player, enemy).
Replace all hardcoded string literals in 8 files with constant references.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(battle): remove deprecated TriggerDialogue action handler
This action was a no-op that only logged a deprecation warning.
Dialogue triggering should be done via FRE rule modifications.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(am): rename AmBattleEntity to AmEntity
The 'Battle' prefix was misleading - this is an AM subsystem internal
marker component, not related to the old BattleEntity (now ModeScoped).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(fre): unify Custom action dispatch via FreCustomActionEvent
Replace triple rule-evaluation dispatch (handle_chase_state_actions,
collect_danmaku_actions, process_view_actions for Custom) with a
single unified dispatch pipeline:
1. dispatch_custom_actions_system reads events, matches rules,
evaluates global conditions, emits FreCustomActionEvent
2. handle_overworld_custom_actions_system handles all action types
(EnterChaseState, SetMode, SpawnView, PlayDanmaku, etc.)
This eliminates redundant rule evaluation and makes adding new
Custom action types trivial - just add a match arm in the handler
or register a new system consuming FreCustomActionEvent.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat(sequencer): add Custom chapter variant for extensible sequences
Add Chapter::Custom { action_type, params } variant that dispatches
as FreCustomActionEvent during execution, completing immediately.
Editors and mods can define custom sequence nodes; handler systems
consume FreCustomActionEvent for their specific action types.
Use AwaitFact after Custom if the action needs to signal completion.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(view): unify View lifecycle through SpawnViewRequest
All View spawning (backpack, battle, chase HUD, dialogue) now goes through
a single unified path: SpawnViewRequest → handle_spawn_view_request_system
→ spawn_dynamic_view_system.
Removed:
- BackpackViewRoot, BattleViewRoot, ChaseHUDRoot marker components
- ViewLayoutHandle global resource (replaced by per-entity HotReloadableViewRoot)
- spawn_ron_view_system (merged into spawn_dynamic_view_system)
- PendingViewBindings global resource (replaced by per-entity PendingViewData)
- update_view_from_map_system (simplified to validate_map_properties_system)
Added:
- SpawnViewRequest.mode_scope: Optional ModeScoped for auto-cleanup
- SpawnViewRequest.bindings: Optional data bindings for interface requirements
- PendingViewData component: Per-entity binding/FRE handle storage
- spawn_dynamic_view_system now handles bindings and FRE asset waiting
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(core): streamline FRE action dispatch and integrate ActionHandlerRegistry
* refactor(overworld): simplify conditionals and improve code style
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 259de0f commit fd822a9
File tree
65 files changed
+1771
-1629
lines changed- crates
- souprune/src
- app_state
- battle
- fre
- sequencer
- overworld
- character
- player
- tilemap
- core
- danmaku
- dialogue
- sequencer
- view
- components
- layout
- reconcile
- ron_view
- extra/debug
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
65 files changed
+1771
-1629
lines changedSubmodule bevy_fact_rule_event updated 1 file
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 3 | | |
8 | 4 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 5 | + | |
| 6 | + | |
28 | 7 | | |
29 | | - | |
| 8 | + | |
| 9 | + | |
30 | 10 | | |
31 | 11 | | |
32 | 12 | | |
33 | 13 | | |
34 | 14 | | |
| 15 | + | |
35 | 16 | | |
36 | | - | |
37 | 17 | | |
38 | 18 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
45 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
46 | 113 | | |
47 | 114 | | |
48 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
48 | | - | |
| 46 | + | |
49 | 47 | | |
50 | 48 | | |
51 | 49 | | |
| |||
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
| 143 | + | |
145 | 144 | | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | 151 | | |
158 | 152 | | |
159 | 153 | | |
| |||
169 | 163 | | |
170 | 164 | | |
171 | 165 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | 166 | | |
176 | 167 | | |
177 | 168 | | |
| |||
183 | 174 | | |
184 | 175 | | |
185 | 176 | | |
186 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
187 | 181 | | |
188 | 182 | | |
189 | 183 | | |
190 | 184 | | |
191 | 185 | | |
192 | 186 | | |
193 | | - | |
| 187 | + | |
194 | 188 | | |
195 | | - | |
| 189 | + | |
196 | 190 | | |
197 | 191 | | |
198 | 192 | | |
| |||
343 | 337 | | |
344 | 338 | | |
345 | 339 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | 340 | | |
380 | 341 | | |
381 | 342 | | |
| |||
0 commit comments