How mentai-baguette/guild_academy works
1. Repository shape
This is a Unity 6.4 2D RPG project organized around a clean split between pure game logic and Unity-facing adapters. The main code lives under Assets/_Project/Scripts/Core and is wrapped by MonoBehaviours in Assets/_Project/Scripts/MonoBehaviours. Content is mostly data-driven via ScriptableObjects and Resources assets.
2. Primary runtime layers
The architecture has three important layers:
- Core domain logic: battle, branching, dialogue, dungeon, calendar, party, save, character progression.
- Unity presentation/interaction layer: scene objects, player/NPC controllers, UI, scene transitions, loaders.
- Content layer: ScriptableObjects and resource-backed data files for characters, enemies, skills, dungeons, themes, dialogue, and audio.
3. Core versus MonoBehaviour boundary
The Core assemblies contain reusable systems with minimal Unity dependency, intended to be unit-testable. The MonoBehaviours assembly bridges those systems to scenes, input, UI, and Unity lifecycle events. This boundary is central to the repo: the core owns rules, while the MonoBehaviours own wiring and user interaction.
4. Battle subsystem
Battle is a self-contained subsystem under Core/Battle, with ATBSystem, ActionExecutor, DamageCalculator, BreakSystem, StatusEffectSystem, FormationSystem, BossPhaseManager, and enemy AI implementations (BasicEnemyAI, ShionBossAI). The flow is: ATB gauges fill, a command is selected, damage/status/break logic is resolved, then enemy AI and boss phase changes advance the turn state. BattleFlowController orchestrates the sequence.
5. Battle UI and encounter entry
The Unity-side battle entry points are BattleManager and BattleUIManager. Field triggers likely transition into battle via EncounterTrigger, with battle setup data coming from BattleSetupData and content assets for enemies/skills. The battle UI is therefore an adapter over the core battle engine rather than the engine itself.
6. Branching and ending system
Story progression is driven by a dedicated branching subsystem: FlagSystem, TrustSystem, AcademyRefusalChecker, EndingResolver, EndingContext, and BranchService. The game’s “mystery” structure is represented as information flags plus trust values, which together determine route changes and ending selection. This is one of the major game-specific decision boundaries in the architecture.
7. Dialogue subsystem
Dialogue has its own core pipeline: DialogueParser turns dialogue JSON into DialogueData / DialogueLine, DialogueRunner advances the conversation, and DialogueManager coordinates presentation state. ResourcesDialogueJsonLoader is the Unity adapter that loads chapter dialogue from Assets/Resources/Dialogues, with DialogueUI, ChoiceUI, and DialogueUIBridge handling on-screen presentation and branching choices.
8. Field, dungeon, and scene flow
The game uses distinct scenes for Title, Field, Battle, Dungeon, and SampleScene. Field gameplay is handled by PlayerController, NPCController, BedInteraction, InfoFlagTrigger, EncounterTrigger, and AcademyPathTracker. Dungeon progression is separated into DungeonManager / DungeonManagerMB, indicating a distinct exploration mode from the overworld field loop.
9. Progression systems
Character and campaign progression are split into several core systems:
- LevelSystem for character growth
- ErosionSystem for the “corruption/abyss power” mechanic
- SoulLinkSystem for relationship-linked bonuses and ending impact
- CalendarManager and ScheduleManager for time progression and event scheduling
These systems suggest the game advances on a calendar basis, with story scenes, dungeon runs, and social events competing for time.
10. Data and content model
Most content is stored as asset data rather than hardcoded values. ScriptableObjects define CharacterDataSO, EnemyDataSO, SkillDataSO, DungeonDataSO, ItemDataSO, and UIThemeSO. Supporting enums and DTO-like types in Core/Data include CharacterId, CharacterStats, SkillData, ItemData, BattleCommand, BattlePhase, SceneNames, and SceneTransitionData. This makes the project highly data-driven and easy to balance without code changes.
11. Save/load boundary
Persistence is isolated behind SaveData, ISaveSerializer, SaveSerializer, and the Unity adapter UnitySaveSerializer. This indicates a serialization boundary between game state and storage format, likely so the core state can be saved independently of platform-specific file I/O. Save data likely captures progression systems, flags, trust, calendar state, and party state.
12. UI and presentation
UI is separated into reusable themed components: ThemedButton, ThemedWindow, GaugeUI, TitleUI, and SceneTransitionManager. Theme assets such as Theme_Ch1_Academy suggest per-chapter presentation styling. TextMesh Pro and URP 2D are used for presentation, but they are infrastructure rather than core architectural drivers.
13. Audio and production assets
Audio is organized by purpose: BGM for major game states and SE for gameplay feedback. The asset layout indicates the game uses sound cues for battle, selection, healing, level-up, game over, and clearing events. This is a supporting subsystem, but it reinforces the game’s state-driven flow.
14. Testability and CI
The repo includes extensive EditMode tests for battle, branching, dialogue, calendar, dungeon, save, schedule, and character systems. That aligns with the core/domain split: rules are designed to be testable without full Unity scenes. CI runs through GitHub Actions with game-ci/unity-test-runner, so automated validation is an explicit part of the architecture.
15. How to draw the architecture
A good diagram would place the core systems in the center, with arrows from MonoBehaviour scene controllers/UI into them, and arrows from ScriptableObject/Resources content into the core via loaders and setup data. Surround that with the major game modes—field exploration, dungeon exploration, battle, dialogue, branching/story, save/load, and schedule progression—all coordinated by scene transitions and the calendar/branching state.
Main entry points: BattleFlowController.cs Battle core · BranchService.cs Branching core · Field.unity Scenes · SaveSerializer.cs Save core
Components 22
Core systems
Pure game rules and reusable domain logic.
- Battle core · Turn flow, ATB, damage, status, break, formation, AI, and boss phases.
Assets/_Project/Scripts/Core/Battle/BattleFlowController.cs - Battle rules · ATB filling, action execution, damage calculation, break/status resolution, and formation handling.
Assets/_Project/Scripts/Core/Battle/ATBSystem.cs - Enemy AI · Enemy decision logic including basic enemies and the Shion boss behavior.
Assets/_Project/Scripts/Core/Battle/BasicEnemyAI.cs - Branching core · Flags, trust, refusal checks, and ending resolution for route selection.
Assets/_Project/Scripts/Core/Branch/BranchService.cs - Dialogue core · Dialogue parsing, data model, runner, and manager for chapter conversations.
Assets/_Project/Scripts/Core/Dialogue/DialogueParser.cs - Calendar · Campaign time progression and scheduling backbone.
Assets/_Project/Scripts/Core/Calendar/CalendarManager.cs - Progression · Leveling, erosion, and soul-link relationship progression.
Assets/_Project/Scripts/Core/Character/LevelSystem.cs - Party · Party composition and party-level management.
Assets/_Project/Scripts/Core/Party/PartyManager.cs - Save core · Save data model and serializer boundary independent of Unity I/O.
Assets/_Project/Scripts/Core/Save/SaveSerializer.cs - Dungeon core · Dungeon progression and dungeon data model.
Assets/_Project/Scripts/Core/Dungeon/DungeonManager.cs
Unity adapters
MonoBehaviours that wire scenes, input, UI, and lifecycle to core systems.
- Field controllers · Player, NPC, triggers, and path tracking in the overworld field scene.
Assets/_Project/Scripts/MonoBehaviours/Field/PlayerController.cs - Battle adapters · Unity battle entry and UI wiring around the core battle engine.
Assets/_Project/Scripts/MonoBehaviours/Battle/BattleManager.cs - Dialogue UI · Resources-based dialogue loading and dialogue/choice presentation bridge.
Assets/_Project/Scripts/MonoBehaviours/Dialogue/ResourcesDialogueJsonLoader.cs - Branch UI · MonoBehaviour boundary for branching and story-state interaction.
Assets/_Project/Scripts/MonoBehaviours/Branch/BranchManager.cs - Dungeon adapter · Unity-facing dungeon manager wrapper.
Assets/_Project/Scripts/MonoBehaviours/Dungeon/DungeonManagerMB.cs - Party adapter · Unity wrapper for party management.
Assets/_Project/Scripts/MonoBehaviours/Party/PartyManagerMB.cs - Save adapter · Unity serializer bridge for persistence.
Assets/_Project/Scripts/MonoBehaviours/Save/UnitySaveSerializer.cs
Content assets
ScriptableObjects, Resources, and dialogue data that feed gameplay systems.
- SO content · ScriptableObject definitions for characters, enemies, skills, dungeons, items, and themes.
Assets/_Project/Scripts/ScriptableObjects/CharacterDataSO.cs - Resources data · Enemy, skill, character, and dialogue assets loaded at runtime.
Assets/Resources/Data/Enemies/Enemy_Goblin.asset - Dialogue JSON · Chapter dialogue source used by the dialogue pipeline.
Assets/Resources/Dialogues/chapter1_dialogue.json
Presentation
UI and scene flow components that present game state.
Connections 30
- Field controllers → Calendar: advances time · Field interactions and daily flow feed the campaign calendar.
- Field controllers → Branching core: sets flags · Triggers and NPC interactions update story flags and trust.
- Field controllers → Battle adapters: starts encounters · Field encounter triggers transition into battle setup.
- Battle adapters → Battle core: drives combat · BattleManager and battle UI wrap the core combat engine.
- Battle core → Battle rules: resolves turns · ATB, actions, damage, break, and status are the combat pipeline.
- Battle core → Enemy AI: requests AI · Enemy and boss AI select actions within the battle loop.
- Branch UI → Branching core: applies story state · Unity-side branching surfaces feed core route and ending logic.
- Dialogue UI → Dialogue core: runs dialogue · The UI adapter loads and presents dialogue through the core runner.
- Dialogue UI → Dialogue JSON: loads chapters · Dialogue JSON is the runtime source for chapter conversations.
- Dialogue core → Branching core: branches choices · Dialogue choices can affect flags, trust, and route selection.
- Dungeon adapter → Dungeon core: wraps exploration · Unity dungeon manager delegates to the core dungeon system.
- Party adapter → Party: syncs party · Scene-side party wrapper keeps core party state in step with the game.
- Save adapter → Save core: serializes state · Unity-specific storage is separated from the core save model.
- UI layer → Dialogue core: shows text · Dialogue UI presents conversation state and choices.
- UI layer → Battle adapters: shows battle · Battle gauges, windows, and scene transitions present battle state.
- UI layer → Scenes: changes scenes · Scene transition UI controls movement between title, field, battle, and dungeon.
- SO content → Battle core: defines stats · Character, enemy, skill, and dungeon assets provide battle inputs.
- SO content → Dungeon core: defines dungeons · Dungeon ScriptableObjects feed dungeon progression and encounters.
- Resources data → Battle core: feeds encounters · Resource-backed enemy and skill data populate combat setup.
- Resources data → Dialogue UI: feeds loaders · Runtime dialogue files are loaded through the Resources adapter.
- Scenes → Field controllers: hosts field · Field scene contains overworld controllers and triggers.
- Scenes → Battle adapters: hosts battle · Battle scene contains combat UI and setup.
- Scenes → Dungeon adapter: hosts dungeon · Dungeon scene contains dungeon exploration adapters.
- Scenes → UI layer: hosts UI · Shared UI and title flow span the scene stack.
- Calendar → Branching core: gates events · Time progression can influence story availability and endings.
- Progression → Battle core: affects combat · Level, erosion, and soul-link progression change battle outcomes.
- Progression → Branching core: affects endings · Relationship and corruption systems feed route and ending logic.
- Save core → Calendar: persists state · Calendar state is part of the campaign save model.
- Save core → Branching core: persists flags · Story flags and trust values are persisted across sessions.
- Save core → Progression: persists growth · Character progression data is saved and restored.