Table of Contents

Class PartyCombatMeterData

Namespace
FishMMO.Server.Implementation.World.SceneServer
Assembly
FishMMO.Server.dll

Runtime data container holding per-encounter damage and healing meters.

public class PartyCombatMeterData : RuntimeDataContainer, IRuntimeDataContainer<INetworkManagerWrapper, ServerManager, NetworkConnection, IRuntimeDataContainer>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IRuntimeDataContainer>, IPartyCombatMeterData, IRuntimeDataContainer, IServerComponent
Inheritance
PartyCombatMeterData
Implements
Inherited Members

Remarks

Deliberately a plain dictionary rather than the shared LastSeenCacheTracker the invitation caches use. That tracker allocates a linked-list node on every touch, and this is touched once per landed hit for every character on the scene server — a per-hit allocation in the combat path is a far worse trade than the small amount of bookkeeping below.

Bounded cleanup is done with a rotating cursor over a key ring instead of a time-ordered queue, because entries are re-touched constantly and constantly re-ordering a queue is the very cost being avoided. The ring never has to be exact: a key it still holds for an entry that has already gone is simply dropped when the cursor next reaches it.

Methods

Clear()

Clears all runtime data in this container, resetting it to initial state. Must be implemented by derived classes.

public override void Clear()

Forget(long)

Drops a character's meter entirely.

public void Forget(long characterID)

Parameters

characterID long

The character to forget.

GetSample(long, float, float, float)

Reads a character's current rates.

public PartyCombatMeterSample GetSample(long characterID, float now, float encounterTimeoutSeconds, float minimumWindowSeconds)

Parameters

characterID long

The character to read.

now float

Current unscaled time, in seconds.

encounterTimeoutSeconds float

Idle time after which an encounter is over.

minimumWindowSeconds float

Floor on the divisor. Without one, the first hit of a fight divides by very nearly zero and reports a rate in the millions for one tick.

Returns

PartyCombatMeterSample

The character's rates, or a zeroed sample when it has no encounter running — including when its last encounter has timed out, which is reported as zero rather than as no reading so a stale number can never survive on a client's meter.

InitializeOnce()

Called once to initialize the data container. Must be implemented by derived classes.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

OnDeinitialize()

Called when the data container is being deinitialized. Must be implemented by derived classes.

protected override void OnDeinitialize()

RecordDamage(long, float, float, float)

Credits a character with damage dealt.

public void RecordDamage(long characterID, float amount, float now, float encounterTimeoutSeconds)

Parameters

characterID long

The character that dealt the damage.

amount float

Damage amount; non-positive amounts are ignored.

now float

Current unscaled time, in seconds.

encounterTimeoutSeconds float

Idle time after which an encounter is over.

RecordHealing(long, float, float, float)

Credits a character with healing done.

public void RecordHealing(long characterID, float amount, float now, float encounterTimeoutSeconds)

Parameters

characterID long

The character that did the healing.

amount float

Healing amount; non-positive amounts are ignored.

now float

Current unscaled time, in seconds.

encounterTimeoutSeconds float

Idle time after which an encounter is over.

Sweep(float, float, int, int)

Removes meters whose encounters have long since ended, up to a bounded count.

public int Sweep(float now, float staleAfterSeconds, int maxScan, int maxRemove)

Parameters

now float

Current unscaled time, in seconds.

staleAfterSeconds float

Idle time after which an entry is discarded.

maxScan int

Maximum entries to examine.

maxRemove int

Maximum entries to remove.

Returns

int

The number of entries removed.