Children
Children Method in Actor Class
Overview
The Children method in the Actor class is designed to retrieve the children of an actor. It offers the flexibility to include or exclude deceased children based on a specified parameter.
Syntax
public IEnumerable<Actor> Children(bool inclusivePassive = true)
Parameters
inclusivePassive(bool): A boolean flag that determines whether deceased (passive state) children should be included in the returned collection. It defaults totrue.
Returns
- Return Type:
IEnumerable<Actor>. This method returns a collection ofActorobjects representing the children of the actor. - If
inclusivePassiveistrue, both living and deceased children are included. - If
inclusivePassiveisfalse, only living (active state) children are included.
Description
The Children method is essential for accessing the children of an actor, with an option to consider the state (alive or dead) of these children. The inclusion of deceased children is controlled by the inclusivePassive parameter.
Usage
This method is useful in game mechanics or narratives where an actor's relationship with their children, including those who may have passed away, is important.
Example:
var allChildren = someActor.Children();
var livingChildren = someActor.Children(false);
In the first example, allChildren will contain all the children of the actor, regardless of their state. In the second example, livingChildren will only include the living children of the actor.
Remarks
- This flexibility in handling children based on their state allows for nuanced storytelling and gameplay, especially in scenarios involving family dynamics and inheritance.
- The
Childrenmethod plays a vital role in managing familial relationships and lineage within the game.