Class MagazineState
Mutable state tracking the current ammo in a weapon's magazine.
Inherited Members
Namespace: Serenity.GameWeapon.Domain.Entities
Assembly: Serenity.GameWeapon.Domain.dll
Syntax
public class MagazineState
Constructors
MagazineState(int, int)
Creates a new MagazineState with the specified capacity.
Declaration
public MagazineState(int maxCapacity, int currentAmmo = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxCapacity | The maximum ammo capacity. Must be greater than zero. |
| int | currentAmmo | The initial ammo count. Defaults to max capacity. |
Properties
CurrentAmmo
Gets the current number of rounds in the magazine.
Declaration
public int CurrentAmmo { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsEmpty
Gets whether the magazine is empty.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsFull
Gets whether the magazine is full.
Declaration
public bool IsFull { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MaxCapacity
Gets the maximum ammo capacity of the magazine.
Declaration
public int MaxCapacity { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
ConsumeRound()
Consumes one round from the magazine.
Declaration
public bool ConsumeRound()
Returns
| Type | Description |
|---|---|
| bool | True if a round was consumed; false if the magazine was empty. |
Reload()
Reloads the magazine to full capacity.
Declaration
public void Reload()
Reload(int)
Reloads the magazine with a specific amount of rounds.
Declaration
public void Reload(int amount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | amount | The number of rounds to add. |