Class FireCadence
Mutable state tracking a weapon's minimum time between shots, in explicit caller-supplied time. Owned by the WeaponState aggregate; has no dependency on any engine clock.
Inherited Members
Namespace: Serenity.GameWeapon.Domain.Entities
Assembly: Serenity.GameWeapon.Domain.dll
Syntax
public class FireCadence
Constructors
FireCadence(float)
Creates a new FireCadence with no shot recorded yet.
Declaration
public FireCadence(float minimumSecondsBetweenShots = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float | minimumSecondsBetweenShots | The minimum seconds between shots, clamped up to UngatedCadenceSeconds when lower. |
Fields
UngatedCadenceSeconds
The MinimumSecondsBetweenShots value that means the cadence is ungated — every call to CanFireAt(float) returns true. Retune(float) clamps up to this.
Declaration
public const float UngatedCadenceSeconds = 0
Field Value
| Type | Description |
|---|---|
| float |
Properties
LastShotTimeSeconds
Gets the time, in seconds, at which the last shot was recorded. NegativeInfinity means no shot has ever been recorded.
Declaration
public float LastShotTimeSeconds { get; }
Property Value
| Type | Description |
|---|---|
| float |
MinimumSecondsBetweenShots
Gets the minimum number of seconds required between two shots. Never below UngatedCadenceSeconds. Change it via Retune(float).
Declaration
public float MinimumSecondsBetweenShots { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
CanFireAt(float)
Checks whether a shot is allowed at the given time.
Declaration
public bool CanFireAt(float nowSeconds)
Parameters
| Type | Name | Description |
|---|---|---|
| float | nowSeconds | The current time, in seconds, supplied by the caller. |
Returns
| Type | Description |
|---|---|
| bool | True if the cadence is ungated, no shot has been recorded yet, or at least MinimumSecondsBetweenShots has elapsed since LastShotTimeSeconds. |
RecordShotAt(float)
Records that a shot was fired at the given time.
Declaration
public void RecordShotAt(float nowSeconds)
Parameters
| Type | Name | Description |
|---|---|---|
| float | nowSeconds | The current time, in seconds, supplied by the caller. |
Reset()
Resets the cadence to its never-fired state.
Declaration
public void Reset()
Retune(float)
Changes the minimum seconds required between two shots.
Declaration
public void Retune(float minimumSecondsBetweenShots)
Parameters
| Type | Name | Description |
|---|---|---|
| float | minimumSecondsBetweenShots | The new minimum seconds between shots, clamped up to UngatedCadenceSeconds when lower. |