23 lines
No EOL
559 B
C#
23 lines
No EOL
559 B
C#
public class InsightLevel {
|
|
|
|
public delegate void InsightLevelChangedAction();
|
|
public event InsightLevelChangedAction OnChanged;
|
|
private int level;
|
|
|
|
public InsightLevel(int initialLevel) {
|
|
this.level = initialLevel;
|
|
}
|
|
|
|
public void Modify(int amount) {
|
|
int previousLevel = this.level;
|
|
|
|
this.level += amount;
|
|
if (this.level < 0) this.level = 0;
|
|
|
|
if (this.level != previousLevel && this.OnChanged != null) {
|
|
this.OnChanged();
|
|
}
|
|
}
|
|
|
|
public int Level {get => this.level;}
|
|
} |