SetNet.Stats
1.2.0
dotnet add package SetNet.Stats --version 1.2.0
NuGet\Install-Package SetNet.Stats -Version 1.2.0
<PackageReference Include="SetNet.Stats" Version="1.2.0" />
<PackageVersion Include="SetNet.Stats" Version="1.2.0" />
<PackageReference Include="SetNet.Stats" />
paket add SetNet.Stats --version 1.2.0
#r "nuget: SetNet.Stats, 1.2.0"
#:package SetNet.Stats@1.2.0
#addin nuget:?package=SetNet.Stats&version=1.2.0
#tool nuget:?package=SetNet.Stats&version=1.2.0
<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>
SetNet.Stats
Custom character statistics for SetNet.
Define your own stat vocabulary — attack power, defense, move/attack speed, whatever your game needs — as a reusable StatSchema, then give any entity (players or mobs) a StatSet over it. Each stat's value is computed from a base plus flat, additive-percent and multiplicative-percent modifiers, clamped to the schema's range and cached until something changes. Modifiers carry an optional source tag, so everything a buff or a piece of gear grants can be pulled off together. This is the foundation SetNet.Combat, SetNet.Abilities and SetNet.Equipment build on. Server-side, no wire protocol.
Install
dotnet add package SetNet
dotnet add package SetNet.Stats
Usage
Declare the schema once, then spin up a set per entity:
// your game's stat vocabulary (share one schema across every player and mob type)
var schema = StatSchema.Create()
.Define("attack_power", baseValue: 10)
.Define("defense", baseValue: 0)
.Define("crit_chance", baseValue: 0, min: 0, max: 1)
.Build();
var stats = schema.NewSet();
// gear and buffs add modifiers, tagged with a source so they come off together:
stats.AddModifier(StatModifier.Flat("attack_power", 5, source: "sword"));
stats.AddModifier(StatModifier.PercentAdd("attack_power", 0.20, source: "rage")); // +20%
double atk = stats.Get("attack_power"); // (10 + 5) * 1.20 = 18
long dmg = stats.GetInt("attack_power"); // rounded to a whole number
stats.RemoveBySource("rage"); // strip the buff; cached values recompute lazily
Notes
- Fully custom. SetNet.Stats ships no stat names or ranges — you declare them. Every downstream module (Combat/Abilities/Equipment) reads stats by the keys you chose.
- Modifier math. A value resolves as
clamp( (base + Σflat) · (1 + ΣpercentAdd) · Π(1 + percentMult) ), so ordering is deterministic regardless of insertion order. UseStatModifier.Flat/PercentAdd/PercentMult(0.1 = +10%). - Remove by source. Tag a group of modifiers with any object (a buff id, an equip slot) and drop them all at once with
RemoveBySource(source)— how equipment and timed buffs clean up after themselves. - Base overrides.
SetBase(statId, value)overrides a stat's base (e.g. from a level-up) before modifiers apply;ResetBasereverts to the schema default. - Cached + observable. Resolved values are cached until a relevant modifier changes; subscribe to
StatSet.Changed(the affected stat id, ornullfor a bulk change) to react. - Server-side only. No runtime bootstrap, no wire types — it's a plain library. Replication of the results is your game's job (e.g. via
SetNet.StateSync).
Documentation & source
- 🐙 https://github.com/Povstalez/SetNet — full module catalog in docs/MODULES.md
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- SetNet (>= 1.2.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on SetNet.Stats:
| Package | Downloads |
|---|---|
|
SetNet.Combat
Server-authoritative combat resolution for SetNet, built on SetNet.Stats: turn an attacker's and defender's StatSets into a DamageResult (attack power, armor mitigation, crit) via a pluggable ICombatFormula, then apply it to a Health pool. Which stats mean "attack power"/"defense"/"crit" is fully configurable (CombatStatKeys), so it fits any stat vocabulary. No wire protocol. Depends on SetNet + SetNet.Stats. |
|
|
SetNet.Equipment
Server-authoritative equipment for SetNet: define your own slot schema (head, weapon, ring1/ring2, whatever — with per-slot accept rules), equip/unequip items pulled from SetNet.Inventory, and have each equipped item apply stat modifiers to the wearer's SetNet.Stats StatSet (so gear changes attack power, defense, speed, …). Clients equip/unequip and read the loadout; changes push. Rides the unified protocol. Depends on SetNet + SetNet.Stats + SetNet.Inventory. |
|
|
SetNet.Abilities
Server-authoritative abilities / skills for SetNet: define abilities with cooldown, resource cost, range and target kind, plus composable effects (deal damage via SetNet.Combat, heal, or apply a timed stat buff via SetNet.Stats). Clients request client.UseAbilities().UseAsync(id, target); the server validates and applies. Entity stats/health/positions come through seams, so mobs and players share the same system. Rides the unified protocol. Depends on SetNet + SetNet.Stats + SetNet.Combat. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.0 | 197 | 8/5/2026 |