
# Manager
`inherits SubViewport`

### Usage
This is the backbone of the demo.

The `Manager` is responsible for the scene management and background music.

#### Setup
1. Create a new scene with a type of `Manager` and make it the main scene.
2. Set the `Bgm` from either in-editor or through code.
3. Add scenes to be run in order with `register_scene()`
4. Create a child of type `AnimationPlayer` and create a new animation with a `Call Method Track`
5. Add keyframes at points where you wish the scene to be changed. Call method `set_scene(scene_number)`.
6. Call `start_audio()` and `$AnimationPlayer.play()` to start the bgm and scene timeline 

#### Example script
```gdscript
extends Manager

var scene1: PackedScene = preload("res://entities/scene_1.tscn");
var scene2: PackedScene = preload("res://entities/scene_2.tscn");
var scene3: PackedScene = preload("res://entities/scene_3.tscn");
var scene4: PackedScene = preload("res://entities/scene_4.tscn");

func _ready() -> void:
    register_scene(scene1);
	register_scene(scene2);
	register_scene(scene3);
	register_scene(scene4);

    start_audio();
    $AnimationPlayer.play("timeline");

```

### Properties
| Type                 | Name                | Default |
| -------------------- | -----------         | ------- |
| `String`             | bgm                 | `Null`  |
| `Array[PackedScene]` | scenes              | `Array[PackedScene]`         |
| `int`                | beat_count (unused) | `Null`  |

`bgm`
Stores the path to the background music as `String`

`scenes` stores the registered scenes. Usually you shouldn't edit this manually

`beat_count` Unused


### Methods

| Returns | Name |
| ------- | ---- |
| `void`  | `set_scene(number: int)` |
| `void`  | `register_scene(scene: PackedScene)` |
| `void`  | `start_audio()` |

#### set_scene(number: int)
Changes the current scene to the scene at index `number` in `scenes`

#### register_scene(scene: PackedScene)
Registers the `scene` to the manager. 

Each registered scene is added to `scenes` and gets preloaded into memory.

The scene number is the scene's index in `scenes`, so the first scene registered gets number `0`, the next one gets number `1` and so on.

#### start_audio()
Calling this function will start playing back the `bgm` on the main bus.