logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class WeaponState

    Mutable state of a weapon instance, tracking magazine, fire mode, and trigger state. Enforces basic weapon invariants (e.g. no firing with empty magazine).

    Inheritance
    object
    WeaponState
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameWeapon.Domain.Entities
    Assembly: Serenity.GameWeapon.Domain.dll
    Syntax
    public class WeaponState

    Constructors

    WeaponState(WeaponId, MagazineState, FireMode)

    Creates a new WeaponState with the specified parameters.

    Declaration
    public WeaponState(WeaponId id, MagazineState magazine, FireMode fireMode)
    Parameters
    Type Name Description
    WeaponId id

    The weapon identity.

    MagazineState magazine

    The initial magazine state.

    FireMode fireMode

    The initial fire mode.

    Properties

    FireMode

    Gets or sets the current fire mode.

    Declaration
    public FireMode FireMode { get; set; }
    Property Value
    Type Description
    FireMode

    Id

    Gets the identity of this weapon.

    Declaration
    public WeaponId Id { get; }
    Property Value
    Type Description
    WeaponId

    IsReloading

    Gets whether the weapon is currently reloading.

    Declaration
    public bool IsReloading { get; }
    Property Value
    Type Description
    bool

    IsTriggerPressed

    Gets whether the trigger is currently pressed.

    Declaration
    public bool IsTriggerPressed { get; }
    Property Value
    Type Description
    bool

    Magazine

    Gets the current magazine state.

    Declaration
    public MagazineState Magazine { get; }
    Property Value
    Type Description
    MagazineState

    Methods

    ReloadCompleted()

    Completes an in-progress reload, filling the magazine.

    Declaration
    public void ReloadCompleted()

    ReloadRequested()

    Requests a reload. Returns true if reload was initiated.

    Declaration
    public bool ReloadRequested()
    Returns
    Type Description
    bool

    True if reload started (not already reloading and not full); otherwise false.

    ToSnapshot()

    Creates an immutable snapshot of the current weapon state.

    Declaration
    public WeaponSnapshot ToSnapshot()
    Returns
    Type Description
    WeaponSnapshot

    A read-only snapshot of the weapon state.

    TriggerPressed()

    Presses the trigger. Returns true if firing is allowed.

    Declaration
    public bool TriggerPressed()
    Returns
    Type Description
    bool

    True if the weapon can fire (not empty, not reloading); otherwise false.

    TriggerReleased()

    Releases the trigger.

    Declaration
    public void TriggerReleased()
    In this article
    © 2026 Serenity. All Rights Reserved