# Game Modules Actor

**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="/files/45sdD9YllO1JcZ8v9L5L" 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="/files/aj63L5g8YNlWlh6woWRt" 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: 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://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/game-modules-actor.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.
