Trigger

From Intrigues Wiki
Revision as of 08:08, 24 December 2023 by Tayfunwiki (talk | contribs) (Created page with "== <code>Trigger</code> Method in Actor Class == === Overview === The <code>Trigger</code> method is used to send a specific trigger to the actor. This function is crucial in games with event-driven mechanics, where triggers can initiate or influence various actions or events related to an actor. === Syntax === <syntaxhighlight lang="c#"> public void Trigger(string triggerName, bool value) </syntaxhighlight> === Parameters === * triggerName (string): The name of the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Trigger Method in Actor Class

Overview

The Trigger method is used to send a specific trigger to the actor. This function is crucial in games with event-driven mechanics, where triggers can initiate or influence various actions or events related to an actor.

Syntax

public void Trigger(string triggerName, bool value)

Parameters

  • triggerName (string): The name of the trigger to send.
  • value (bool): The value to be passed with the trigger, often representing the state or condition associated with the trigger.

Description

This method sends a trigger, identified by triggerName, to the actor, along with a boolean value value. The method's functionality is often linked to event listeners or handlers, such as a WaitTrigger node, which wait for specific triggers to perform subsequent actions. The trigger mechanism is essential in creating responsive and interactive game environments.

Usage

Used to activate specific events, actions, or changes in state for an actor. It's particularly relevant in gameplay scenarios where conditional actions are based on the occurrence of certain events or states.

Example of Usage

public Actor guard;
string triggerName = "Alert";

// Sending an 'Alert' trigger to the guard with a value of true
guard.Trigger(triggerName, true);
// This could signal the guard to initiate alert-related behaviors or actions

In this example, an 'Alert' trigger is sent to a guard character. The trigger could activate alert-related behaviors, such as changing the guard's state to a heightened level of awareness or initiating a search sequence.

Remarks

  • The Trigger method enables dynamic and responsive game mechanics, allowing for real-time interactions based on actor-specific triggers.
  • This method is vital in games with complex event handling systems where actors' behaviors and responses are contingent upon various triggers and conditions.
  • The ability to pass a boolean value with the trigger adds flexibility, enabling triggers to convey more nuanced information about the event or condition being communicated.