Parents

From Intrigues Wiki
Revision as of 14:41, 19 December 2023 by Tayfunwiki (talk | contribs) (Created page with "== <code>Parents</code> Method in Actor Class == === Overview === The <code>Parents</code> method in the <code>Actor</code> class is used to retrieve the parents of an actor. It allows for the inclusion or exclusion of deceased parents based on the specified parameter. === Syntax === <syntaxhighlight lang="c#"> public IEnumerable<Actor> Parents(bool inclusivePassive = true) </syntaxhighlight> === Parameters === * <code>inclusivePassive</code> (bool): A flag indicatin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Parents Method in Actor Class

Overview

The Parents method in the Actor class is used to retrieve the parents of an actor. It allows for the inclusion or exclusion of deceased parents based on the specified parameter.

Syntax

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

Parameters

  • inclusivePassive (bool): A flag indicating whether to include deceased (passive state) parents in the returned collection. It defaults to true.

Returns

  • Return Type: IEnumerable<Actor>. The method returns a collection of Actor objects representing the parents of the specified actor.
  • When inclusivePassive is true, it includes all parents regardless of their state (alive or dead).
  • When inclusivePassive is false, it only includes parents who are in an active (alive) state.

Description

The Parents method is designed to provide access to the actor's parental figures. The method's behavior can be controlled through the inclusivePassive parameter, allowing users to specify whether they want to include parents who have passed away (Passive state) in the collection.

Usage

This method is particularly useful in scenarios where the actor's familial background, including the state of their parents (alive or dead), plays a role in the gameplay or narrative.

Example:

IEnumerable<Actor> livingParents = someActor.Parents(false);
IEnumerable<Actor> allParents = someActor.Parents();

In these examples, livingParents will contain only living parents of the actor, while allParents will include both living and deceased parents.

Remarks

  • The method leverages LINQ (.Where(p => p.State == IState.Active)) for filtering active parents when inclusivePassive is false.
  • The ability to include or exclude deceased parents provides flexibility in how parental relationships are handled within the game's logic or story.
  • The method is a part of handling complex family trees and relationships within the game, enhancing the depth and realism of character interactions and narratives.