OnMemberJoin

From Intrigues Wiki

onMemberJoin Event in Clan Class

Overview

The onMemberJoin event in the Clan class is triggered when a new member joins the clan. This event is crucial for recognizing and responding to changes in the clan's membership within the game's world.

Event Definition

public Action<Actor> onMemberJoin;

Description

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

Functionality

  • The onMemberJoin event is raised when an actor becomes a member of the clan.
  • It provides the Actor object representing the new member.
  • This event allows for updating game elements such as clan rosters, member lists, or triggering specific gameplay mechanics or narrative elements associated with the clan's expansion.

Usage

This event is typically used to handle updates or actions within the game when the clan's membership increases. It can be instrumental in scenarios involving resource allocation, social dynamics, or questlines that are dependent on clan size.

Example of Usage

public class ClanMembershipHandler : MonoBehaviour {
    void Start() {
        Clan playerClan = IM.Player.Clan;
        if (playerClan != null) {
            playerClan.onMemberJoin += HandleNewMemberJoining;
        }
    }

    private void HandleNewMemberJoining(Actor newMember) {
        Debug.Log($"New member joined the player's clan: {newMember.Name}");
    }

    void OnDestroy() {
        if (IM.Player.Clan != null) {
            IM.Player.Clan.onMemberJoin -= HandleNewMemberJoining;
        }
    }
}

Description

  • This example demonstrates subscribing to the onMemberJoin event for the player's clan.
  • When a new member joins the clan, the HandleNewMemberJoining method is called, logging the new member's name.
  • It ensures to unsubscribe from the event when the GameObject is destroyed to prevent unintended behavior.

Remarks

  • The onMemberJoin event is essential for dynamically managing the clan's composition and responding to its growth.
  • It provides an opportunity for developers to create gameplay and narrative elements that evolve with the clan's changing demographics.
  • Effectively handling this event is key to maintaining a realistic and engaging clan dynamic within the game.