# HappyMahjong Project Facts

> Evidence collected from `/Users/lionqu/Github/NewHappyMahjongClient/HappyMahjongClient` without running Unity.

## Project location

- Project root: `/Users/lionqu/Github/NewHappyMahjongClient/HappyMahjongClient`
- Unity version: `2021.3.15f1`
  - Evidence: `ProjectSettings/ProjectVersion.txt`

## Startup scene

- First enabled scene: `Assets/Scenes/AppMainScene.unity`
  - Evidence: `ProjectSettings/EditorBuildSettings.asset`
- `AppMainScene.unity` contains a GameObject named `LoadDll` with script `Assets/Scripts/Boot/LoadDll.cs`.
  - Evidence: script GUID from `Assets/Scripts/Boot/LoadDll.cs.meta` is referenced in `Assets/Scenes/AppMainScene.unity`.

## Startup flow relevant to onboarding

1. Open the project with Unity `2021.3.15f1`.
2. Open `Assets/Scenes/AppMainScene.unity`.
3. AppMainScene starts `LoadDll`.
4. `LoadDll` loads bootstrap / hotload DLLs, then calls `LoadScenePrefab()`.
5. `LoadScenePrefab()` instantiates:
   - `JavaCallbackObject`
   - `UIRoot` → renamed to `UI Root`
   - `AppMainRoot`
6. `AppMainRoot` uses `AppRoot : ContextView`.
7. `AppRoot.Start()` creates `context = new AppContext(this)`.
8. `AppContext` binds global models, services, commands, mediators, and cross-context events.

Key files:

- `Assets/Scripts/Boot/LoadDll.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/AppMain/AppRoot.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/AppMain/AppContext.cs`

## Framework

The project uses StrangeIoC / MVCS.

Important classes and patterns:

- `ContextView`: MonoBehaviour that owns a context.
- `MVCSContext`: StrangeIoC context that registers injection, command, mediation and cross-context bindings.
- `AppContext`: main hall context.
- `LoginContext`: login context.
- `GameContext`: in-game context.
- `SelectionContext`: selection context.
- `IStrangeContext`: project module interface with:
  - `InjectionBinder`
  - `CommandBinder`
  - `MediationBinder`
  - `CrossContextBridgeBind`
  - `UnBindCrossContextBinder`

Key files:

- `Assets/Scripts/Base/StrangeIoC/` — framework source; do not modify during onboarding tasks.
- `Assets/Scripts/InGameScripts/InGameScripts/GameFoundation/ModuleRegister/IStrangeContext.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/LoginRoot.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/LoginContext.cs`

## UI reality

Current new UI development should not use NGUI as the active UI framework. NGUI-related directories/classes remain mainly for historical compatibility. `UIEventListener` is still used because it is not treated as an NGUI-only concept in practice and is convenient for click binding. `EmptyClick` / `emptyClick` / `CloseEmptyClick` objects appear in prefabs as empty click receivers for background clicks, close areas, or click-through blocking.

For onboarding, teach these rules:

- Find existing similar UI and follow it.
- UI loading should go through `UIUtil`.
- Popup display should go through `PopUpManager`.
- Click binding may use `Button.onClick`, `UIEventListener.Get(...).onClick`, or an Empty Click object depending on the surrounding module.
- Seeing `UIEventListener` does not mean the feature should be implemented with NGUI.
- Do not directly use `Resources.Load` or raw `Object.Instantiate` for production UI unless the surrounding code already does and owner confirms.

Project docs:

- `Docs/02-systems/ui-system.md`

Key files / concepts:

- `Assets/Scripts/ResMgr/Common/Util/UIUtil.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/UICommon/PopUpManager.cs`
- `UIEventListener.Get(gameObject).onClick`
- `EmptyClick` / `emptyClick` / `CloseEmptyClick` prefab objects

## Login module example

Useful first real feature chain:

- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/View/LoginView.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/View/LoginMediator.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/Controller/LoginPlatformCommand.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/Controller/LoginTSDKCommand.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/LoginManager.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/LoginController.cs`
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Login/LoginContext.cs`

Project docs:

- `Docs/01-flows/login-flow.md`

## Module templates and module boundaries

New modules must use templates from:

- `Assets/Editor/Prefab2Code/Scripts/ScriptTemplates/`

Observed template folders:

- `StrangeIoc`
- `弹窗式StrangeIoc模板`
- `ChildActivity`
- `RecyclableScrollView`
- `游戏玩法开发模板`
- `s级牌桌模板`
- `防暴力点击`
- `客户端本地数据记录`

Teaching rules:

- For new modules, do not let agents hand-write a module skeleton from scratch; pick a template first.
- For existing modules, locate the module directory and keep edits inside that boundary where possible.
- Cross-module edits require architecture impact review before implementation.

## Risk files and directories

Teach these as project-specific red flags:

- `Assets/Scripts/Base/StrangeIoC/` — framework source, don't modify for product tasks.
- `Assets/Scripts/InGameScripts/InGameScripts/Game/View/GameUIView.cs` — huge game UI file.
- `Assets/Scripts/InGameScripts/InGameScripts/Game/View/GameTableView.cs` — huge table view.
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/AppMain/AppContext.cs` — core binding file.
- `Assets/Scripts/InGameScripts/InGameScripts/Game/GameContext.cs` — game binding file.
- `Assets/Scripts/InGameScripts/InGameScripts/Hall/Selection/SelectionContext.cs` — selection binding file.
- `Assets/Scripts/CodeGen/` and `Assets/Scripts/Generated/` — generated code.
- `Packages/`, `ProjectSettings/`, `.unity`, `.prefab`, `.asset`, `.meta` — normal Unity high-risk categories.

Project docs:

- `Docs/04-ai-index/risky-files.md`
- `Docs/04-ai-index/code-map.md`
