Grandchildren

From Intrigues Wiki
Revision as of 14:43, 21 December 2023 by Tayfunwiki (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.