# ProgressController

## Events

<details>

<summary><strong>OnStartResearchFailed</strong></summary>

Called when starting a research has failed. Returns a ProgressEventStats code

```csharp
progressController.OnStartResearchFailed += OnResearchFailed;

void OnResearchFailed(ProgressEventData.ProgressEventStatus _status)
{
    Debug.Log("Research failed! Status: " + _status); 
}

```

</details>

<details>

<summary>OnStartResearch</summary>

Called when a research has been started

```csharp
progressController.OnStartResearch += OnStartResearch 

void OnStartResearch(ProgressNode _event)
{
    if (_event != null)
    {
        Debug.Log("Research started " + _event.title);
    }          
}
```

</details>

<details>

<summary>OnResearchComplete</summary>

Called when a research has been completed

```csharp
progressController.OnResearchComplete += OnResearchComplete;

void OnResearchComplete(ProgressNode _event)
{
    if (_event != null)
    {
       Debug.Log("Research complete " + _event.title);
    }
}
```

</details>

<details>

<summary>OnResearchUnlocked</summary>

Called when new nodes has been unlocked. Returns a list with all newly unlocked nodes.

```csharp
progressController.OnResearchUnlocked += OnResearchUnlocked;

void OnResearchUnlocked(List<ProgressNode>_eventData)
{
      Debug.Log("New nodes has been unlocked " + _eventData.Count);      
}  
```

</details>

<details>

<summary>OnResearchProgress</summary>

Constantly returns the current progress of a research.

```csharp
progressController.OnResearchProgress += ResearchProgress;

void ResearchProgress(float _value)
{
    Debug.Log("current progress: " + _value);
}
```

</details>

## Methods

<details>

<summary>SetUIController</summary>

Set a different Progress UI controller. Can be used to switch between themes for example.

```csharp
progressController.SetUIController(themeObject1);
```

</details>

<details>

<summary>LoadProgressGraph</summary>

Load a Progress Graph. You can optionally pass a name of a Progress Graph. If the name is empty the assigned Progress Graph will be loaded.

```csharp
progressController.LoadProgressGraph();

progressController.LoadProgressGraph("PlayerProgress");
```

</details>

<details>

<summary>StartResearchInProgressGraphByTitle</summary>

Start a new research by its title name.

```csharp
public void StartResearchSpecificNode()
{
    // Research a specific node in the progress graph
    var _node = progressController.StartResearchInProgressGraphByTitle("Bio Engineering");

    if (_node != null)
    {
        _node.OnResearchProgress -= Progress;
        _node.OnResearchProgress += Progress;
     }
    else
    {
        // Research failed. Maybe because we don't have enough resources
        Debug.Log("Research failed, not enough resources");
    }
}

```

</details>

<details>

<summary>StartResearchInProgressGraphByGuid</summary>

Start a new research by the progress nodes runtime guid

```csharp
public ProgressNode MyProgressNode;

progressController.StartResearchInProgressGraphByGuid(MyProgressNode.GetRuntimeDataObject().guid);
```

</details>

<details>

<summary>StartResearchInProgressGraph</summary>

Start new research. Pass in the actual node you want to research.

</details>

<details>

<summary>ResetProgressGraphToInitialState</summary>

Resets the Progress Graph back to it's initial state.

</details>
