# Environment Prefab / Chunk Pattern

This manual explains how environment objects should be organized.

Current environment prefabs:

```text
Assets/Prefabs/Environment/fire_camp.prefab
Assets/Prefabs/Environment/platform_.prefab
Assets/Prefabs/Environment/slope.prefab
Assets/Prefabs/Environment/home_.prefab
Assets/Prefabs/Environment/phase_.prefab
```

## Environment Object Types

Environment objects usually belong to one of these groups:

```text
Ground
Platform
Slope
Background
Prop
Checkpoint / interactable
Level chunk
```

## Ground And Platform Pattern

Ground/platform prefabs should usually have:

```text
Transform
SpriteRenderer
Collider2D
```

Use them for:

```text
Surfaces Rika can stand on
Enemy patrol ground
Level collision
```

Rules:

```text
Sorting Layer: Ground
Collider should match visible ground
Collider should not be trigger
Object should not move unless intentionally animated/platformed
```

## Prop Pattern

Props are visual or interactive world objects that are not ground.

Examples:

```text
fire_camp
home_
decorations
```

Rules:

```text
Sorting Layer: Prop
Use collider only if interaction or blocking is needed
Make sure Global Light 2D applies to Prop layer
```

## Fire Camp Checkpoint Pattern

Current fire camp:

```text
fire_camp
├── Transform
├── SpriteRenderer
├── Animator
├── CircleCollider2D
├── Checkpoint
└── RestCheckpoint
```

Behavior:

```text
Rika comes close
Prompt appears: Press E to rest
Press E
Fuel refills to 100
Camp becomes current checkpoint
```

Rules:

```text
CircleCollider2D should be trigger
Checkpoint should not activate on touch
RestCheckpoint should activate checkpoint after refill
```

## Background Pattern

Backgrounds should:

```text
Use Background sorting layer
Not block physics
Not have gameplay scripts unless needed
Stay visually behind gameplay objects
```

If a background is too bright or too dark, check material, lighting, and sorting layer.

## Chunk Pattern

A chunk is a reusable section of level.

Example chunk contents:

```text
Chunk_PlatformGap
├── platform_
├── slope
├── fire_camp optional
└── props
```

Use chunks when:

```text
A section is reused in multiple levels
The level layout has repeated structures
You want designers to drag one prefab instead of many pieces
```

Rules for chunks:

```text
Root object has clear name
Child objects are prefabs or simple helper objects
Root transform should be clean
Do not hide important gameplay setup deep in random children
```

## Tilemap Note

Tilemaps are useful for large grid-based ground layouts.

Use Tilemap when:

```text
The level is made from repeated tiles
You need fast painting/editing of ground
You want consistent grid alignment
```

Use prefabs when:

```text
The object has scripts
The object has unique animation
The object is an interactable
The object is a reusable large piece
```

In this project, fire camp should be a prefab, not a tile.

## Collider Rules

Ground/platform:

```text
Collider is solid
Is Trigger: false
```

Checkpoint/interactable:

```text
Collider is trigger
Is Trigger: true
```

Decorative prop:

```text
No collider unless needed
```

## Sorting Layer Rules

Recommended order:

```text
Background
Ground
Prop
Characters
Effects
```

Use:

```text
Ground pieces -> Ground
Fire camp and props -> Prop
Rika/enemies -> Characters
Bullets/effects -> Effects
```

## Lighting Rules

If using URP 2D lights, Global Light 2D must include the sorting layer.

If an environment sprite appears black:

```text
Check SpriteRenderer material
Check Sorting Layer
Check Global Light 2D Apply To Sorting Layers
Check color tint
```

## Checklist For Environment Prefabs

```text
Prefab is under Assets/Prefabs/Environment
SpriteRenderer has correct sprite
Sorting Layer is correct
Collider matches purpose
Trigger setting is correct
Scripts are assigned only when needed
References are not missing
Object is tested in scene
Prefab changes are saved
```

## Summary

Environment pattern:

```text
Ground blocks movement.
Props decorate or interact.
Checkpoints are prefab interactables.
Chunks combine repeated level sections.
Scenes place environment prefabs.
```
