# Web

## 🕸️ Web Class

The runtime version of the WebGraph.

> Namespace: `Esper.SkillWeb.Graph`\
> Type: `class`

***

### 📦 Fields

| Access          | Field                         | Type                         | Description                                                                                                                                        |
| --------------- | ----------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `public`        | `graph`                       | `WebGraph`                   | The graph reference which is created with the Web Creator. This graph is used to create the actual runtime graph.                                  |
| `public`        | `skillNodes`                  | `Dictionary<int, SkillNode>` | A dictionary of skill nodes.                                                                                                                       |
| `protected`     | `revertableState`             | `Dictionary<int, int>`       | The revertable graph state simply as a dictionary where the key is the skill node ID and the value is the skill node level.                        |
| `public`        | `dataset`                     | `WebDataset`                 | The dataset.                                                                                                                                       |
| `protected`     | `revertableSkillPointsInt`    | `int`                        | The skill points set when the graph is reverted (int).                                                                                             |
| `protected`     | `revertableSkillPointsFloat`  | `float`                      | The skill points set when the graph is reverted (float).                                                                                           |
| `protected`     | `revertableSkillPointsDouble` | `double`                     | The skill points set when the graph is reverted (double).                                                                                          |
| `public`        | `isReverting`                 | `bool`                       | If the graph is currently reverting. This flag is automatically set as needed when RevertChanges is called.                                        |
| `protected`     | `boundInt`                    | `BoundSkillPoints<int>`      | Used for skill point binding (int).                                                                                                                |
| `protected`     | `boundFloat`                  | `BoundSkillPoints<float>`    | Used for skill point binding (float).                                                                                                              |
| `protected`     | `boundDouble`                 | `BoundSkillPoints<double>`   | Used for skill point binding (double).                                                                                                             |
| `public static` | `onSkillsReset`               | `UnityEvent<Web>`            | A callback for when all skills of a web is reset. This accepts 1 argument: the web that was reset (Web).                                           |
| `public static` | `onReverted`                  | `UnityEvent<Web>`            | A callback for when a web is reverted. This accepts 1 argument: the reverted web (Web).                                                            |
| `public static` | `onDanglingLevelsDetected`    | `UnityEvent<Web, int>`       | A callback for when a dangling levels are detected. This accepts 2 arguments: the affected web (Web), total number of dangling skill levels (int). |

***

### 🔍 Properties

| Access   | Property            | Type               | Description                                     |
| -------- | ------------------- | ------------------ | ----------------------------------------------- |
| `public` | `Connections`       | `List<Connection>` | A list of all skill connections.                |
| `public` | `HasUnsavedChanges` | `bool`             | If there are unsaved changes made to the graph. |

***

### 🧰 Methods

| Access           | Method                                                        | Returns            | Description                                                                                                               |
| ---------------- | ------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| `public`         | `Web(WebGraph)`                                               | -                  | Constructor.                                                                                                              |
| `public`         | `Web(SavableWeb)`                                             | -                  | Constructor.                                                                                                              |
| `public`         | `ResetAllSkills()`                                            | `void`             | Resets all skills.                                                                                                        |
| `public virtual` | `AddToRevertableState(SkillNode)`                             | `void`             | Adds to the revertable state. If this is the first skill node added, the web will become revertable.                      |
| `public virtual` | `ConfirmChanges()`                                            | `void`             | Confirms the changes made. The graph will not be revertable until changes are made once again.                            |
| `public virtual` | `RevertChanges()`                                             | `void`             | Reverts the changes made. The graph will not be revertable until changes are made once again.                             |
| `public`         | `UpdateAllStates()`                                           | `void`             | Updates all node states.                                                                                                  |
| `public`         | `GetSkillConnections(SkillNode)`                              | `List<Connection>` | Creates a list of connections of the skill node.                                                                          |
| `public`         | `GetNode(int)`                                                | `SkillNode`        | Gets a skill node by its node ID. This is not the skill ID.                                                               |
| `public`         | `GetSkillNodes(int)`                                          | `List<SkillNode>`  | Gets skill nodes by their skill ID. A list is returned because multiple instances of the same skill are allowed in a web. |
| `public`         | `GetSkillNodes(string)`                                       | `List<SkillNode>`  | Gets skill nodes by their name. A list is returned because multiple instances of the same skill are allowed in a web.     |
| `public`         | `GetSkillNode(int)`                                           | `SkillNode`        | Gets the first skill node by skill ID.                                                                                    |
| `public`         | `GetSkillNode(string)`                                        | `SkillNode`        | Gets the first skill node by name.                                                                                        |
| `public`         | `GetSkillNodes(Skill.State[])`                                | `List<SkillNode>`  | Gets a list of all skill nodes in specific states.                                                                        |
| `public`         | `GetObtainedSkillNodes()`                                     | `List<SkillNode>`  | Gets a list of all obtained skill nodes.                                                                                  |
| `public`         | `IsNodeObtained(int)`                                         | `bool`             | Checks if a skill node with the specific node ID is obtained.                                                             |
| `public`         | `IsObtained(int)`                                             | `bool`             | Checks if a skill with the specific skill ID is obtained.                                                                 |
| `public`         | `IsObtained(string)`                                          | `bool`             | Checks if a skill with the specific skill name is obtained.                                                               |
| `public`         | `ToSavable()`                                                 | `SavableWeb`       | Converts this Web to a SavableWeb.                                                                                        |
| `public`         | `CanUpgradeSkillNode(SkillNode)`                              | `bool`             | Checks if the player has enough skill points to upgrade the skill node.                                                   |
| `public`         | `ApplyBindingReset(SkillNode)`                                | `void`             | Applies the skill points binding while using a skill node reference as if it was reset.                                   |
| `public`         | `ApplyBinding(SkillNode, bool)`                               | `void`             | Applies the skill points binding.                                                                                         |
| `public`         | `Bind(Func<int>, Func<SkillNode, int>, Action<int>)`          | `void`             | Binds this web with a skill points value.                                                                                 |
| `public`         | `Bind(Func<float>, Func<SkillNode, float>, Action<float>)`    | `void`             | Binds this web with a skill points value.                                                                                 |
| `public`         | `Bind(Func<double>, Func<SkillNode, double>, Action<double>)` | `void`             | Binds this web with a skill points value.                                                                                 |

***

### 🧩 Nested Classes

`public class BoundSkillPoints<T>`

Skill points binder.

| Access   | Field               | Type                 | Description                                                                                                                                                                                                                  |
| -------- | ------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `public` | `skillPointsGetter` | `Func<T>`            | A method that gets the player's skill points. This should return the numeric type.                                                                                                                                           |
| `public` | `skillCostGetter`   | `Func<SkillNode, T>` | A method that gets the skill cost from a skill node.                                                                                                                                                                         |
| `public` | `skillPointsSetter` | `Action<T>`          | A method that sets the player's skill points after applying the cost. The cost will be subtracted if the skill node was upgraded. If it was downgraded, it will be added. The value will not be set to a number less than 0. |
