OnClanCultureChanged

From Intrigues Wiki

onClanCultureChanged Event in Clan Class

Overview

The onClanCultureChanged event in the Clan class is activated when there is a change in the clan's cultural background. This event is crucial for adapting to and reflecting changes in the clan's cultural identity within the game's world.

Event Definition

public event Action<Culture> onClanCultureChanged;

Description

  • Delegate Type: Action<Culture>
  • Purpose: Notifies when the clan's culture has been changed.
  • Parameters:
    • Culture: The previous culture of the clan before the change.

Functionality

  • The onClanCultureChanged event is raised when the clan adopts a new cultural background.
  • It provides the previous Culture object as a parameter, enabling a comparison between the old and new cultures.
  • This event allows various game elements, such as narrative scripts, clan behavior, and user interface, to respond dynamically to changes in the clan's culture.

Usage

This event is particularly useful in scenarios where the cultural identity of a clan influences gameplay mechanics, storylines, or player interactions. It can be used to trigger updates or actions that align with the clan's new cultural characteristics.

Example of Usage

public class ClanCultureChangeHandler : MonoBehaviour {
    void Start() {
        Clan playerClan = IM.Player.Clan;
        if (playerClan != null) {
            playerClan.onClanCultureChanged += HandleClanCultureChange;
        }
    }

    private void HandleClanCultureChange(Culture oldCulture) {
        Debug.Log($"The player's clan culture has changed from {oldCulture.CultureName}. New Culture: {IM.player.Clan.CultureName}");
    }

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

Description

  • This example shows subscribing to the onClanCultureChanged event for the player's clan.
  • When the clan's culture changes, the HandleClanCultureChange method is called, logging the old culture's name.
  • It also ensures to unsubscribe from the event upon the destruction of the GameObject to prevent memory leaks or unintended behavior.

Remarks

  • The onClanCultureChanged event is vital for maintaining narrative consistency and gameplay relevance when a clan undergoes cultural changes.
  • It provides a mechanism for developers to create dynamic gameplay and storytelling that adapts to the evolving cultural identities of clans.
  • Effective handling of this event is essential for enhancing the player's immersion and interaction with the game's social and cultural dynamics.