> For the complete documentation index, see [llms.txt](https://solo-player.gitbook.io/most-in-one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://solo-player.gitbook.io/most-in-one/most-systems/most-gate.md).

# MOST Gate

A configurable gate system with input/output logic (math/custom), automatic text labeling (positive, negative, or empty), animations, and a customizable output hook with model management.

<figure><img src="/files/WCYQozYAJovLgGTBiYcS" alt=""><figcaption></figcaption></figure>

### <mark style="color:$info;">Gate Structure</mark>

<figure><img src="/files/ctB6hpXqcaWrr61AWBh8" alt=""><figcaption></figcaption></figure>

Depending on the Gate Text (Output), MOST\_Gate will automatically select the active model between Positive, Negative, and Custom models, all directly in edit mode

{% hint style="info" %}

* If Output Text is a Positive number or a True value >> the selected gate is <mark style="color:blue;">**Positive**</mark>
* If Output Text is a Negative number or a False value >> the selected gate is <mark style="color:red;">**Negative**</mark>
* If Output Text is another value (string) >> the selected gate is <mark style="color:green;">**Custom**</mark>
  {% endhint %}

<figure><img src="/files/GrUbsbNvQYMBTl3NCCsF" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}

* All Gate Models properties are optional to add...
* There are no restrictions on the gate object/prefab structure; you can customize or rebuild the gate system without any restrictions
* You will find tons of gate structures inside Gate prefabs folder
  {% endhint %}

<mark style="color:yellow;">**Gate Post (TMP)**</mark>**&#x20;is a Text to display the main gate output text**

<mark style="color:yellow;">**Fixed Output (TMP)**</mark>**&#x20;is a Text to display the secondary gate output text (Fixed because it can't be edited by upgrade).**

{% hint style="info" %} <mark style="color:red;">**secondary gate output**</mark>**&#x20;can be used if the main gate output is used for something else, like for the upgrades or other stuff (a lot of examples will be found on Gate prefab)**
{% endhint %}

## <mark style="color:$info;">Set up The Gate</mark>

* <mark style="color:yellow;">**Gate Output:**</mark> Set the text <mark style="color:red;">as a string</mark>. <mark style="color:yellow;">Numbers</mark> <mark style="color:red;">must start with a sign (</mark><mark style="color:yellow;">+</mark><mark style="color:red;">,</mark> <mark style="color:yellow;">-</mark><mark style="color:red;">,</mark> <mark style="color:yellow;">x</mark><mark style="color:red;">,</mark>  <mark style="color:yellow;">÷</mark><mark style="color:red;">),</mark> <mark style="color:$primary;">with option to hide the sign</mark>\ <mark style="color:$primary;">**The gate will automatically detect the type of output and activate the target game model**</mark><br>
* <mark style="color:yellow;">**Gate Type:**</mark>**&#x20;**<mark style="color:$primary;">**As an enum menu...**</mark>\ <mark style="color:$primary;">**You can add/edit types from Most\_Gate cs Line 25**</mark>

```csharp
public enum GateType 
{ 
  Health,
  FireRate,
  FireRange,
  Upgrade,
  AddChildren,
  Currency,
  Other /* Edit or Add More Types */ 
}

```

* <mark style="color:yellow;">**Trigger the gate:**</mark>&#x20;

<pre class="language-csharp"><code class="lang-csharp">// Use the gate calculations to return the output and use it on your objects

<strong>Most_Gate.Calculation(); // returns the output text if it's a number
</strong>// ex: x6 returns 6, +5 returns 5, -3 returns -3

Most_Gate.Calculation(float input); // returns the output equation with the input
// ex: input = 10, gate text = +5, returns 15

</code></pre>

Use Calculation() on your objects to trigger the gate

```csharp
// In Game Example... 
// A game object with a collision system has power and health property

using UnityEngine;

public class CharacterControl_Gun : MonoBehaviour
{
    [Tooltip("This value will be updated using MOST_Gate")]
    [Min(0)] public float Power = 10;
    [Min(0)] public float Health = 50;
    
    // if this game object triggers a gate object
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Gate")) // Gate tag check
        {
            // accepts only if the object has Most_Gate system
            if (other.GetComponent<Most_Gate>()) 
            GateTriggered(other.GetComponent<Most_Gate>());
        }
    }
    
    void GateTriggered(Most_Gate gate)
    {
        if (gate.IsCollected) return; // if this gate not triggered before
        switch (gate.Type) // Type Check
        {
            case Most_Gate.GateType.Upgrade:
                Power = gate.Calculation(Power); 
                break;
                
            case Most_Gate.GateType.Upgrade:
                Health = gate.Calculation(Health); 
                break;
                
            default: Debug.Log("This Gate type is not defined on this character control");
    }
}
```

## <mark style="color:red;">MORE... API reference</mark>

{% hint style="success" %} <mark style="color:green;">**All public properties can be updated at runtime, and the changes will be set immediately.**</mark>
{% endhint %}

<pre class="language-csharp"><code class="lang-csharp">// Next to each line shows the return and set data Type 

Most_Gate.Calculation(); // returns the output text if it's a number
// ex: x6 returns 6, +5 returns 5, -3 returns -3

Most_Gate.Calculation(float input); // returns the output equation with the input
// ex: input = 10, gate text = +5, returns 15

Most_Gate.GetSign(); // returns a custom enum from Solo.MOST.IN.ONE namespace
 { Plus, Minus, Subtract, Multiply, NoSign }
// NoSign for non-num output

//_______________________________________________________________//

// return Gate Type
// You can update the Gate type at runtime without any issues
Most_Gate.Type return enum GateType

// true if this gate got triggered / Calculation()
Most_Gate.IsCollected return bool

// Main Gate output
Most_Gate.GateText return or set

// secondary Gate output
Most_Gate.OutputText return or set

// controls the output calculations scale
// for example // if the output +10 and rescale = 0.1f the calculation() will return 10 * .1f
<strong>Most_Gate.AmountRescale return or set
</strong>
// make secondary gate output the target output in the calculation
Most_Gate.EnableFixedOutput return or set

// controls the upgrade system. enable or disable
Most_Gate.EnableUpgrade return or set
</code></pre>
