MOD!
This commit is contained in:
@@ -2,7 +2,7 @@ using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SoulliesFramework.General
|
||||
namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>
|
||||
/// 指令:从指令上下文中获取一个变量,并将其作为字符串在控制台输出。
|
||||
@@ -16,10 +16,10 @@ namespace SoulliesFramework.General
|
||||
this.variableName = variableName;
|
||||
}
|
||||
|
||||
protected override IObservable<Unit> OnExecute(CommandContext context)
|
||||
protected override IObservable<Unit> OnExecute(CommandContext outerContext)
|
||||
{
|
||||
// 尝试从 SharedData 中获取变量。
|
||||
if (context.sharedInfo.TryGetValue(variableName, out object value))
|
||||
if (outerContext.context.TryGetValue(variableName, out object value))
|
||||
{
|
||||
// 获取成功,将其转换为字符串并输出。
|
||||
string stringValue = value?.ToString() ?? "null";
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SoulliesFramework.General
|
||||
namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>
|
||||
/// 指令:在指令上下文 (CommandContext) 中声明并设置一个变量。
|
||||
@@ -18,13 +18,13 @@ namespace SoulliesFramework.General
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
protected override IObservable<Unit> OnExecute(CommandContext context)
|
||||
protected override IObservable<Unit> OnExecute(CommandContext outerContext)
|
||||
{
|
||||
Debug.Log($"[Cmd_SetVariable] 正在设置变量 '{variableName}',值为: '{value}'");
|
||||
|
||||
// 直接操作 Context 的 SharedData 字典来存入数据。
|
||||
// 使用索引器会覆盖同名旧值,如果需要更复杂的逻辑可以先用 TryGetValue 检查。
|
||||
context.sharedInfo[variableName] = value;
|
||||
outerContext.context[variableName] = value;
|
||||
|
||||
// 这是一个瞬时操作,所以返回一个立即完成的 Observable。
|
||||
return Observable.Return(Unit.Default);
|
||||
|
||||
@@ -2,7 +2,7 @@ using UniRx;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SoulliesFramework.General
|
||||
namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>
|
||||
/// 指令:等待指定秒数后,在控制台输出一条信息。
|
||||
@@ -23,7 +23,7 @@ namespace SoulliesFramework.General
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
protected override IObservable<Unit> OnExecute(CommandContext context)
|
||||
protected override IObservable<Unit> OnExecute(CommandContext outerContext)
|
||||
{
|
||||
// 使用 Observable.Timer 来创建一个在指定时间后发出信号的流。
|
||||
// Do 操作符用于在流的特定生命周期点执行副作用(例如打印日志)。
|
||||
|
||||
Reference in New Issue
Block a user