OnLeftFamily

From Intrigues Wiki

onLeftFamily Event in Actor Class

Overview

The onLeftFamily event in the Actor class is triggered when an actor leaves a family. This event is of significant importance in games where family ties and relationships play a crucial role in shaping character interactions, gameplay dynamics, and narrative development.

Description

  • Event Type: Action<Family>
  • Functionality: This event fires when the actor exits a family. The event handler receives a Family object representing the family that the actor has left. This provides an opportunity to execute specific actions or logic in response to this change in family affiliation.

Usage

The event is used to implement responses or updates within the game when an actor's family relationship changes. This could include modifying the actor's role or interactions, changing narrative elements, or adjusting gameplay mechanics to align with the actor's new status outside the family.

Subscribing to the Event

To effectively respond to the onLeftFamily event, subscribe a method with the signature Action<Family> within a MonoBehaviour script. It is important to unsubscribe from the event appropriately, especially when the actor is destroyed or the family context changes.

Example of Usage

public class FamilyLeaveHandler : MonoBehaviour {
    public Actor actor;

    void Start() {
        if (actor != null) {
            actor.onLeftFamily += OnLeftFamily;
        }
    }

    private void OnLeftFamily(Family oldFamily) {
        Debug.Log($"{actor.FullName} has left the family: {oldFamily.FamilyName}.");
        // Logic to respond to the actor's departure from the family
    }

    void OnDestroy() {
        if (actor != null) {
            actor.onLeftFamily -= OnLeftFamily;
        }
    }
}

In this example, the FamilyLeaveHandler script is attached to a GameObject in Unity and subscribes to the onLeftFamily event of an Actor. When the actor leaves a family, the OnLeftFamily method is invoked, allowing the game to adapt to the actor's change in family status.

Remarks

  • The onLeftFamily event is crucial for games that feature intricate family dynamics, enabling the game to reflect changes in familial relationships dynamically.
  • Properly managing this event can significantly enhance the narrative and gameplay experience by providing a responsive environment that adapts to changes in character relationships.
  • This event is particularly relevant in role-playing games, simulation games, and other titles where family dynamics are integral to the game's structure and character development.