DiceOpsPlugin

版本 v1.1.1·更新於 2025-11-13

Dependency plugin for easily subscribing to dice related events and easier parsing of dice results.

模組介紹 作者原文

Dice Operations Plugin

This unofficial TaleSpire mod allows users to create dice related plugins more easily. The plugin allows you to

subscrive to notification for various dice related events (both before and after the event), provides two virtual

methods that can be overriden to change dice results before they are displayed, and provides a helper function to

convert the convoluted dice results to a much more easily read format.

Install

Use R2ModMan or similar installer to install. Since this is a dependency plugin it will be installed automatically

when needed. The user does not need to install this plugin.

Usage

Dice Notifications

There are three functions for managing notifications:

`System.Guid AddNotification(EventCallbackDelegate)`

`void RemoveNotification(System.Guid subscrition))`

When a notification is added, a subscription guid is returned which can be used with the RemoveNotification methods

to unsubscribe from any notifications associated with the subscription guid.

The following events are available:

`LoadDiceInTrayCallback(DiceEvent diceEvent,RollId rollId,ref DiceRollDescriptor rollDescriptor,ref bool showResult)`

`SpawnDiceFromTrayCallback(DiceEvent diceEvent, RollId rollId, DiceRollDescriptor diceRollDescriptor, ref float3 pos, ref bool isGmRoll, ref bool showResult)`

`GatherDiceCallback(DiceEvent diceEvent, RollId rollId, ref Vector3 position)`

`RollDiceCallback(DiceEvent diceEvent, RollId rollId, ref float3 velocity)`

`ClearDiceCallback(DiceEvent diceEvent, RollId rollId)`

`DiceRollResultCallback(DiceEvent diceEvent, RollId rollId, ref Dice.RollResults rollResultData, ref ClientGuid sender)`

`DiceRollChatResultCallback(DiceEvent diceEvent, RollId rollId, ref RollResults diceResult, ref UIChatMessageManager.DiceResultsReference.ResultsOrigin origin, ref ClientGuid sender, ref bool hidden, UIChatMessageManager.IChatFocusable focus = null)`

It is possible to either provide the callback as a lambda expression or as a callback method:

AddNotification((RollDiceCallback)((DiceEvent diceEvent, RollId rollId, ref float3 velocity) => { LoggingPlugin.LogDebug("Event: "+diceEvent+", RollId: "+rollId+", Velocity: "+velocity); }));

or

AddNotification((RollDiceCallback)rollCallback);

public void rollCallback(DiceEvent diceEvent, RollId rollId, ref float3 velocity)

{

LoggingPlugin.LogDebug("Event: "+diceEvent+", RollId: "+rollId+", Velocity: "+velocity);

}

It should be noted that notification will trigger with a before and after event. Use the diceEvenet parameter to identify which event the callback is associated with.

DiceEvents is an enumeration of the following events:

DiceEvents.beforeLoadDiceInTray

DiceEvents.afterLoadDiceInTray

DiceEvents.beforeSpawnDiceFromTray

DiceEvents.afterSpawnDiceFromTray

DiceEvents.beforeGatherDice

DiceEvents.afterGatherDice

DiceEvents.beforeRollDice

DiceEvents.afterRollDice

DiceEvents.beforeDiceRollResult

DiceEvents.afterDiceRollResult

DiceEvents.beforeDiceRollChatResult

DiceEvents.afterDiceRollChatResult

DiceEvents.beforeClearDice

DiceEvents.afterClearDice

Each callback has different parameters that it provies but all callbacks have DiceEvent and RollId as the first two parameters.

Dice Methods

Dice operations can be do using the provided IEnumerator methods. The following methods are available:

`IEnumerator SpawnTrayDice(float delay)`

`IEnumerator GatherDice(RollId rollId, Vector3 pos, float delay)`

`IEnumerator RollDice(RollId rollId, float delay)`

`IEnumerator ClearDice(RollId rollId, float delay)`

Where rollId is usually obtaine from one of the notifications (excluding either of the LoadDiceInTray which always some back with a default roll id).

These functions are intended to be run as Coroutines and thus something like:

`_self.StartCoroutine(DiceOpsPlugin.SpawnTrayDice(0.5f));`

Result Modification

Many of the parameters provided to the callback are ref parameters allowing the callback to modify these parameters. Typically the user will want to change these

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

LordAshes-LoggingPlugin

檔案與校驗

檔案名稱
DiceOpsPlugin-1.1.1.zip
檔案大小
35.5 KiB