Skill Node

🎯 SkillNode Class

A node that represents a skill.

Namespace: Esper.SkillWeb.Graph Inherits from: Node Type: class


πŸ“¦ Fields

Access
Field
Type
Description

public

web

Web

The web that this skill is a part of.

public

skill

Skill

The skill.

public

state

Skill.State

The current state of the skill node.

public

hasConnectionDependency

bool

Dictates whether this skill should become unlockable only if it has a direct connection to another skill that is obtained.

public

uiRefresher

Action

An action that refreshes the UI. This is invoked when the skill state is updated.

public

uiOnStateChanged

Action

An action that is simply meant to invoke the onStateChanged event on the UI side.

public

dataset

SkillDataset

The dataset. This is cloned from the Skill reference.

public static

playerLevelGetter

Func<int>

A function that gets the player level. You can use this to set your own level getting logic.

public static

canUpgrade

Func<SkillNode, bool>

A function that checks if a skill can be upgraded. You can use this to set your own logic to prevent/allow skill upgrades.

public static

canDowngrade

Func<SkillNode, bool>

A function that checks if a skill can be downgraded. You can use this to set your own logic to prevent/allow skill downgrades.

public static

onUpgrade

UnityEvent<SkillNode>

A callback for when any skill is upgraded. This accepts 1 argument: the affected skill (SkillNode).

public static

onDowngrade

UnityEvent<SkillNode>

A callback for when any skill is downgraded. This accepts 1 argument: the affected skill (SkillNode).

public static

onSkillObtained

UnityEvent<SkillNode>

A callback for when any skill is obtained. This accepts 1 argument: the affected skill (SkillNode).

public static

onSkillUnobtained

UnityEvent<SkillNode>

A callback for when any skill becomes unobtained. This accepts 1 argument: the affected skill (SkillNode).

public static

onSkillStateChanged

UnityEvent<SkillNode>

A callback for when any skill state is changed. This accepts 1 argument: the affected skill (SkillNode).


πŸ” Properties

Access
Property
Type
Description

public

Level

int

The current skill level.

public

MaxLevel

int

The max skill level.

public

IsLocked

bool

If the skill node is locked.

public

IsUnlocked

bool

If the skill is unlocked.

public

IsObtained

bool

If the skill has been obtained (leveled up atleast once).

public

IsMaxed

bool

If the skill has been maxed.

public

IsUpgradable

bool

If the skill can be upgraded (unlocked and not maxed).


🧰 Methods

Access
Method
Returns
Description

public

SkillNode(int, Skill, Vector2, List<Connection>)

-

Constructor.

public

CreateCopy()

SkillNode

Creates a copy of this skill node.

public

GetIcon(bool)

Skill.SkillIcon

Gets the skill icon based on the current skill state.

public

SetLevel(int, bool)

void

Sets the skill level. The level cannot be higher than the max level.

public

ResetLevel(bool)

void

Resets the level of this skill to 0.

public

TryUpgrade()

bool

Increases the level by 1 if possible. The skill must be unlocked and the level cannot be higher than the max level.

public

TryDowngrade()

bool

Decreases the level by 1 if possible. The level cannot be lower than 0.

protected

ApplyCustomScaling()

void

Applies stat scaling to custom fields.

public

UpdateConnectedSkillStates(List<Connection>)

void

Recursively updates connected skills. This may reset skills if their preceding skill nodes have become unobtained.

public

HasConnectionToPrerequisiteSkill(List<Connection>)

bool

If this skill has a connection to a prerequisite skill. If this skill itself does not require a prerequisite, true will be returned.

public

UnlockRequirementsMet()

bool

Checks if this skill's unlock connection requirements are met.

public

UpdateState()

void

Logically updates the skill state. This may reset skills if they're preceding skill nodes have become unobtained.

public

UpdateState(bool)

void

Logically updates the skill state. This may reset skills if they're preceding skill nodes have become unobtained.

public

ToSavable()

SavableSkillNode

Converts this SkillNode to a SavableSkillNode.

Creating a Skill Node

Creating a SkillNode requires a skill node ID (int), a reference to a Skill, and a Vector2 position.

var mySkill = SkillWeb.GetSkill("My Skill");
var mySkillNode = new SkillNode(0, mySkill, Vector2.zero);

If you're creating your own procedural generation algorithm, you can get an available node ID from a WebGraph with the webGraph.GetAvailableNodeID method.

Notable Methods

Get Icon

The GetIcon method gets the icon (Skill.SkillIcon) of the skill node based on its current state.

var skillIcon = mySkillNode.GetIcon();

Set Level

The SetLevel method sets the skill node level.

// Set skill level to 1
mySkillNode.SetLevel(1);

Reset Level

The ResetLevel method sets the skill node level to 0.

mySkillNode.ResetLevel();

Try Upgrade

The TryUpgrade method attempts to level up the skill node by 1. This will return false if the skill is locked, the level requirement is not met, or the skill is already maxed.

bool success = mySkillNode.TryUpgrade();

Try Downgrade

The TryDowngrade method attempts to level down the skill node by 1. This will return false work if the skill level is 0 or downgrading is disabled.

bool success = mySkillNode.TryDowngrade();

Last updated