架构大更
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>从 outerContext 中读取一个变量并输出到控制台。</summary>
|
||||
public class Cmd_GetAndLogVariable : CommandBase
|
||||
{
|
||||
private readonly string variableName;
|
||||
|
||||
public Cmd_GetAndLogVariable(string variableName)
|
||||
{
|
||||
this.variableName = variableName;
|
||||
}
|
||||
|
||||
protected override UniTask ExecuteAsync(CommandContext outerContext)
|
||||
{
|
||||
if (outerContext.context.TryGetValue(variableName, out object value))
|
||||
Debug.Log($"[Cmd_GetAndLogVariable] 获取变量 '{variableName}',值为: '{value?.ToString() ?? "null"}'");
|
||||
else
|
||||
Debug.LogWarning($"[Cmd_GetAndLogVariable] 变量 '{variableName}' 未在上下文中定义。");
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f69b73b7e4bbb84bb29e4d5000b1292
|
||||
@@ -0,0 +1,26 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>在 outerContext 中设置一个键值对。</summary>
|
||||
public class Cmd_SetVariable : CommandBase
|
||||
{
|
||||
private readonly string variableName;
|
||||
private readonly object value;
|
||||
|
||||
public Cmd_SetVariable(string variableName, object value)
|
||||
{
|
||||
this.variableName = variableName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
protected override UniTask ExecuteAsync(CommandContext outerContext)
|
||||
{
|
||||
Debug.Log($"[Cmd_SetVariable] 设置变量 '{variableName}',值为: '{value}'");
|
||||
outerContext.context[variableName] = value;
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16d73f0ca2725b6459957343e231bc32
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>等待指定秒数后在控制台输出一条信息。</summary>
|
||||
public class Cmd_WaitAndLog : CommandBase
|
||||
{
|
||||
private readonly float duration;
|
||||
private readonly string message;
|
||||
|
||||
public Cmd_WaitAndLog(float duration, string message)
|
||||
{
|
||||
this.duration = duration;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
protected override async UniTask ExecuteAsync(CommandContext outerContext)
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(duration));
|
||||
Debug.Log($"[Cmd_WaitAndLog] 等待 {duration} 秒后... 输出: '{message}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25d431de73c653d42a6950339d22aa16
|
||||
Reference in New Issue
Block a user