Grandparents

From Intrigues Wiki
Revision as of 13:43, 21 December 2023 by Tayfunwiki (talk | contribs) (Created page with "== <code>Grandparents</code> Method in Actor Class == === Overview === The <code>Grandparents</code> method in the <code>Actor</code> class retrieves the grandparents of an actor. It allows for the inclusion or exclusion of deceased grandparents based on the provided parameter. === Syntax === <syntaxhighlight lang="c#"> public IEnumerable<Actor> Grandparents(bool inclusivePassive = true) </syntaxhighlight> === Parameters === * <code>inclusivePassive</code> (bool): A...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Grandparents Method in Actor Class

Overview

The Grandparents method in the Actor class retrieves the grandparents of an actor. It allows for the inclusion or exclusion of deceased grandparents based on the provided parameter.

Syntax

public IEnumerable<Actor> Grandparents(bool inclusivePassive = true)

Parameters

  • inclusivePassive (bool): A flag that determines whether to include deceased (passive state) grandparents in the returned collection. The default value is true.

Returns

  • Return Type: IEnumerable<Actor>. The method returns a collection of Actor objects, each representing a grandparent of the actor.
  • When inclusivePassive is set to true, the collection includes all grandparents, alive or deceased.
  • When inclusivePassive is set to false, it includes only living (active state) grandparents.

Description

The Grandparents method provides a way to access the actor's grandparents, with an option to include those who have passed away. The method uses LINQ's SelectMany function to aggregate grandparents from the actor's parents, allowing for a comprehensive collection.

Usage

This method is useful in game scenarios where familial lineage and ancestry play a role, such as for inheritance, story development, or character background.

Example:

var allGrandparents = someActor.Grandparents();
var livingGrandparents = someActor.Grandparents(false);

In these examples, allGrandparents includes both living and deceased grandparents, while livingGrandparents includes only the living ones.

Remarks

  • The ability to include or exclude deceased grandparents provides depth to the handling of familial and relational dynamics within the game.
  • The Grandparents method is crucial for managing complex relationships and can significantly impact the storylines and character interactions in the game.