Line 186: |
Line 186: |
| | | |
| ===Extensibility=== | | ===Extensibility=== |
− | C# mods can use the <samp>StardewValley.Triggers.DataTriggers</samp> class to interact with data triggers. | + | C# mods can use the <samp>StardewValley.Triggers.TriggerActionManager</samp> class to interact with trigger actions. |
| | | |
| For example, you can add a new trigger type: | | For example, you can add a new trigger type: |
| <syntaxhighlight lang="js"> | | <syntaxhighlight lang="js"> |
− | // register custom hook type | + | // register custom trigger type |
− | DataTriggers.RegisterTrigger("Some.ModId_OnItemReceived");
| + | TriggerActionManager.RegisterTrigger("Some.ModId_OnItemReceived"); |
| | | |
− | // raise trigger as needed | + | // run actions for the custom trigger |
− | DataTriggers.Raise("Some.ModId_OnItemReceived");
| + | TriggerActionManager.Raise("Some.ModId_OnItemReceived"); |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
| Or you can add a new action handler: | | Or you can add a new action handler: |
| <syntaxhighlight lang="js"> | | <syntaxhighlight lang="js"> |
− | DataTriggers.RegisterAction("Some.ModId_PlaySound", this.PlaySound);
| + | TriggerActionManager.RegisterAction("Some.ModId_PlaySound", this.PlaySound); |
| | | |
| ... | | ... |
| | | |
− | /// <inheritdoc cref="DataTriggerActionDelegate" /> | + | /// <inheritdoc cref="TriggerActionDelegate" /> |
| public static bool PlaySound(string[] args, string trigger, TriggerActionData data) | | public static bool PlaySound(string[] args, string trigger, TriggerActionData data) |
| { | | { |
| // get args | | // get args |
| if (!ArgUtility.TryGet(args, 1, out string soundId, out string error, allowBlank: false)) | | if (!ArgUtility.TryGet(args, 1, out string soundId, out string error, allowBlank: false)) |
− | return DataTriggers.Helpers.LogActionError(args, trigger, data, error); | + | return TriggerActionManager.Helpers.LogActionError(args, trigger, data, error); |
| | | |
| // apply | | // apply |