> For the complete documentation index, see [llms.txt](https://heroicsolo.gitbook.io/heroic-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heroicsolo.gitbook.io/heroic-engine/basics/publish-your-docs/core-systems/events-manager.md).

# Events Manager

{% hint style="info" %}
Events Manager supports events with up to 2 parameters of any type.
{% endhint %}

To use this system, inject IEventsManager interface into your class, as shown below:

```csharp
[Inject] private IEventsManager eventsManager;
```

### Available methods

***

<pre class="language-csharp"><code class="lang-csharp"><strong>void RegisterListener(string eventType, UnityAction listener)
</strong></code></pre>

*Registers event listener without parameters.*

*Examples:*

```csharp
eventsManager.RegisterListener("PlayerDeath", OnPlayerDeath);
eventsManager.RegisterListener("GameWin", () => { Debug.Log("Victory!"); });
```

***

```csharp
void RegisterListener<T>(string eventType, UnityAction<T> listener)
```

*Registers event listener with single parameter of any type.*

*Examples:*

```csharp
eventsManager.RegisterListener<int>("PlayerDamageGot", OnPlayerDamageGot);
eventsManager.RegisterListener("GameWin", (score) => { Debug.Log($"Victory! Score: {score}"); });
```

***

```csharp
void RegisterListener<T1, T2>(string eventType, UnityAction<T1, T2> listener)
```

*Registers event listener with 2 parameters of any types.*

*Example:*

```csharp
eventsManager.RegisterListener<int, string>("PlayerDamageGot", (damage, enemyName) => { Debug.Log($"Damage got: {damage} from {enemyName}"); });
```

***

```csharp
void UnregisterListener(string eventType, UnityAction listener)
```

*Unregisters event listener without parameters.*

*Example:*

```csharp
eventsManager.UnregisterListener("PlayerDeath", OnPlayerDeath);
```

***

```csharp
void UnregisterListener<T>(string eventType, UnityAction<T> listener)
```

*Unregisters event listener with 1 parameter of any type.*

*Example:*

```csharp
eventsManager.UnregisterListener<int>("PlayerDamageGot", OnPlayerDamageGot);
```

***

```csharp
void UnregisterListener<T1, T2>(string eventType, UnityAction<T1, T2> listener)
```

*Unregisters event listener with 2 parameters of any types.*

*Example:*

```csharp
eventsManager.UnregisterListener<int, string>("PlayerDamageGot", OnPlayerDamageGot);
```

***

```csharp
void TriggerEvent(string eventType)
```

*Triggers event without parameters.*

*Example:*

```csharp
eventsManager.TriggerEvent("PlayerDeath");
```

***

```csharp
void TriggerEvent<T>(string eventType, T value)
```

*Triggers event with 1 parameter of any type.*

*Example:*

```csharp
eventsManager.TriggerEvent<int>("GameWin", score);
```

***

```csharp
void TriggerEvent<T1, T2>(string eventType, T1 value1, T2 value2)
```

*Triggers event with 2 parameters of any types.*

*Example:*

```csharp
eventsManager.TriggerEvent<int, string>("OnDamageGot", damage, enemyName);
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://heroicsolo.gitbook.io/heroic-engine/basics/publish-your-docs/core-systems/events-manager.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.
