> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/game-modules-actor.md).

# Game Modules Actor

v4.0

**Game Modules 4** introduces the `GameModulesActor` class, along with the `GameModulesInventoryActor`.  These classes are set up to automate the Game Module systems.

You can inherit from these classes! The **Party Based RPG demo game** `DemoActor` inhertis from `GameModulesInventoryActor`.

{% hint style="info" %}
If you're using the [**Inventory**](/magic-pig-games/game-modules-4/game-module-systems/inventory.md) system, inherit from `GameModulesInventoryActor`. Otherwise, inherit from `GameModulesActor`.
{% endhint %}

{% embed url="<https://youtu.be/gl9Ckdml0o0>" %}

## Start Actions

Add the **`StartActions`** class to your object, and drag the object itself into the list. Any `IHaveStartActions` class (`Monobehaviour` or otherwise) can be added to this list. When the object is created, or when the gameplay starts, the `StartActions()` method will be automatically called by the `StartActions` class on each of the objects in the list.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FVQQtjmSPWOBSN3Nr6kvc%2FScreenshot%202023-07-24%20at%202.32.36%20PM.png?alt=media&amp;token=0babce4f-dae3-4dbb-8e4d-eb35593465a8" alt=""><figcaption><p>The component has recently been updated, after the video below was made. It now will automatically cache the <code>IHaveStartActions</code> classes which it can find on the object it is attached to, whenever you view it in the Inspector.</p></figcaption></figure>

{% embed url="<https://www.youtube.com/watch?v=rUqsjeun1Xc>" %}

## Starting Stats

**Game Modules 4** comes with a new **`StartingStats`** component. Add this to the object which holds your `GameModulesActor`, or any other field that implements `IHaveStats`.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FVGKMWq8U1Bxqrd84H2uW%2FScreenshot%202023-07-24%20at%202.32.40%20PM.png?alt=media&amp;token=06bc7e7a-6fa5-4fa5-9486-f2ab37033e4e" alt=""><figcaption></figcaption></figure>

Choose [**Stats**](/magic-pig-games/game-modules-4/module-documentation/stats-and-skills.md) you wish to add when the game starts. If the **Stat** already exists, nothing will happen (to avoid overwriting existing data).

This is a convenient way to specify the starting values for an `actor`.

{% hint style="success" %}
The component will automatically cache the fields at edit time, minimizing the resources required at runtime. Simply adding the component or viewing it in the Inspector will trigger the script to find `IHaveStats` classes.
{% endhint %}

## Important Methods

Most of the Game Module actions are automatic, and already set up if you inherit from `GameModulesActor`. However, you should still run these to methods from your Actor class or monobehaviour.

{% hint style="info" %}
In the **Party Based RPG demo game**, the `DemoActor` class inherits from `GameModulesInventoryActor`, but is not a monobehaviour.&#x20;

Instead, the `GameData` class, which has a `List<DemoActor>` which holds the four players, is a monobehaviour, and calls the `Tick()` and `StartActions()` methods.
{% endhint %}

### `Tick()` and `LateTick()`

{% hint style="success" %}
In 4.0.3, this has been automated. The `GameModulesActor` will automatically register itself with the `ModulesHelper` if it has [**Quests**](/magic-pig-games/game-modules-4/module-documentation/quests.md), or when a Quest is added. `ModulesHelper` will now call `Tick()`, so you no longer have to remember this!
{% endhint %}

{% hint style="success" %}
There are many helpful methods on these classes. Please read the scripts to familiarize yourself with them. The scripts are well documented.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/game-modules-actor.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
