# WeaponStateFactory

Contains all the available Weapon States.

{% hint style="info" %}
How can I add a new State?

First, make a new script that inherits from WeaponBaseState. Take a look at the provided example code:
{% endhint %}

```csharp
using UnityEngine;
namespace cowsins
{
    public class WeaponCustomState : WeaponBaseState
    {

        public WeaponCustomState (WeaponStates currentContext, WeaponStateFactory weaponStateFactory)
            : base(currentContext, weaponStateFactory) { }

        public override void EnterState()
        {
            // Do something on entering the state
        }

        public override void UpdateState()
        {
            CheckSwitchState();
        }

        public override void FixedUpdateState() { }

        public override void ExitState() {
            // Do something on exiting the state
        }

        public override void CheckSwitchState() { }

        public override void InitializeSubState() { }

    }
}
```

{% hint style="info" %}
Once you have this, we need to register this state in the WeaponStateFactory.cs as shown:
{% endhint %}

```csharp
public WeaponBaseState Die() { return new WeaponCustomState(_context, this); }
```

## List of Available WeaponStates

1. WeaponDefaultState
2. WeaponShootingState
3. WeaponReloadingState
4. WeaponInspectState
5. MeleeState


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cowsinss-organization.gitbook.io/fps-engine-documentation/content/03.-content/03.3-player/weapon-states/weaponstatefactory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
