VTI Targets: Difference between revisions

From WaffleSlapper's Project Wiki
(Initial setup save.)
 
(More fleshing out of VTITarget.)
Line 4: Line 4:


The VTITarget component is one of the core scripts for the [[VTI World Kit]]. It is used to identify a GameObject as something that can be interacted with  by Twitch viewers when running [[VRChat Twitch Integration]].
The VTITarget component is one of the core scripts for the [[VTI World Kit]]. It is used to identify a GameObject as something that can be interacted with  by Twitch viewers when running [[VRChat Twitch Integration]].
== Event Firing ==
When the [[VTI Event Handler]] receives an [[VTI Events|Event]] from the [[VTI Companion App]], it will enqueue it under the ID of the triggered Target. Once that Event is at the top of the Queue, the Event Handler will attempt to dispatch the Event data to the Target and then call <syntaxhighlight lang="csharp" inline>VTIFire()</syntaxhighlight>.
Once Fired, the VTITarget will forward the Event data to each [[VTI Drivers|Driver]] component within the same GameObject as the VTITarget component, and then call <syntaxhighlight lang="csharp" inline>VTIEventPlay()</syntaxhighlight> on each Driver.
=== Readiness Validation ===
Before firing, the [[VTI Event Handler]] will call <syntaxhighlight lang="csharp" inline>VTICheckCanFire()</syntaxhighlight> against the queued VTITarget. This will first check the current time against the Cooldown property, and then will loop through all attached [[VTI Drivers|Driver]] component and call <syntaxhighlight lang="csharp" inline>VTICheckReady()</syntaxhighlight> on each. If any Driver returns <syntaxhighlight lang="csharp" inline>false</syntaxhighlight>, or the Cooldown has not yet elapsed, the Event is skipped and the process repeats for the next in line.


== Properties ==
== Properties ==
{| class="wikitable"
{| class="wikitable"
|+ VTITarget
|+ Properties
|-
|-
! Property !! Usage
! Property !! Usage
Line 17: Line 25:
| Description || A short sentence describing the usage of this Target. Used in the [[VTI Companion App]]'s Target editor and when generating Channel Point Rewards.
| Description || A short sentence describing the usage of this Target. Used in the [[VTI Companion App]]'s Target editor and when generating Channel Point Rewards.
|-
|-
| Cooldown || The number of seconds to wait before this Target can be fired again. Set this to at least as long as the events run by any attached [[VTI Driver|VTI Drivers]] unless they are capable of being interrupted or overlapped.
| Cooldown || The number of seconds to wait before this Target can be fired again. Set this to at least as long as the events run by any attached [[VTI Drivers]] unless they are capable of being interrupted or overlapped.
|-
|-
| Allow Message Input || Enable this when any attached [[VTI Driver|VTI Drivers]] expect User Messaging in order to function.
| Allow Message Input || Enable this when any attached [[VTI Drivers]] expect User Messaging in order to function.
|-
|-
| Allow Event Type Rebinding || If any attached [[VTI Driver|VTI Drivers]] are specifically tailored to one specific event, disable this. For example: a Driver that expects a chat command with a specific argument will likely not work when set to SUBCRIBE_GIFT.
| Allow Event Type Rebinding || If any attached [[VTI Drivers]] are specifically tailored to one specific event, disable this. For example: a Driver that expects a chat command with a specific argument will likely not work when set to SUBCRIBE_GIFT.
|-
|-
| Default Event Type || What Twitch Event this Target should be fired on. This presents as a dropdown for all [https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types EventSub Subscription Types] currently supported by [[VRChat Twitch Integration|VTI]].
| Default Event Type || What Twitch Event this Target should be fired on. This presents as a dropdown for all [https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types EventSub Subscription Types] currently supported by [[VRChat Twitch Integration|VTI]].
|-
|-
| Default Twitch Binding Settings || This section is dynamically displayed based on which Event Type is selected. Use this area to tune exactly what parameters are required to fire this Target.  
| Default Twitch Binding Settings || This section is dynamically displayed based on which Event Type is selected. Use this area to tune exactly what parameters are required to fire this Target.  
|}
== Methods ==
{| class="wikitable"
|+ Methods
|-
! Method !! Return !! Usage
|-
| VTICheckCanFire() || bool || Check whether or not this Target is off cooldown and all attached [[VTI Drivers|Drivers]] are reporting Ready.
|-
| VTIFire() || void || Trigger this Target. Forwards [[VTI Events|Event]] data to all attached [[VTI Drivers|Drivers]] and calls <syntaxhighlight lang="csharp" inline>Driver.VTIEventPlay()</syntaxhighlight> on each.
|}
|}

Revision as of 06:27, 13 February 2024


VTITarget's Inspector

The VTITarget component is one of the core scripts for the VTI World Kit. It is used to identify a GameObject as something that can be interacted with by Twitch viewers when running VRChat Twitch Integration (For Worlds!).

Event Firing

When the VTI Event Handler receives an Event from the VTI Companion App, it will enqueue it under the ID of the triggered Target. Once that Event is at the top of the Queue, the Event Handler will attempt to dispatch the Event data to the Target and then call VTIFire().

Once Fired, the VTITarget will forward the Event data to each Driver component within the same GameObject as the VTITarget component, and then call VTIEventPlay() on each Driver.

Readiness Validation

Before firing, the VTI Event Handler will call VTICheckCanFire() against the queued VTITarget. This will first check the current time against the Cooldown property, and then will loop through all attached Driver component and call VTICheckReady() on each. If any Driver returns false, or the Cooldown has not yet elapsed, the Event is skipped and the process repeats for the next in line.

Properties

Properties
Property Usage
ID The Unique Identifier for this Target. Used internally to dispatch Events. Must not match any other VTITargets in the scene or a warning will be thrown.
Display Name The User-Friendly name for this Target. Used in the VTI Companion App's Target editor and when generating Channel Point Rewards. Does not need to be unique.
Description A short sentence describing the usage of this Target. Used in the VTI Companion App's Target editor and when generating Channel Point Rewards.
Cooldown The number of seconds to wait before this Target can be fired again. Set this to at least as long as the events run by any attached VTI Drivers unless they are capable of being interrupted or overlapped.
Allow Message Input Enable this when any attached VTI Drivers expect User Messaging in order to function.
Allow Event Type Rebinding If any attached VTI Drivers are specifically tailored to one specific event, disable this. For example: a Driver that expects a chat command with a specific argument will likely not work when set to SUBCRIBE_GIFT.
Default Event Type What Twitch Event this Target should be fired on. This presents as a dropdown for all EventSub Subscription Types currently supported by VTI.
Default Twitch Binding Settings This section is dynamically displayed based on which Event Type is selected. Use this area to tune exactly what parameters are required to fire this Target.

Methods

Methods
Method Return Usage
VTICheckCanFire() bool Check whether or not this Target is off cooldown and all attached Drivers are reporting Ready.
VTIFire() void Trigger this Target. Forwards Event data to all attached Drivers and calls Driver.VTIEventPlay() on each.