public sealed class RewindBudgetHow much rewinding one connection may cost the server, per second.
Remarks
Doc 16's owed "cost budget for rewinds", closed here because doc 28 § Shooting says this library is the reason to close it. A rewound hit claim costs a physics scene rolled back and re-traced; an ordinary remote call costs a dictionary lookup. A rate limiter that counts them the same lets a client spend a whole server frame with a flood that is, packet for packet, entirely inside its rate.
⚠ A deeper rewind costs more, and that is the whole reason this is not just a second rate limit. Rolling back two ticks is cheap and rolling back thirty is not, so charging per tick makes the price track the work. A player on a bad connection legitimately pays more — which is correct, because they legitimately cost more — and the refill rate is where a game decides how much of that it is willing to fund.
Policy here, enforcement in the router. This library has no networking and must not grow any; what it owns is the arithmetic of what a claim costs. RpcRouter's per-connection limiter is what should consult it, which keeps one limiter rather than two that disagree.
Fields and properties (4)
public float CapacityThe most a connection may bank.
public float RefillPerSecondHow fast it comes back.
public float CostPerTickWhat one tick of rewind costs.
public float MinimumCostWhat a claim costs even when it rewinds nothing.
Methods (6)
public RewindBudget(float capacity = 120, float refillPerSecond = 60, float costPerTick = 1, float minimumCost = 1)Makes a budget.
public float CostOf(int rewindTicks)What a rewind of this depth costs.
public float RemainingFor(ulong connection)How much one connection has left.
public bool TryConsume(ulong connection, int rewindTicks)Spends a rewind's cost, if there is room for it.
public void Tick(float delta)Refills every connection.
public bool Forget(ulong connection)Forgets a connection — it left.
Used by (3)
- HitClaimValidatorVixen.Gameplay.Shooting
- HitClaimValidatorTestsVixen.Gameplay.Shooting.Tests
- RewindBudgetTestsVixen.Gameplay.Shooting.Tests