SetNet.StatusEffects 1.2.0

dotnet add package SetNet.StatusEffects --version 1.2.0
                    
NuGet\Install-Package SetNet.StatusEffects -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SetNet.StatusEffects" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SetNet.StatusEffects" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SetNet.StatusEffects" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SetNet.StatusEffects --version 1.2.0
                    
#r "nuget: SetNet.StatusEffects, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SetNet.StatusEffects@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SetNet.StatusEffects&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SetNet.StatusEffects&version=1.2.0
                    
Install as a Cake Tool

<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>

SetNet.StatusEffects

Server-authoritative buffs and debuffs for SetNet.

Apply timed, stacking status effects (poison, haste, shield…) to any target key — a player or an entity id. The server owns the effects, a timer expires them, and every change is pushed to the affected player and to anyone watching that target (so players fighting a boss see its debuffs tick down). Stacking and refresh behaviour is configurable per effect type. This layer tracks the effects; interpreting a magnitude (armor bonus, damage-over-time) is your game logic. Added by composition — no base class.

Install

dotnet add package SetNet
dotnet add package SetNet.StatusEffects

Usage

Call StatusEffectRuntime.Enable() once at startup on both ends.

// server
StatusEffectRuntime.Enable();
var effects = server.UseStatusEffects();
effects.Define(new StatusEffectDefinition("poison", maxStacks: 5, defaultDurationMs: 8000, stacking: StackPolicy.Stack, isDebuff: true));
effects.Define(new StatusEffectDefinition("haste",  defaultDurationMs: 5000, stacking: StackPolicy.Refresh));

// game logic (an ability hits a player or a mob entity id):
await effects.ApplyAsync(targetKey: victimPlayerKey, "poison", stacks: 2, magnitude: 12, source: casterKey);
await effects.ApplyAsync(targetKey: "mob:dragon#7", "haste", durationMs: 3000);
await effects.RemoveAsync(victimPlayerKey, "poison");   // a cleanse

// client
StatusEffectRuntime.Enable();
var effects = client.UseStatusEffects();
effects.Changed += (target, list) => DrawEffectBar(target, list);

await effects.WatchAsync(myPlayerKey);       // my own buffs/debuffs
await effects.WatchAsync("mob:dragon#7");    // the boss I'm fighting

API

Server: server.UseStatusEffects(StatusEffectOptions?) → StatusEffectServer (Dispose() stops the timer)

Member Purpose
Define(StatusEffectDefinition) register stack/refresh/duration rules for an effect type
ApplyAsync(targetKey, effectId, durationMs = 0, stacks = 1, magnitude = 0, source = "") apply/refresh an effect
RemoveAsync(targetKey, effectId) / ClearAsync(targetKey) cleanse
GetAsync(targetKey) current effects

Client: client.UseStatusEffects() → StatusEffectClient — GetAsync(targetKey), WatchAsync(targetKey), UnwatchAsync(targetKey), event Changed.

Definition: EffectId, MaxStacks, DefaultDurationMs (0 = permanent), Stacking (Refresh/Stack/Ignore), IsDebuff.

StatusEffectRuntime.Enable() — one-time bootstrap.

Notes

  • Rides the unified SetNet.Protocol messaging layer on the Channels.StatusEffects channel (all modules share one envelope wire type, 65447) — no per-module wire ids to reserve. Serializer-agnostic: the control protocol is hand-framed byte[], your payloads use your SetNetSerializer.
  • Target keys are arbitrary. A player key (the affected player gets pushes automatically) or an entity id like "mob:dragon#7" (no peer — read via GetAsync, or let nearby players WatchAsync it). By default the player key is the connection id; override StatusEffectOptions.TargetKey.
  • Stacking policies. Refresh resets duration and keeps the higher stack count; Stack adds stacks up to MaxStacks and refreshes; Ignore drops a re-application while one is active. Unregistered effects default to single-stack refresh.
  • Effects are just data here. The Magnitude and stack count are yours to interpret in combat/stat code. Pair with SetNet.StateSync if you also replicate entity transforms, and drive interest (who watches a mob) from your spatial logic.
  • Not persisted. Effects live in memory and expire on the timer; that's the usual lifetime for combat buffs. Re-apply on respawn/zone-in as your design requires.

Documentation & source

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 146 8/5/2026