Class EntityLevel
- Namespace
- ElectricDrill.SoapRpgFramework.Experience
- Assembly
- com.electricdrill.soap-rpg-framework.Runtime.dll
Represents the level and experience system of an entity in the RPG framework. Handles experience gain, level progression, and experience-based calculations. Implements ILevelable to provide standard leveling functionality.
[Serializable]
public class EntityLevel : ILevelable- Inheritance
- 
      objectEntityLevel
- Implements
Properties
CurrentTotalExperience
Gets the current total experience of the entity. This represents all experience gained since the entity was created.
public long CurrentTotalExperience { get; }Property Value
- long
Level
Gets or sets the current level of the entity. Level must be between 1 and the maximum level. Setting the level will trigger the OnLevelUp event.
public virtual int Level { get; set; }Property Value
- int
Methods
AddExp(long)
Adds experience to the entity. The experience will be modified by any experience gain modifiers. If the entity gains enough experience to level up, the OnLevelUp event will be raised. Can trigger multiple level ups if enough experience is added.
public void AddExp(long amount)Parameters
- amountlong
- The base amount of experience to add before modifiers are applied. 
CurrentLevelTotalExperience()
Gets the total experience required to reach the current level. For level 1, this returns 0. For higher levels, it uses the experience growth formula.
public long CurrentLevelTotalExperience()Returns
- long
- The total experience required for the current level. 
NextLevelTotalExperience()
Gets the total experience required to reach the next level. If the entity is already at the maximum level, returns the experience for the current level.
public long NextLevelTotalExperience()Returns
- long
- The total experience required for the next level, or current level experience if at max level. 
SetTotalCurrentExp(long)
Sets the total current experience and automatically updates the level to match. The level will be calculated based on the experience growth formula.
public void SetTotalCurrentExp(long totalCurrentExperience)Parameters
- totalCurrentExperiencelong
- The total experience to set. 
ValidateExperience()
Validates that the current total experience corresponds to the current level. If the experience doesn't match the level, it will be reset to the base experience for the current level. This method is useful for debugging and ensuring data consistency.
public void ValidateExperience()Events
OnLevelUp
Event raised when the entity levels up. The parameters are the EntityCore that leveled up and its new level respectively.
public virtual event Action<EntityCore, int> OnLevelUpEvent Type
- Action<EntityCore, int>
Operators
implicit operator int(EntityLevel)
Implicitly converts an EntityLevel to its integer level value. Allows EntityLevel objects to be used directly as integers in calculations.
public static implicit operator int(EntityLevel entityLevel)Parameters
- entityLevelEntityLevel
- The EntityLevel instance to convert. 
Returns
- int
- The current level as an integer.