Grandparents
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 istrue
.
Returns
- Return Type:
IEnumerable<Actor>
. The method returns a collection ofActor
objects, each representing a grandparent of the actor. - When
inclusivePassive
is set totrue
, the collection includes all grandparents, alive or deceased. - When
inclusivePassive
is set tofalse
, 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.