> For the complete documentation index, see [llms.txt](https://unfinishedstudios1.gitbook.io/fp-motion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unfinishedstudios1.gitbook.io/fp-motion/components/events/action.md).

# Action

## Fields

| Field | Description                 |
| ----- | --------------------------- |
| State | Is the event active or not? |

## Methods

## SubscribeToStart

<mark style="color:orange;">`PUT`</mark> `SubscribeTo(Event newEvent)`

Invoking this method will subscribe the event you pass to this *Action,* making it a listener to the start event.

#### Path Parameters

| Name     | Type   | Description                                                           |
| -------- | ------ | --------------------------------------------------------------------- |
| newEvent | object | Determines the method you want to subscribe to this *Action's* start. |

{% tabs %}
{% tab title="200 In this example we want to print Aiming! whenever the player starts aiming. We can do this by using this method." %}

```csharp
private void OnAim(){
    Debug.Log("Aiming!");
}

PlayerEvents.Aim.SubscribeToStart(OnAim);
```

{% endtab %}
{% endtabs %}

## SubscribeToStop

<mark style="color:orange;">`PUT`</mark> `SubscribeToStop(Event newEvent)`

Invoking this method will subscribe the event you pass to this *Action,* making it a listener to the stop event.

#### Path Parameters

| Name     | Type   | Description                                                          |
| -------- | ------ | -------------------------------------------------------------------- |
| newEvent | object | Determines the method you want to subscribe to this *Action's* stop. |

{% tabs %}
{% tab title="200 In this example we want to print Aiming! whenever the player stops aiming. We can do this by using this method." %}

```csharp
private void OnAim(){
    Debug.Log("Aiming!");
}

PlayerEvents.Aim.SubscribeToStop(OnAim);
```

{% endtab %}
{% endtabs %}

## AddStartTrier

<mark style="color:orange;">`PUT`</mark> `AddStartTrier(TryDelegate newTrier)`

Invoking this method will make the function you passed the new start trier for this *Action.*

#### Path Parameters

| Name     | Type    | Description                                                                            |
| -------- | ------- | -------------------------------------------------------------------------------------- |
| newTrier | boolean | Function with a return type of boolean that will be used as a trier for this *Action.* |

{% tabs %}
{% tab title="200 We can use this method as a way to locally check whether to allow an Action to change state or not." %}

```csharp
private bool OnTry_Aim(){
    if(canAim)
        return true;
    else
        return false;
}

PlayerEvents.Aim.AddStartTrier(OnTry_Aim);
```

{% endtab %}
{% endtabs %}

## AddStopTrier

<mark style="color:orange;">`PUT`</mark> `AddStopTrier(TryDelegate newTrier)`

Invoking this method will make the function you passed the new stop trier for this *Action.*

#### Path Parameters

| Name     | Type    | Description                                                                            |
| -------- | ------- | -------------------------------------------------------------------------------------- |
| newTrier | boolean | Function with a return type of boolean that will be used as a trier for this *Action.* |

{% tabs %}
{% tab title="200 We can use this method as a way to locally check if we should allow the Action to stop once it has started." %}

```csharp
private bool OnTryStop_Aim(){
    if(canAim)
        return true;
    else
        return false;
}

PlayerEvents.Aim.AddStopTrier(OnTryStop_Aim);
```

{% endtab %}
{% endtabs %}

## TryStart

<mark style="color:green;">`POST`</mark> `TryStart()`

Invoking this method will try to start this *Action,* meaning that it will first invoke the triers and make sure they all return true before starting.

{% tabs %}
{% tab title="200 As you can see, this method is really simple to invoke, but should not be used too much as it checks triers every time." %}

```csharp
PlayerEvents.Aim.TryStart();
```

{% endtab %}
{% endtabs %}

## TryStop

<mark style="color:green;">`POST`</mark> `TryStop()`

Invoking this method will try to stop this *Action*, meaning it will first invoke the triers and make sure they all return before properly stopping it.

{% tabs %}
{% tab title="200 In this example we are trying to stop the aiming, this will only work if aiming is current happening, and if the triers allow us to stop it." %}

```csharp
PlayerEvents.Aim.TryStop();
```

{% endtab %}
{% endtabs %}

## ForceStart

<mark style="color:green;">`POST`</mark> `ForceStart()`

Invoking this method will allow you to directly skip over the triers and start the *Action.*

{% tabs %}
{% tab title="200 In this case, the code will directly start the aiming Action." %}

```
PlayerEvents.Aim.ForceStart();
```

{% endtab %}
{% endtabs %}

## ForceStop

<mark style="color:green;">`POST`</mark> `ForceStop()`

Invoking this method will allow you to directly skip over the triers and stop the *Action.* This forceful approach is necessary sometimes.

{% tabs %}
{% tab title="200 In this case the code will directly stop the aiming Action." %}

```
PlayerEvents.Aim.ForceStop();
```

{% endtab %}
{% endtabs %}

## ForceToggle

<mark style="color:green;">`POST`</mark> `ForceToggle()`

Invoking this method will forcefully switch the *Action's* state. *Actions* that are started will be forcefully stopped, and ones that are stopped will be forcefully started.

{% tabs %}
{% tab title="200 This method is helpful for things like crouching, where you just need to toggle the state when the player presses a button." %}

```csharp
if(Input.GetKeyCode(KeyCode.C))
    PlayerEvents.Crouch.ForceToggle();
```

{% endtab %}
{% endtabs %}

## Debug

`OPTIONS` `Debug(bool debugAttempts = false, string name = "Debug")`

Logs the names of the methods subscribed to this Attempt, and the Triers added.

#### Path Parameters

| Name          | Type    | Description                                                                                               |
| ------------- | ------- | --------------------------------------------------------------------------------------------------------- |
| Name          | string  | Simple name that you can give this debug, making it easier to not confuse it when debugging other things. |
| DebugAttempts | boolean | ​Determines whether you want to debug the triers of this attempt, or only the listeners.                  |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}
