OnConspiratorChanged

From Intrigues Wiki
Revision as of 18:36, 4 January 2024 by Tayfunwiki (talk | contribs) (Created page with "== <code>onConspiratorChanged</code> Event in Scheme Class == === Overview === The <code>onConspiratorChanged</code> event in the Scheme class is triggered when the conspirator of a scheme is changed. This event provides a way to respond dynamically to changes in the scheme's initiator within the game. === Event Definition === <syntaxhighlight lang="c#"> public static event Action<Scheme, Actor> onConspiratorChanged; </syntaxhighlight> === Description === * Parameter...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

onConspiratorChanged Event in Scheme Class

Overview

The onConspiratorChanged event in the Scheme class is triggered when the conspirator of a scheme is changed. This event provides a way to respond dynamically to changes in the scheme's initiator within the game.

Event Definition

public static event Action<Scheme, Actor> onConspiratorChanged;

Description

  • Parameters:
    • Scheme: The scheme for which the conspirator has changed.
    • Actor: The new conspirator actor of the scheme.
  • Type: Action<Scheme, Actor> - A delegate type representing the method signature for the event handlers.
  • Visibility: Public.

Functionality

  • The event is designed to notify other parts of the game when the conspirator of a particular scheme changes, allowing for updates in UI, game logic, or other relevant systems.
  • It facilitates the tracking and management of dynamic changes in schemes, particularly in games where schemes play a crucial role in the narrative or gameplay.

Usage

This event is useful for updating UI elements that display information about schemes, handling changes in game logic related to the scheme's initiator, or triggering specific actions when the conspirator of a scheme changes.

Example of Usage

public class SchemeListener : MonoBehaviour {
    void OnEnable() {
        Scheme.onConspiratorChanged += HandleConspiratorChange;
    }

    void OnDisable() {
        Scheme.onConspiratorChanged -= HandleConspiratorChange;
    }

    private void HandleConspiratorChange(Scheme scheme, Actor newConspirator) {
        Debug.Log($"Conspirator of scheme '{scheme.SchemeName}' changed to: {newConspirator.Name}");
    }
}

Description

  • This example demonstrates subscribing to the onConspiratorChanged event to log a message whenever the conspirator of any scheme changes.
  • The HandleConspiratorChange method is called whenever the event is triggered, providing information about the scheme and the new conspirator.

Remarks

  • The onConspiratorChanged event is an important tool for maintaining game integrity and consistency, especially in games with complex character interactions and decision-making processes.
  • Proper handling of this event can enhance the player's understanding of the evolving narrative and strategic elements within the game.
  • Event handlers for onConspiratorChanged should be carefully managed to avoid memory leaks or unintended behavior, especially when subscribing and unsubscribing from the event.