Grandchildren: Difference between revisions

From Intrigues Wiki
(Created page with "== <code>Grandchildren</code> Method in Actor Class == === Overview === The <code>Grandchildren</code> method in the <code>Actor</code> class is designed to retrieve the grandchildren of an actor. It offers the option to include or exclude deceased grandchildren based on a specified parameter. === Syntax === <syntaxhighlight lang="c#"> public IEnumerable<Actor> Grandchildren(bool inclusivePassive = true) </syntaxhighlight> === Parameters === * <code>inclusivePassive<...")
 
No edit summary
 
Line 27: Line 27:
==== Example: ====
==== Example: ====
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
IEnumerable<Actor> allGrandchildren = someActor.Grandchildren();
var allGrandchildren = someActor.Grandchildren();
IEnumerable<Actor> livingGrandchildren = someActor.Grandchildren(false);
var livingGrandchildren = someActor.Grandchildren(false);
</syntaxhighlight>In the first example, <code>allGrandchildren</code> includes both living and deceased grandchildren, while <code>livingGrandchildren</code> includes only the living ones.
</syntaxhighlight>In the first example, <code>allGrandchildren</code> includes both living and deceased grandchildren, while <code>livingGrandchildren</code> includes only the living ones.



Latest revision as of 13:43, 21 December 2023

Grandchildren Method in Actor Class

Overview

The Grandchildren method in the Actor class is designed to retrieve the grandchildren of an actor. It offers the option to include or exclude deceased grandchildren based on a specified parameter.

Syntax

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

Parameters

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

Returns

  • Return Type: IEnumerable<Actor>. This method returns a collection of Actor objects, each representing a grandchild of the actor.
  • When inclusivePassive is set to true, the collection includes all grandchildren, regardless of their state (alive or dead).
  • When inclusivePassive is set to false, it only includes living (active state) grandchildren.

Description

The Grandchildren method provides a means to access the actor's grandchildren, allowing for inclusion of those who have passed away, depending on the inclusivePassive parameter. The method uses LINQ's SelectMany function to collate grandchildren from the actor's children, ensuring a comprehensive collection.

Usage

This method is particularly useful in game mechanics or narratives where an actor's relationship with their grandchildren, including those who may have passed away, is significant.

Example:

var allGrandchildren = someActor.Grandchildren();
var livingGrandchildren = someActor.Grandchildren(false);

In the first example, allGrandchildren includes both living and deceased grandchildren, while livingGrandchildren includes only the living ones.

Remarks

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