# Player Web Link

## 🔗 PlayerWebLink Class

Links a web to a GameObject.

> Namespace: `Esper.SkillWeb`\
> Inherits from: `MonoBehaviour`\
> Type: `class`

***

### 📦 Fields

| Access   | Field               | Type              | Description                                                                                                                                                                          |
| -------- | ------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `public` | `webName`           | `string`          | The name of the web to link with.                                                                                                                                                    |
| `public` | `linkAutomatically` | `bool`            | If the component should automatically link to the web. Automatic linking requires a Web to be loaded by a web view component. Disable this if you'd like to handle linking yourself. |
| `public` | `linkedWeb`         | `Web`             | The linked web. This will be null if there was no link made.                                                                                                                         |
| `public` | `obtainedSkills`    | `List<SkillNode>` | A list of obtained skills. This is updated automatically as long as there is a link set.                                                                                             |
| `public` | `onUnlinked`        | `UnityEvent`      | A callback for when the PlayerWebLink becomes unlinked.                                                                                                                              |
| `public` | `onLinked`          | `UnityEvent`      | A callback for when the PlayerWebLink is linked.                                                                                                                                     |

***

### 🔍 Properties

| Access   | Property   | Type   | Description           |
| -------- | ---------- | ------ | --------------------- |
| `public` | `IsLinked` | `bool` | If linked with a web. |

***

### 🧰 Methods

| Access      | Method                                | Returns           | Description                                                                                                                                        |
| ----------- | ------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `protected` | `AddToObtainedSkills(SkillNode)`      | `void`            | Adds a skill to the list of obtained skills. The skill is only added if the web of the skill matches.                                              |
| `protected` | `RemoveFromObtainedSkills(SkillNode)` | `void`            | Removes a skill to the list of obtained skills. The skill is only added if the web of the skill matches.                                           |
| `public`    | `UpdateLinkStatus()`                  | `void`            | Updates the link status. If a web view is found in the scene with a matching web name, a link to it will be set. Otherwise, there will be no link. |
| `public`    | `Link()`                              | `void`            | Tries to link with a web using the webName field. No link will be made if the relevant web view component is not found.                            |
| `public`    | `Link(Web)`                           | `void`            | Links with a web. This may change the webName field.                                                                                               |
| `public`    | `Unlink()`                            | `void`            | Unlinks from a web.                                                                                                                                |
| `public`    | `GetAllObtainedSkills()`              | `List<SkillNode>` | Gets the list of obtained skills. This requires a link.                                                                                            |
| `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. This requires a link.    |
| `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. This requires a link.        |
| `public`    | `GetSkillNode(int)`                   | `SkillNode`       | Gets the first skill node by skill ID. This requires a link.                                                                                       |
| `public`    | `GetSkillNode(string)`                | `SkillNode`       | Gets the first skill node by name. This requires a link.                                                                                           |
| `public`    | `IsObtained(int)`                     | `bool`            | Checks if a skill with the specific skill ID is obtained. This requires a link.                                                                    |
| `public`    | `IsObtained(string)`                  | `bool`            | Checks if a skill with the specific skill name is obtained. This requires a link.                                                                  |
| `public`    | `AutoLinkCoroutine()`                 | `IEnumerator`     | A coroutine that runs indefinitely until a link is made.                                                                                           |
