CreateActor

From Intrigues Wiki
Revision as of 08:27, 24 December 2023 by Tayfunwiki (talk | contribs) (→‎Usage)

CreateActor Methods in RuntimeActor Class

Overview

The CreateActor methods in the RuntimeActor class are used to create new actors within the game. These methods are essential for dynamically introducing new characters, such as when a child is born or a new character enters the storyline.

Method 1: CreateActor with Out Parameters

Syntax

public static void CreateActor(string name, IState state, int age, Culture culture, IGender gender,
                               Sprite portrait, out RuntimeActor runtimeActor, out GameObject gameObj)

Parameters

  • name (string): The name of the new actor.
  • state (IState): The initial state of the new actor.
  • age (int): The age of the new actor.
  • culture (Culture): The cultural background of the new actor.
  • gender (IGender): The gender of the new actor.
  • portrait (Sprite): The sprite for the new actor's portrait.
  • runtimeActor (out RuntimeActor): Out parameter returning the created RuntimeActor instance.
  • gameObj (out GameObject): Out parameter returning the GameObject associated with the new actor.

Description

This method creates a new RuntimeActor and a corresponding GameObject. It initializes the actor with the specified name, state, age, culture, gender, and portrait. The method returns the created RuntimeActor and GameObject through out parameters.

Usage

Used to add new characters to the game with specific attributes. Essential for games where the population of characters needs to expand dynamically.

Method 2: CreateActor with Return Type

Syntax

public static RuntimeActor CreateActor(string name, IState state, int age, Culture culture, IGender gender,
                                        Sprite portrait)

Parameters

  • name, state, age, culture, gender, portrait: Same as Method 1.

Description

Similar to the first method, this variation creates a new RuntimeActor with the provided details. However, it directly returns the RuntimeActor instance without using out parameters.

Usage

Suitable for scenarios where only the RuntimeActor instance is needed, and the creation process is streamlined without the requirement of an associated GameObject.

Remarks

  • Both methods provide flexibility in character creation, supporting diverse and dynamic game worlds.
  • The inclusion of cultural background and gender in character creation adds depth to the character's identity and can influence gameplay and narrative.
  • These methods are particularly useful in RPGs, simulation games, and any narrative-driven game that requires the introduction of new characters with specific traits and representations.