IM.OnTrigger: Difference between revisions

From Intrigues Wiki
(Created page with "== <code>onTrigger</code> Event in IM Class == === Overview === The <code>onTrigger</code> event in the IM (Intrigue Manager) class is designed to respond to specific conditions within the game, particularly those involving triggers activated by the TriggerNode. === Description === * Event Type: <code>Action<Scheme, string, bool></code> * Functionality: ** This event is triggered under certain conditions, and it carries along three parameters: a <code>Scheme</code> ob...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Trigger Node.gif|thumb|Trigger Node]]
== <code>onTrigger</code> Event in IM Class ==
== <code>onTrigger</code> Event in IM Class ==



Latest revision as of 14:37, 4 January 2024

Trigger Node

onTrigger Event in IM Class

Overview

The onTrigger event in the IM (Intrigue Manager) class is designed to respond to specific conditions within the game, particularly those involving triggers activated by the TriggerNode.

Description

  • Event Type: Action<Scheme, string, bool>
  • Functionality:
    • This event is triggered under certain conditions, and it carries along three parameters: a Scheme object, a string identifier, and a bool status.
    • It is configured to handle triggers that are activated specifically through the 'Scheme' input of a TriggerNode, offering a focused mechanism for responding to scheme-related events within the game.

Usage

The onTrigger event is crucial for capturing and handling trigger events that are set off via the 'Scheme' input of the TriggerNode. This allows for targeted responses to events directly tied to specific schemes, enhancing the interactivity and narrative depth of the game.

Note

  • TriggerNode Integration: The event is particularly attuned to listening for triggers that are activated through the 'Scheme' input of the TriggerNode. This enables the event to specifically handle triggers related to particular schemes, making it an essential tool for scheme-based gameplay mechanics and storytelling.

Example of Usage

public class SchemeTriggerHandler : MonoBehaviour {
    void OnEnable() {
        IM.onTrigger += HandleSchemeTrigger;
    }

    void OnDisable() {
        IM.onTrigger -= HandleSchemeTrigger;
    }

    private void HandleSchemeTrigger(Scheme scheme, string triggerId, bool status) {
        Debug.Log($"Scheme Trigger Activated: {triggerId}, Status: {status}, In Scheme: {scheme.SchemeName}");
        // Implement logic to respond to the scheme-specific trigger event
        // This could involve changing the course of the scheme, updating game states, or initiating new narrative paths
    }
}

Description:

  • HandleSchemeTrigger: This method, subscribed to the onTrigger event, is invoked when a trigger related to a specific scheme is activated. It processes the received information, allowing for responses tailored to the context of the scheme.

Remarks

  • The onTrigger event is a vital component for games that employ complex scheme systems, where triggers play a significant role in unfolding events and shaping the player's experience.
  • Proper implementation of this event handler enables developers to create dynamic and responsive gameplay, where player actions or environmental changes can have meaningful impacts on ongoing schemes.