# Understanding the Scene States in MainControl.cs: Normal, Overworld, and Battle

> Explore the Normal, Overworld, and Battle scene states in MainControl.cs. Learn how these states manage game mode initialization, UI, and gameplay logic in the undertale-changer-template.

- Repository: [Archived AIk/undertale-changer-template](https://github.com/arch-aik/undertale-changer-template)
- Tags: deep-dive
- Published: 2026-02-25

---

**The [`MainControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/MainControl.cs) file in the undertale-changer-template repository defines three distinct scene states—Normal, Overworld, and Battle—that govern game mode initialization, UI handling, and gameplay logic flow.**

The `SceneState` enum serves as the central state machine for the Undertale Changer Template, determining which subsystems are active at any given moment. Located in [`Assets/Scripts/UCT/Core/MainControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/Assets/Scripts/UCT/Core/MainControl.cs), this enum drives the `StartWithSceneState` method and coordinates with specialized control classes to manage scene-specific behaviors.

## The SceneState Enum Definition

At the top of the `MainControl` class, the `SceneState` enum declares three mutually exclusive values:

```csharp
public enum SceneState
{
    Normal,
    Overworld,
    Battle
}

```

These values are stored in the public `sceneState` field and accessed via `MainControl.Instance.sceneState` throughout the codebase. The `StartWithSceneState` method (lines 34-39) uses a switch statement on this enum to trigger appropriate initialization routines.

## Breakdown of Each Scene State

### Normal State

**Normal** represents the default operational mode when no specialized scene logic is required. In this state, the game runs general gameplay systems without loading overworld-specific or battle-specific subsystems. Use this state for menu screens, cutscenes, or transitional sequences that do not require the full overhead of exploration or combat mechanics.

### Overworld State

**Overworld** activates the exploration system, triggering player spawning, global lighting initialization, and chase UI preparation. When `MainControl.Instance.sceneState` is set to `SceneState.Overworld`, the `StartWithSceneState` method coordinates with [`OverworldControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/OverworldControl.cs) to load tilemaps, instantiate the player character, and configure camera boundaries. This state handles random encounters, NPC interactions, and environmental puzzles.

### Battle State

**Battle** initializes the combat system, loading turn data and configuring battle-specific UI elements. Transitioning to `SceneState.Battle` triggers the [`BattleControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/BattleControl.cs) subsystem, which sets up the soul (player heart), enemy positions, and turn-based logic. This state manages attack patterns, item usage, and victory/defeat conditions while suspending overworld physics and rendering.

## Practical Implementation Examples

### Checking the Current Scene State

Use conditional logic to execute state-specific code:

```csharp
if (MainControl.Instance.sceneState == MainControl.SceneState.Overworld)
{
    // Execute overworld-specific logic
    OverworldControl.Instance.CheckForRandomEncounter();
}

```

### Switching Scene States

Transition between modes by updating the enum value and reinitializing:

```csharp
public void EnterBattle()
{
    MainControl.Instance.sceneState = MainControl.SceneState.Battle;
    MainControl.Instance.StartWithSceneState(); // Re-initialises for battle
}

```

### Using Switch Statements for State-Dependent Logic

Handle multiple states cleanly with pattern matching:

```csharp
switch (MainControl.Instance.sceneState)
{
    case MainControl.SceneState.Normal:
        // General gameplay
        break;
    case MainControl.SceneState.Overworld:
        // Overworld handling
        HandleOverworldUpdate();
        break;
    case MainControl.SceneState.Battle:
        // Battle handling
        ProcessTurnLogic();
        break;
}

```

## Related Files and Architecture

The scene state system relies on coordination between the core controller and specialized subsystems:

- **[`Assets/Scripts/UCT/Core/MainControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/Assets/Scripts/UCT/Core/MainControl.cs)** – Defines the `SceneState` enum and manages global state transitions via `StartWithSceneState`.
- **[`Assets/Scripts/UCT/Control/OverworldControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/Assets/Scripts/UCT/Control/OverworldControl.cs)** – Implements exploration behaviors activated when `SceneState.Overworld` is set.
- **[`Assets/Scripts/UCT/Control/BattleControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/Assets/Scripts/UCT/Control/BattleControl.cs)** – Implements combat system logic that runs under `SceneState.Battle`.

## Summary

- **Three scene states**—Normal, Overworld, and Battle—control game mode initialization in [`MainControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/MainControl.cs).
- The **`SceneState` enum** drives the `StartWithSceneState` method to configure appropriate subsystems.
- **Normal** handles default operations, **Overworld** manages exploration, and **Battle** controls combat sequences.
- State transitions require updating `MainControl.Instance.sceneState` and calling initialization methods to synchronize subsystem activation.

## Frequently Asked Questions

### How do I check which scene state is currently active in MainControl.cs?

Access the singleton instance's `sceneState` field and compare it against the `SceneState` enum values. For example: `if (MainControl.Instance.sceneState == MainControl.SceneState.Battle)` will return true when the game is in battle mode.

### What happens when I change the scene state to Overworld?

Setting `MainControl.Instance.sceneState = MainControl.SceneState.Overworld` prepares the game for exploration, but you must call `MainControl.Instance.StartWithSceneState()` to actually initialize the overworld systems, spawn the player, and configure the chase UI through [`OverworldControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/OverworldControl.cs).

### Can I add custom scene states to the enum?

Yes, you can extend the `SceneState` enum in [`Assets/Scripts/UCT/Core/MainControl.cs`](https://github.com/arch-aik/undertale-changer-template/blob/main/Assets/Scripts/UCT/Core/MainControl.cs) by adding new values after `Battle`. However, you must also update the `StartWithSceneState` method's switch statement and any related control classes to handle the new state's initialization logic.