A simple, lightweight library that contains a bunch of classes to manage game character stats.
There are three ways to include GameStats in your project:
- Install the NuGet package:
dotnet add package Greenstack.GameStats --version 1.0.0 - Clone the repository as a submodule into your project. This will let you have the most up-to-date sources. Note that the
mainbranch may have breaking changes. - Copy
src/Stats.csto an appropriate location in your project. While you won't get updates, it does reduce the number of dlls that will be produced in a project build.
The core stat types are ResourceStat<T> and ModifiableStat<T>. T is constrained to any type that implements the INumber<T> interface.
ResourceStat<T>: This stat is used to track a value that can increase or decrease in value. This is good for tracking things such as money, health, mana, or any other resource that can be depleted, refreshed, or otherwise.ModifiableStat<T>: This status is used to track a stat that has a definite value, but can be modified in some way and reset to that core value. This class is valuable to act as a proxy over a value that should be preserved or reset to a regular value after a battle ends, as ModifiableStats don't alter its main value as modifications come an and out.
Each of these stats come with helper methods to query and operate on their internal values, as well as to compare them against raw values and other stats.
Many thanks to those that have assisted in the development of this library!