OnMemberLeave

From Intrigues Wiki

onMemberLeave Event in Clan Class

Overview

The onMemberLeave event in the Clan class is activated when a member leaves the clan. This event is crucial for acknowledging and responding to changes in the clan's composition within the game's world.

Event Definition

public event Action<Actor> onMemberLeave;

Description

  • Delegate Type: Action<Actor>
  • Purpose: Notifies when a member leaves the clan.
  • Parameters:
    • Actor: The actor who has left the clan.

Functionality

  • The onMemberLeave event is raised whenever an actor ceases to be a member of the clan.
  • It provides the Actor object representing the departing member.
  • This event allows for updating game elements such as clan rosters, adjusting clan resources, or triggering specific gameplay mechanics or narrative elements associated with the change in the clan's size.

Usage

This event is typically used to handle updates or actions within the game when the clan's membership decreases. It can influence gameplay in areas such as clan dynamics, resource management, or storylines that involve clan loyalty and membership.

Example of Usage

public class ClanDepartureHandler : MonoBehaviour {
    void Start() {
        Clan playerClan = IM.Player.Clan;
        if (playerClan != null) {
            playerClan.onMemberLeave += HandleMemberLeaving;
        }
    }

    private void HandleMemberLeaving(Actor departingMember) {
        Debug.Log($"Member left the player's clan: {departingMember.Name}");
    }

    void OnDestroy() {
        if (IM.Player.Clan != null) {
            playerClan.onMemberLeave -= HandleMemberLeaving;
        }
    }
}

Description

  • This example shows how to subscribe to the onMemberLeave event for the player's clan.
  • When a member leaves the clan, the HandleMemberLeaving method is invoked, logging the name of the departing member.
  • It also ensures to unsubscribe from the event upon the destruction of the GameObject to prevent memory leaks or unintended behavior.

Remarks

  • The onMemberLeave event is vital for dynamically managing the clan's composition and responding to its reduction.
  • It offers a mechanism for developers to create gameplay and narrative elements that adjust to the clan's changing demographics.
  • Effective handling of this event is key to maintaining a realistic and engaging clan dynamic within the game.