Variables

From Intrigues Wiki

Variables Property in Actor Class

Overview

The Variables property in the Actor class is a collection that stores private variables associated with the actor. This property plays a key role in managing dynamic data specific to each actor within the game.

Syntax

[SerializeReference] public List<NVar> Variables = new List<NVar>();

Description

  • Property Type: List<NVar>. The Variables property is a list of NVar objects. NVar is assumed to be a custom class or structure designed to hold variable data.
  • Attribute: [SerializeReference]. This attribute indicates that the elements in the list are serialized by Unity, allowing them to be edited in the Unity Editor and preserved across game sessions.
  • Purpose: The Variables property is designed to store customizable and actor-specific data such as stats, state flags, or other dynamic information. This flexibility is crucial for games where actors require individualized data that can change over time or based on game events.

Usage

This property is used to store and access a wide range of data points specific to each actor. It can be utilized for gameplay mechanics, character progression, tracking states, and more.

Example:

NVar healthVariable = someActor.Variables.Find(var => var.Name == "Health");
if (healthVariable != null && healthVariable.Value < 50) {
    // Execute logic for low health
}

In this example, the actor's health variable is accessed from the Variables list. The game logic is then executed based on the condition of the actor's health.

Remarks

  • The use of a generic list (List<NVar>) provides flexibility in storing various types of data.
  • The [SerializeReference] attribute ensures that variable data is serialized by Unity, which is important for maintaining consistency and persistence of actor-specific data across game sessions.
  • The Variables property is essential in complex games where each actor needs to maintain a set of dynamic and individualized data points, influencing their behavior, abilities, and interactions within the game world.