32 lines
1.0 KiB
Dart
32 lines
1.0 KiB
Dart
import '../models/game_diff.dart';
|
||
import '../models/runtime_event.dart';
|
||
import '../packages/game_package.dart';
|
||
import 'runtime_script_services.dart';
|
||
|
||
abstract interface class ScriptEngine {
|
||
// 加载单个包(向后兼容,内部调 loadPackages([package]))。
|
||
Future<void> loadPackage(
|
||
GamePackage package, {
|
||
RuntimeScriptServices services = const RuntimeScriptServices(),
|
||
});
|
||
|
||
// 加载多个包,按顺序合并模块,后加载的同名模块覆盖先加载的。
|
||
// 入口脚本使用最后一个包。
|
||
Future<void> loadPackages(
|
||
List<GamePackage> packages, {
|
||
RuntimeScriptServices services = const RuntimeScriptServices(),
|
||
});
|
||
|
||
bool smokeTest(Map<String, Object?> context);
|
||
|
||
GameDiff init(Map<String, Object?> context);
|
||
|
||
GameDiff dispatchEvent(RuntimeEvent event);
|
||
|
||
/// 设置翻译字典和当前语言,Lua 侧可通过 runtime.i18n.t(key, fallback) 查询。
|
||
void setTranslations({
|
||
required String locale,
|
||
required Map<String, Map<String, String>> translations,
|
||
});
|
||
}
|