Parents: Difference between revisions

From Intrigues Wiki
(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...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 27: Line 27:
==== Example: ====
==== Example: ====
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
IEnumerable<Actor> livingParents = someActor.Parents(false);
var livingParents = someActor.Parents(false);
IEnumerable<Actor> allParents = someActor.Parents();
var allParents = someActor.Parents();
</syntaxhighlight>In these examples, <code>livingParents</code> will contain only living parents of the actor, while <code>allParents</code> will include both living and deceased parents.
</syntaxhighlight>In these examples, <code>livingParents</code> will contain only living parents of the actor, while <code>allParents</code> will include both living and deceased parents.


=== Remarks ===
=== Remarks ===


* The method leverages LINQ (<code>.Where(p => p.State == IState.Active)</code>) for filtering active parents when <code>inclusivePassive</code> is <code>false</code>.
* The ability to include or exclude deceased parents provides flexibility in how parental relationships are handled within the game's logic or story.
* 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.
* 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.

Latest revision as of 00:55, 20 December 2023

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:

var livingParents = someActor.Parents(false);
var 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 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.