WeaponStateFactory

Contains all the available Weapon States.

How can I add a new State?

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

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() { }

    }
}

Once you have this, we need to register this state in the WeaponStateFactory.cs as shown:

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

List of Available WeaponStates

  1. WeaponDefaultState

  2. WeaponShootingState

  3. WeaponReloadingState

  4. WeaponInspectState

  5. MeleeState

Last updated