Added BaseLifetimescope and gameplay scene

This commit is contained in:
Savya Bikram Shah
2026-05-26 18:59:54 +05:45
parent a1ba052ece
commit 0b4aeb8fd8
24 changed files with 647 additions and 133 deletions

View File

@@ -88,6 +88,9 @@ Assets/Darkmatter/Code/
│ ├── Coloring/
│ │ ├── IColorPalette.cs
│ │ └── PaintCommandDTO.cs
│ ├── Paper/ (shared art rig — RT-as-paper)
│ │ ├── IPaperRig.cs
│ │ └── IArtInputBridge.cs
│ ├── History/
│ │ ├── ICommand.cs
│ │ └── IUndoStack.cs
@@ -122,6 +125,7 @@ Assets/Darkmatter/Code/
└── Features/
├── MainMenu/
├── DrawingCatalog/
├── Paper/ (RT paper rig — ArtCamera + RenderTexture + input bridge)
├── ShapeBuilder/
├── Coloring/
├── History/
@@ -209,33 +213,60 @@ Failures show a child-friendly retry screen; never crash.
## 7. Rendering Strategy
Hybrid: **Sprites for artwork, Canvas for HUD**.
**RT-as-paper.** ArtCamera renders the drawing world to an offscreen `RenderTexture`. A Canvas `RawImage` displays that RT. HUD lives on the same Canvas, above the RawImage. The RT *is* the paper — same fixed coordinate system on every device.
```
┌──────────────────────────────────────────────────────┐
│ UICanvas (Screen-Space - Camera, UICamera) │
│ │
│ ┌────────────────────────────────────┐ │
│ │ RawImage (AspectRatioFitter 1:1) │ [HUD] │
│ │ └─ texture = PaperRig.Surface │ palette │
│ │ │ undo etc │
│ │ ArtCamera renders → here │ │
│ └────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────┘
│ rendered offscreen
ArtCamera (orthographicSize fixed, aspect = 1f)
culling mask: Artwork, PaperBackground, Effects
target texture: PaperRig.Surface (2048×2048 ARGB32)
```
### Cameras
| Camera | Type | Culling Mask | Purpose |
|---|---|---|---|
| `ArtCamera` | Orthographic | `Artwork`, `PaperBackground` | Renders the drawing only. Source for capture. |
| `UICamera` | Overlay (or screen-space) | `UI` | HUD canvas, palette, buttons. |
| Camera | Type | Culling Mask | Render Target | Purpose |
|---|---|---|---|---|
| `ArtCamera` | Orthographic, **fixed ortho size**, aspect = 1 | `Artwork`, `PaperBackground`, `Effects` | `PaperRig.Surface` (offscreen RT) | Renders the drawing world. Never sees the screen. |
| `UICamera` | Camera (Screen-Space Camera) | `UI` | Screen | Displays the paper RawImage + HUD. |
### Layers
| Layer | Used by |
|---|---|
| `Artwork` | Drawing region sprites, shape pieces, paper bg |
| `UI` | All Canvas elements |
| `Effects` | Particle bursts, sparkles on completion |
| `Artwork` | Drawing region sprites, shape pieces, paper bg, all in ArtCamera world |
| `Effects` | Particle bursts, sparkles — also in ArtCamera world (so they're captured into the PNG) |
| `UI` | All Canvas elements (RawImage paper + HUD) |
### Why hybrid
### Why RT-as-paper
| Need | Choice | Why |
|---|---|---|
| Per-region tap-to-fill | Sprites + `PolygonCollider2D` | Clean `Physics2D.OverlapPoint`; deterministic; no shader work for the toddler region count (520). |
| Drag/drop shape pieces | Sprites + Physics2D | Natural world bounds, easy snap distance checks. |
| Capture to PNG with paper bg | Sprites under dedicated Camera | `RenderTexture` from `ArtCamera` excludes HUD automatically. |
| Color palette, buttons | Canvas | Anchors handle aspect ratios. Buttons + ScrollRect free. |
| Per-region tap-to-fill | Sprites + `PolygonCollider2D` in ArtCamera world; tapped via `IArtInputBridge` | Coordinate system is fixed (RT space). One `Physics2D.OverlapPoint` call after screen→art-world conversion. |
| Drag/drop shape pieces | Sprites + Physics2D in art world | Same fixed bounds on every device — no per-aspect tray layout. |
| Capture to PNG | `RT → Texture2D → PNG` | The RT *is* the saved image. No camera state override, no compositing pass, no determinism worries. |
| Multi-resolution support | `AspectRatioFitter (1:1, FitInParent)` on the RawImage | The "fit camera" problem reduces to a single Canvas property. Letterbox/pillarbox = whatever the Canvas around the RawImage looks like. |
| Color palette, buttons | Canvas above the RawImage | Anchors handle aspect ratios. Buttons + ScrollRect free. |
| Drawing catalog grid | Canvas | `GridLayoutGroup` + ScrollRect, async thumbnail loader. |
### Multi-resolution rule
The artwork world is **screen-size-independent by construction.** Author every drawing in a fixed 2048×2048 design rect (or 20×20 world units at PPU=100). Pieces, regions, snap radii, slot positions — all expressed in this space and never scaled at runtime. Different screen sizes only change how the *RawImage* is laid out on the Canvas; the contents of the RT stay identical.
If you need a backdrop (wood/cloth behind the paper), it's a sibling Canvas Image *outside* the RawImage, sized to fill the screen. The RT itself has a transparent or paper-colored background.
---
## 8. Core Contracts