Skip to content

Commit

Permalink
部分枚举要从地图配置里读出来
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Nov 25, 2024
1 parent 435cf27 commit 9506001
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/ecaCompiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Compiler } from './compiler';
import { Formatter } from './formatter';
import * as vscode from 'vscode';
import * as y3 from 'y3-helper';
import { testConfig } from './testConfig';
import { fillStatic, fillMapDefined } from './testConfig';

export function init() {
const formatter = new Formatter();

testConfig(formatter);
fillStatic(formatter);

vscode.commands.registerCommand('y3-helper.compileECA', async () => {
await y3.env.mapReady();
if (!y3.env.scriptUri) {
vscode.window.showErrorMessage('请先打开地图');
return;
Expand All @@ -20,6 +20,10 @@ export function init() {
title: '编译中...',
cancellable: true,
}, async (progress, token) => {
progress.report({
message: '正在加载地图配置...',
});
await fillMapDefined(formatter);
progress.report({
message: '正在搜索触发器文件...',
});
Expand Down
52 changes: 44 additions & 8 deletions src/ecaCompiler/testConfig.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
/* eslint-disable @typescript-eslint/semi */
import { Formatter } from './formatter';
import * as y3 from 'y3-helper';
import { define } from '../customDefine';

export function testConfig(formatter: Formatter) {
export async function fillMapDefined(formatter: Formatter) {
formatter
// 字体类型
.setRule(100259, {
'physics': y3.lua.encode('物理伤害'),
'magic': y3.lua.encode('魔法伤害'),
'real': y3.lua.encode('真实伤害'),
'heal': y3.lua.encode('治疗'),
'get_gold': y3.lua.encode('获取金币'),
0: y3.lua.encode('系统字体'),
'MSYH': y3.lua.encode('微软雅黑'),
'HKHeiW9': y3.lua.encode('华康黑体W9'),
'HKHeiW12': y3.lua.encode('华康黑体W12'),
'HKSongW9': y3.lua.encode('华康标题宋W9'),
'HKWeiBeiW7': y3.lua.encode('华康魏碑W7'),
'HKXinZongYiW7': y3.lua.encode('华康新综艺体W7'),
'HKXinZongYiW9': y3.lua.encode('华康新综艺体W9'),
'HKYuanW5': y3.lua.encode('华康圆体W5'),
'HKYuanW7': y3.lua.encode('华康圆体W7'),
'HKYuanW9': y3.lua.encode('华康圆体W9'),
// 从配置里读取自定义字体
...(await define.字体.get()).reduce((map, font) => {
map[font.uid] = y3.lua.encode(font.name);
return map;
}, {} as Record<string, string>),
})
// 从配置里读取跳字类型
. setRule(100333, (await define.跳字.get()).reduce((map, word) => {
map[word.uid] = y3.lua.encode(word.name);
return map;
}, {} as Record<string, string>))
}

export function fillStatic(formatter: Formatter) {
formatter
// 预设单位
. setRule(100006, 'y3.unit.get_by_res_id({})')
. setRule(100205, 'y3.destructible.get_by_id({})')
. setRule(100333, {
934231441: '"伤害_左上"',
934269508: '"伤害_中上"',
934266669: '"伤害_右上"',
934252831: '"伤害_左下"',
934277693: '"金币跳字"',
// 伤害类型
. setRule(100064, {
0: y3.lua.encode('物理'),
1: y3.lua.encode('法术'),
2: y3.lua.encode('真实'),
})
// 预设可破坏物
. setRule(100205, 'y3.destructible.get_by_id({})')

. setRule('UNIT_ENTITY_POINT', '{}:get_point()')
. setRule('ALL_PLAYER', 'y3.player_group.get_all_players()')
Expand Down

0 comments on commit 9506001

Please sign in to comment.