OnClanNameChanged
onClanNameChanged
Event in Clan Class
Overview
The onClanNameChanged
event in the Clan class is triggered when the name of the clan is altered. This event is crucial for monitoring and responding to changes in the identity and representation of the clan within the game.
Event Definition
public event Action<string> onClanNameChanged;
Description
- Delegate Type:
Action<string>
- Purpose: Notifies when the clan's name has been changed.
- Parameters:
string
: The old name of the clan.
Functionality
- The
onClanNameChanged
event is raised when there is a modification to the clan's name. - It provides the updated name of the clan as a parameter.
- This event allows various aspects of the game, such as UI elements, narrative scripts, or clan-based mechanics, to update accordingly to reflect the change in the clan's name.
Usage
This event is generally used to implement real-time updates in the game when a clan undergoes a name change. It ensures that the game accurately reflects the current state and identity of the clan across all relevant elements.
Example of Usage
public class ClanNameChangeHandler : MonoBehaviour {
void Start() {
Clan playerClan = IM.Player.Clan;
if (playerClan != null) {
playerClan.onClanNameChanged += HandleClanNameChange;
}
}
private void HandleClanNameChange(string oldName) {
Debug.Log($"The player's clan name has been changed to: {IM.Player.Clan.ClanName}, Old Name: {oldName}");
}
void OnDestroy() {
if (IM.Player.Clan != null) {
IM.Player.Clan.onClanNameChanged -= HandleClanNameChange;
}
}
}
Description
- This example demonstrates how to subscribe to the
onClanNameChanged
event for the player's clan. - It also ensures to unsubscribe from the event upon the destruction of the GameObject to prevent memory leaks or unintended behavior.
Remarks
- The
onClanNameChanged
event is essential for maintaining consistency and accuracy in the portrayal of the clan throughout the game. - It plays a significant role in games where clan identity is pivotal to the gameplay experience or narrative.