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
-
IRuntimeDataContainer<INetworkManagerWrapper, ServerManager, NetworkConnection, IRuntimeDataContainer>
- 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
characterIDlongThe 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
characterIDlongThe character to read.
nowfloatCurrent unscaled time, in seconds.
encounterTimeoutSecondsfloatIdle time after which an encounter is over.
minimumWindowSecondsfloatFloor 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
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
characterIDlongThe character that dealt the damage.
amountfloatDamage amount; non-positive amounts are ignored.
nowfloatCurrent unscaled time, in seconds.
encounterTimeoutSecondsfloatIdle 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
characterIDlongThe character that did the healing.
amountfloatHealing amount; non-positive amounts are ignored.
nowfloatCurrent unscaled time, in seconds.
encounterTimeoutSecondsfloatIdle 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
nowfloatCurrent unscaled time, in seconds.
staleAfterSecondsfloatIdle time after which an entry is discarded.
maxScanintMaximum entries to examine.
maxRemoveintMaximum entries to remove.
Returns
- int
The number of entries removed.