Skip to main content

PathExperience

A class in Root.Township, the global namespace.

A player's progress on one progression path (forging, mining and so on): XP, level, free points, bought skills and practiced skills. Held by PlayerProgressionManager.

Constructors​

MemberWhat it is
PathExperience(ProgressionPath path, PlayerProgressionManager manager, Action<bool> leveledUp, Action<ProgressionPath> updatedPoints)Creates a PathExperience from path, manager, leveledUp and updatedPoints.

Fields​

9 private and internal fields
MemberWhat it is
private uint currentExperienceBacking field for CurrentExperience, experience towards the next level.
private uint currentLevelBacking field for CurrentLevel.
private uint freePointsBacking field for FreePoints, skill points not yet spent.
private Action<bool> LeveledUpCallback run after a level-up; its argument is true when the free points cap has been reached.
private static Logger loggerNLog logger for this class; also traces level and skill events.
private HashSet<uint> practicedSlotsHashes of slots the player has practised.
private PlayerProgressionManager targetPlayerThe PlayerProgressionManager this path belongs to.
private HashSet<uint> unlockedSlotsBacking field for UnlockedSlots, the hashes of unlocked skill slots.
private Action<ProgressionPath> UpdatedPointsCallback run with the path whenever points or slots change.

Properties​

MemberWhat it is
uint CurrentExperience { get; }XP toward the next level. Resets on each level up.
uint CurrentLevel { get; }The path's level. Selling skills lowers it again.
uint FreePoints { get; }Unspent skill points. Gaining XP stops once this reaches the settings' maximum.
ProgressionPath Path { get; private set; }Which progression path this is.
IEnumerable<uint> UnlockedSlots { get; }Hashes of the bought skill slots.
int UnlockedSlotsCounts { get; }How many skill slots are bought.

Methods​

MemberWhat it is
void DebugClearSlots()Removes all bought skills and resets XP, level and points to zero, without locking the skills.
void GainExperience(int experience)Adds XP scaled by the server's per-path and global XP multipliers, levelling up and adding points as needed.
SkillStatus IsSlotAvailable(ProgressionSlot slot)Whether a skill slot is owned, owned but locked by children, buyable, too expensive or not yet reachable.
bool IsSlotPracticed(uint slotHash)Whether the skill slot has been practiced at a shrine.
void LockSlot(ProgressionSlot slot, bool isRecoveringPoints = true)Sells a skill: locks it and any children that depend only on it, lowers the level, and optionally refunds part of the XP.
void LoseExperience(float percentage)Removes a fraction (0 to 1) of the current unspent XP. Used for the server's XP lost on death setting.
bool PracticeSlot(uint slotHash)Marks a skill slot as practiced. Returns false if it already was.
void RemoveFreePoints(int toRemove)Takes away levels, from free points first and then by selling leaf skills. Used by offline progression changes.
void Serialize(Stream stream)Reads or writes XP, level, points and bought skills. Reading unlocks the skills on the player.
void SerializePracticedSlots(Stream stream)Reads or writes the set of practiced skill slots.
void UnlockSlot(ProgressionSlot slot, bool isConsumingPoints = true)Buys a skill, spending its cost in points unless told not to, and unlocks it on the player.
5 private and internal methods
MemberWhat it is
private void GainExperienceUnmultiplied(int experience)Adds experience with no server multipliers, levelling up and granting free points until the max free points cap.
private bool HasMultipleDependenciesUnlocked(ProgressionSlot slot)True if a slot has more than one dependency and at least two of them are unlocked.
private void RecursiveLockSlot(ProgressionSlot slot, ref float totalExperienceReward)Locks a child slot once none of its dependencies are unlocked, adding its refund and continuing to its children.
private void RemoveSlots(int remainder)Locks unlocked leaf slots one at a time (no refund) to take away points the player has already spent.
private void SerializeSlots(Stream stream, uint slotHash, HashSet<uint> covered, ProfessionSkillTree tree)Writes a slot after its unlocked dependencies, so loading unlocks them in a valid order.

Used in​

Members of other types that take, return or hold a PathExperience: