OnJoinedClan

From Intrigues Wiki
Revision as of 15:55, 24 December 2023 by Tayfunwiki (talk | contribs) (Created page with "== <code>onJoinedClan</code> Event in Actor Class == === Overview === The <code>onJoinedClan</code> event within the <code>Actor</code> class is triggered when the actor joins a clan. This event is fundamental in games where clan affiliations influence character dynamics, gameplay mechanics, or the unfolding of the narrative. === Description === * Event Type: <code>Action<Clan></code> * Functionality: Activated when the actor becomes a member of a clan. The event hand...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

onJoinedClan Event in Actor Class

Overview

The onJoinedClan event within the Actor class is triggered when the actor joins a clan. This event is fundamental in games where clan affiliations influence character dynamics, gameplay mechanics, or the unfolding of the narrative.

Description

  • Event Type: Action<Clan>
  • Functionality: Activated when the actor becomes a member of a clan. The event handler receives the Clan object representing the clan joined. It enables the implementation of specific reactions or updates in response to the actor's new clan affiliation.

Usage

The event is used to trigger custom actions or updates within the game when an actor joins a clan. This can involve adjusting the actor's interactions, abilities, or role within the game to reflect their new clan membership.

Subscribing to the Event

To handle the onJoinedClan event effectively, a method with the corresponding signature (Action<Clan>) should be subscribed to it within a MonoBehaviour script. Unsubscribing from the event is important when the actor is destroyed or when clan-related logic is no longer applicable.

Example of Usage

public class ClanJoinHandler : MonoBehaviour {
    public Actor actor;

    void Start() {
        if (actor != null) {
            actor.onJoinedClan += OnJoinedClan;
        }
    }

    private void OnJoinedClan(Clan newClan) {
        Debug.Log($"{actor.FullName} has joined the clan: {newClan.ClanName}.");
        // Implement logic to respond to the actor joining a new clan
    }

    void OnDestroy() {
        if (actor != null) {
            actor.onJoinedClan -= OnJoinedClan;
        }
    }
}

In this example, the ClanJoinHandler script, attached to a GameObject, subscribes to the onJoinedClan event of an Actor. When the actor joins a new clan, the OnJoinedClan method logs this event and allows for additional logic to adapt to the actor's new clan affiliation.

Remarks

  • The onJoinedClan event is crucial in games where clan dynamics significantly impact the gameplay, offering a structured approach to manage clan-related character changes.
  • Handling this event effectively can enrich the narrative and gameplay experience, providing a more immersive and contextually responsive environment.
  • This event is especially relevant in strategy games, role-playing games, and other titles where clans or similar group affiliations play a pivotal role in the game's structure and character interactions.