52 lines
2.2 KiB
C#
52 lines
2.2 KiB
C#
using Ichni.Story;
|
|
using Yarn.Unity;
|
|
|
|
namespace Ichni.Story.YarnFunctions
|
|
{
|
|
/// <summary>
|
|
/// ichni Official 的永久剧情变量 Yarn 接口。
|
|
/// <para>所有变量都属于当前 StoryData 对应的章节存档。请不要在新台本中使用 Yarn 原生的
|
|
/// <c><<declare>></c>、<c><<set>></c> 或 <c>$variable</c>,它们会创建不受本章节回滚系统管理的临时变量。</para>
|
|
/// <para>推荐语法:<c><<set_bool "c0_intro_read" true>></c>、
|
|
/// <c><<if get_int("c0_route") == 1>></c>。</para>
|
|
/// </summary>
|
|
public static class VariableCommands
|
|
{
|
|
[YarnCommand("set_bool")]
|
|
public static void SetBool(string key, bool value) => StoryProgress.SetBoolAndRefresh(key, value);
|
|
|
|
[YarnFunction("get_bool")]
|
|
public static bool GetBool(string key) => StoryVariables.GetBool(key);
|
|
|
|
[YarnCommand("set_int")]
|
|
public static void SetInt(string key, int value) => StoryProgress.SetIntAndRefresh(key, value);
|
|
|
|
[YarnCommand("add_int")]
|
|
public static void AddInt(string key, int delta) => StoryProgress.AddIntAndRefresh(key, delta);
|
|
|
|
[YarnFunction("get_int")]
|
|
public static int GetInt(string key) => StoryVariables.GetInt(key);
|
|
|
|
[YarnCommand("set_float")]
|
|
public static void SetFloat(string key, float value) => StoryProgress.SetFloatAndRefresh(key, value);
|
|
|
|
[YarnCommand("add_float")]
|
|
public static void AddFloat(string key, float delta) => StoryProgress.AddFloatAndRefresh(key, delta);
|
|
|
|
[YarnFunction("get_float")]
|
|
public static float GetFloat(string key) => StoryVariables.GetFloat(key);
|
|
|
|
[YarnCommand("set_string")]
|
|
public static void SetString(string key, string value) => StoryProgress.SetStringAndRefresh(key, value);
|
|
|
|
[YarnFunction("get_string")]
|
|
public static string GetString(string key) => StoryVariables.GetString(key);
|
|
|
|
[YarnCommand("remove_variable")]
|
|
public static void RemoveVariable(string key) => StoryProgress.RemoveVariableAndRefresh(key);
|
|
|
|
[YarnFunction("has_variable")]
|
|
public static bool HasVariable(string key) => StoryVariables.HasVariable(key);
|
|
}
|
|
}
|