# Listening to Events

When a class needs to receive events related to the stored game data, such as a player being hit, or respawned, it must implement the `MentalMapEventListener` interface. Once registered in the `MentalMap`, it will receive data-related events each time a change in the game data occurs.

## MentalMapEventListener

This interface has the following functions, that are called when the corresponding event is triggered in the `MentalMap`:

* `onTargetHit()`: this function will be called whenever a target is hit.
* `onRespawn()`: this function will be called whenever the player is respawned.


---

# 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://asrob-uc3m.gitbook.io/robotdevastation-developer-manual/robotdevastation/managers/data-management/listening-to-events.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.
