Interface IGameWeaponService
Service interface for managing generic weapon state and actions.
Namespace: Serenity.GameWeapon.Application.Interfaces
Assembly: Serenity.GameWeapon.Application.dll
Syntax
public interface IGameWeaponService : IService, IFoundationSettings
Remarks
Weapon actions express intent, not immediate effects. Timing, targeting, and combat consequences are handled by other systems. Implementations coordinate WeaponState transitions while enforcing weapon invariants (e.g. no firing with empty magazine).
Methods
AcquireWeapon(WeaponId)
Adds a registered weapon to the arsenal.
Declaration
void AcquireWeapon(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity to acquire. |
Remarks
A no-op — the weapon is not added and no signal is dispatched — when id was
never registered via RegisterWeapon(WeaponId, int, FireMode). Adding an already-acquired weapon is also a
no-op (the arsenal is a set, not a bag).
AddReserveAmmo(WeaponId, int)
Adds rounds to the specified weapon's ammo reserve.
Declaration
void AddReserveAmmo(WeaponId id, int amount)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| int | amount | The number of rounds to add. |
ConsumeAmmo(WeaponId)
Consumes one round of ammo from the specified weapon's magazine.
Declaration
bool ConsumeAmmo(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
Returns
| Type | Description |
|---|---|
| bool | True if ammo was consumed; false if the magazine is empty. |
CycleNextWeapon()
Advances the arsenal to the next weapon, wrapping around.
Declaration
bool CycleNextWeapon()
Returns
| Type | Description |
|---|---|
| bool | True if the active weapon changed; false when fewer than two weapons are in the arsenal. |
GetActiveWeapon()
Returns the currently active weapon.
Declaration
WeaponId GetActiveWeapon()
Returns
| Type | Description |
|---|---|
| WeaponId | The active WeaponId, or the default WeaponId when the arsenal is empty. |
GetArsenalSnapshot()
Returns an immutable snapshot of the arsenal.
Declaration
ArsenalSnapshot GetArsenalSnapshot()
Returns
| Type | Description |
|---|---|
| ArsenalSnapshot | An ArsenalSnapshot of the current arsenal order and active selection. |
GetSnapshot(WeaponId)
Returns an immutable snapshot of the specified weapon's state.
Declaration
WeaponSnapshot GetSnapshot(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
Returns
| Type | Description |
|---|---|
| WeaponSnapshot | A WeaponSnapshot of the weapon's current state. |
RegisterWeapon(WeaponId, int, FireMode)
Registers a weapon with the specified identity and configuration.
Declaration
void RegisterWeapon(WeaponId id, int maxCapacity, FireMode fireMode)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| int | maxCapacity | The maximum magazine capacity. |
| FireMode | fireMode | The initial fire mode. |
ReloadComplete(WeaponId, int)
Marks a reload as complete for the specified weapon.
Declaration
void ReloadComplete(WeaponId id, int ammoLoaded)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| int | ammoLoaded | The number of rounds loaded. Added to the current ammo, capped at the magazine's max capacity. A negative value fills the magazine to full instead. |
ReloadCompleteFromReserve(WeaponId)
Completes an in-progress reload, filling the magazine from the ammo reserve.
Declaration
int ReloadCompleteFromReserve(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
Returns
| Type | Description |
|---|---|
| int | The number of rounds actually loaded into the magazine. |
ReloadRequested(WeaponId)
Requests a reload for the specified weapon.
Declaration
void ReloadRequested(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
SetActiveWeapon(WeaponId)
Sets the active weapon directly.
Declaration
bool SetActiveWeapon(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity to make active. |
Returns
| Type | Description |
|---|---|
| bool | True if the weapon was in the arsenal and made active; false if it was not present. |
SetFireCadence(WeaponId, float)
Sets the minimum time between shots for the specified weapon.
Declaration
void SetFireCadence(WeaponId id, float minimumSecondsBetweenShots)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| float | minimumSecondsBetweenShots | The minimum seconds between shots. Zero or less means ungated. |
SetFireMode(WeaponId, FireMode)
Sets the fire mode for the specified weapon.
Declaration
void SetFireMode(WeaponId id, FireMode fireMode)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| FireMode | fireMode | The new fire mode. |
SetReserve(WeaponId, int, int)
Configures the ammo reserve for the specified weapon.
Declaration
void SetReserve(WeaponId id, int maxCapacity, int currentAmmo)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| int | maxCapacity | The maximum reserve capacity. A negative value means infinite. |
| int | currentAmmo | The initial reserve ammo. Ignored when the reserve is infinite. |
TriggerPressed(WeaponId)
Signals that the trigger has been pressed.
Declaration
void TriggerPressed(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
TriggerReleased(WeaponId)
Signals that the trigger has been released.
Declaration
void TriggerReleased(WeaponId id)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
TryFire(WeaponId, float)
Attempts to fire the specified weapon at the given time, gated by its fire cadence.
Declaration
bool TryFire(WeaponId id, float nowSeconds)
Parameters
| Type | Name | Description |
|---|---|---|
| WeaponId | id | The weapon identity. |
| float | nowSeconds | The current time, in seconds, supplied by the caller. |
Returns
| Type | Description |
|---|---|
| bool | True if a round was consumed; false if reloading, empty, cadence-blocked, or the id is unknown. |