Grandchildren
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 istrue
.
Returns
- Return Type:
IEnumerable<Actor>
. This method returns a collection ofActor
objects, each representing a grandchild of the actor. - When
inclusivePassive
is set totrue
, the collection includes all grandchildren, regardless of their state (alive or dead). - When
inclusivePassive
is set tofalse
, 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:
IEnumerable<Actor> allGrandchildren = someActor.Grandchildren();
IEnumerable<Actor> 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.