Stat Profile
📑 StatProfile Class
A profile that defines the stats for any entity.
Namespace:
Esper.Inventool.Stats
Access:public
Type:class
Attributes:[Serializable]
📦 Fields
public
target
object
The target object.
public
level
int
The current level. Default: 1.
public
maxLevel
int
The max level. Default: 1.
public
weight
float
The amount the target weighs.
public
experience
ScalingValue
Experience points. Managed via AddExp
and RemoveExp
.
public
durability
ScalingValue
Durability points. Managed via IncreaseDurability
and ReduceDurability
.
public
stats
List<Stat>
The list of stats.
public
levelingEnabled
bool
If the target object can level up.
public
durabilityEnabled
bool
If the target object uses durability.
🔍 Properties
public
IsMaxed
bool
True if level == maxLevel
.
🔧 Constructors
public
StatProfile()
Default constructor.
public
StatProfile(StatProfile statProfile)
Copy constructor. Copies target, level, maxLevel, weight, experience, durability, flags, and deep-copies stats.
🧰 Methods
public
UpdateStatLevels()
void
Updates levels on experience
, durability
, and all stats; recalculates and resets stat values.
public
GetInterpolatedText(string original)
string
Returns text with placeholders replaced using stat data and colors.
protected
AddStatColor(Stat stat, string original)
string
Wraps a string with the stat’s color tag.
public
GetStat(int id)
Stat
Gets a stat by identity ID or null
if not found.
public
GetStat(string nameOrAbbreviation)
Stat
Gets a stat by name or abbreviation or null
if not found.
public
GetStat(StatIdentity statIdentity)
Stat
Gets a stat by identity or null
if not found.
public
MergeStats(params Stat[] stats)
void
Merges stats: tries TryMerge
; adds copies if not mergeable.
public
MergeStats(List<Stat> stats)
void
Merges stats from a list (wrapper).
public
CombineStats(params Stat[] stats)
void
Combines matching stats by identity (ignores missing).
public
CombineStats(List<Stat> stats)
void
Combines stats from a list (wrapper).
public
UncombineStats(params Stat[] stats)
void
Uncombines matching stats by identity (ignores missing).
public
UncombineStats(List<Stat> stats)
void
Uncombines stats from a list (wrapper).
public
SetMaxLevel(int maxLevel)
void
Sets max level; clamps current level; warns if invalid or leveling disabled.
public
SetLevel(int level)
void
Sets current level; updates all stat levels; ignores if invalid or disabled.
public
LevelUp()
void
Increases level by 1; resets experience; updates stats; invokes target events.
public
LevelDown()
void
Decreases level by 1; updates stats; invokes target events.
public
RecalculateExternalValues()
void
Recalculates external value for all stats.
public
ResetExternalValues()
void
Resets external value for all stats.
public
ResetCurrentValues()
void
Resets current value for all stats.
protected
ApplyLevelToStats()
void
Obsolete. Applies level to all stats and resets value.
public
AddExp(NumericValue value)
void
Adds experience; levels up on high; recurses excess.
public
RemoveExp(NumericValue value)
void
Removes experience; levels down on low; recurses excess.
public
IncreaseDurability(NumericValue value)
void
Increases durability up to high; requires durabilityEnabled
.
public
ReduceDurability(NumericValue value)
void
Reduces durability down to low; invokes zero‑durability target events.
Creating a Stat Profile
var myStatProfile = new StatProfile();
Managing Stats
Adding/Removing Stats
To add or remove a stat, simply use the Add
or Remove
methods of the stats
field.
myStatProfile.stats.Add(myStat);
myStatProfile.stats.Remove(myStat);
Getting Stats
You can get a specific stat in the profile with the stat's ID, name or abbreviation.
var hpStat = myStatProfile.GetStat("HP");
Merging Stats
You can merge a list of stats with the MergeStats
method. Stat merging is the process of permanently adding a stat's value to another of the same identity. If the stat cannot be merged with any existing stat in the profile, it will be added as a new stat instead.
myStatProfile.MergeStats(stat1, stat2); //stat3, etc...
Combining/Uncombining Stats
Stat combining is the process of temporarily adding a stat's value to another of the same identity.
Combining
You can combine a list of stats with the CombineStats
method. Only similar stats can be combined with each other. Stats that aren't identical to any stat in the profile will be ignored.
myStatProfile.CombineStats(stat1, stat2); //stat3, etc..
Uncombining
Use the UncombineStats
method to have the opposite effect.
myStatProfile.UncombineStats(stat1, stat2); //stat3, etc..
Managing Levels
When setting the level of a StatProfile
, the methods below should be used as they will update all stats in the profile.
Set the Level
To set the max value, use the SetMaxLevel
method.
myStatProfile.SetMaxLevel(100);
The SetLevel
will set the current level to a specific value.
myStatProfile.SetLevel(1);
Level Up
The LevelUp
method increases the level by 1.
myStatProfile.LevelUp();
Level Down
The LevelDown
method decreases the level by 1.
myStatProfile.LevelDown();
Manage Experience
Add Exp
The AddExp
method adds experience points. This will result in a level up if the high value reached.
myStatProfile.AddExp(100);
Remove Exp
The RemoveExp
method removes experience points. This will result in a level down if the value goes below zero.
myStatProfile.RemoveExp(100);
Manage Durability
Increase Durability
The IncreaseDurability
method increases the durability. The durability cannot go over the high value.
myStatProfile.IncreaseDurability(100);
Remove Exp
The ReduceDurability
method reduces the durability. The durability cannot go below the low value.
myStatProfile.ReduceDurability(100);
Text Interpolation
You can use the GetInterpolatedText
method to convert a string with stat text tags to correctly display the stats from a stat profile (e.g. "Character has {stat1_value} {stat1_abbr}" becomes "Character has 100 HP").
string original = "Character has {stat1_value} {stat_abbr}.";
string interpolatedText = myStatProfile.GetInterpolatedText(original);
Supported Stat Text Tags
{stat0_value}
The value of the stat at the current level without any changes.
{stat0_name}
The name of the stat.
{stat0_abbr}
The abbreviated name of the stat.
{stat0_lvl}
The current level of the stat.
{stat0_mlvl}
The max level of the stat.
{stat0_curr}
The current value of the stat.
{stat0_next}
The value of the stat at the next level.
{stat0_max}
The max value of the stat at the current level.
{stat0_maxed}
The max value of the stat at the max level.
{stat0_scaling}
The scaling of the stat. Note: this will not work correctly when stat scaling is set to Curve.
{stat0_init}
The initial value of the stat.
Last updated