同步
This commit is contained in:
95
Assets/Scripts/SLSUtilities/Narrative/Base/YarnFunctions.cs
Normal file
95
Assets/Scripts/SLSUtilities/Narrative/Base/YarnFunctions.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.Collections.Generic;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace SLSUtilities.Narrative
|
||||
{
|
||||
public static partial class YarnFunctions
|
||||
{
|
||||
[YarnCommand("set_bool")]
|
||||
public static void Yarn_SetBool(string key, bool value)
|
||||
{
|
||||
StorySystem.Variables.boolVariables[key] = value;
|
||||
}
|
||||
|
||||
[YarnFunction("get_bool")]
|
||||
public static bool Yarn_GetBool(string key)
|
||||
{
|
||||
return StorySystem.Variables.boolVariables.GetValueOrDefault(key, false);
|
||||
}
|
||||
|
||||
[YarnCommand("set_int")]
|
||||
public static void Yarn_SetInt(string key, int value)
|
||||
{
|
||||
StorySystem.Variables.intVariables[key] = value;
|
||||
}
|
||||
|
||||
[YarnCommand("modify_int")]
|
||||
public static void Yarn_ModifyInt(string key, int modification)
|
||||
{
|
||||
int currentValue = StorySystem.Variables.intVariables.GetValueOrDefault(key, 0);
|
||||
StorySystem.Variables.intVariables[key] = currentValue + modification;
|
||||
}
|
||||
|
||||
[YarnFunction("get_int")]
|
||||
public static int Yarn_GetInt(string key)
|
||||
{
|
||||
return StorySystem.Variables.intVariables.GetValueOrDefault(key, 0);
|
||||
}
|
||||
|
||||
[YarnCommand("set_float")]
|
||||
public static void Yarn_SetFloat(string key, float value)
|
||||
{
|
||||
StorySystem.Variables.floatVariables[key] = value;
|
||||
}
|
||||
|
||||
[YarnCommand("modify_float")]
|
||||
public static void Yarn_ModifyFloat(string key, float modification)
|
||||
{
|
||||
float currentValue = StorySystem.Variables.floatVariables.GetValueOrDefault(key, 0f);
|
||||
StorySystem.Variables.floatVariables[key] = currentValue + modification;
|
||||
}
|
||||
|
||||
[YarnFunction("get_float")]
|
||||
public static float Yarn_GetFloat(string key)
|
||||
{
|
||||
return StorySystem.Variables.floatVariables.GetValueOrDefault(key, 0f);
|
||||
}
|
||||
|
||||
[YarnCommand("set_string")]
|
||||
public static void Yarn_SetString(string key, string value)
|
||||
{
|
||||
StorySystem.Variables.stringVariables[key] = value;
|
||||
}
|
||||
|
||||
[YarnFunction("get_string")]
|
||||
public static string Yarn_GetString(string key)
|
||||
{
|
||||
return StorySystem.Variables.stringVariables.GetValueOrDefault(key, "");
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class YarnFunctions
|
||||
{
|
||||
[YarnCommand("log")]
|
||||
public static void Log(string message, string logType)
|
||||
{
|
||||
logType = logType.ToLower();
|
||||
|
||||
switch (logType)
|
||||
{
|
||||
case "info":
|
||||
UnityEngine.Debug.Log(message);
|
||||
break;
|
||||
case "warning":
|
||||
UnityEngine.Debug.LogWarning(message);
|
||||
break;
|
||||
case "error":
|
||||
UnityEngine.Debug.LogError(message);
|
||||
break;
|
||||
default:
|
||||
UnityEngine.Debug.Log(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user