feat: 杂项

This commit is contained in:
unanmed 2024-03-04 19:00:39 +08:00
parent 2a6a1d6cfe
commit 3913229e52
4 changed files with 67 additions and 25 deletions

View File

@ -428,17 +428,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
core.events.checkLvUp();
const getHeroStatusOn = Mota.require('fn', 'getHeroStatusOn');
const { has } = Mota.Plugin.require('utils_g');
// 检查HP上限
if (core.flags.statusBarItems.indexOf('enableHPMax') >= 0) {
core.setStatus(
'hp',
Math.min(getHeroStatusOn('hpmax'), core.getStatus('hp'))
);
const hpmax = getHeroStatusOn('hpmax');
if (core.status.hero.hp > hpmax) {
core.status.hero.hp = hpmax;
}
}
// 设置生命上限、生命值、攻防护盾金币和经验值
var statusList = [
const statusList = [
'hpmax',
'hp',
'mana',
@ -448,29 +449,26 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
'money',
'exp'
];
statusList.forEach(function (item) {
statusList.forEach(item => {
// 向下取整
core.status.hero[item] = Math.floor(core.status.hero[item]);
});
// 设置魔力值; status:manamax 只有在非负时才生效。
if (
core.status.hero.manamax != null &&
core.getRealStatus('manamax') >= 0
) {
core.status.hero.mana = Math.min(
core.status.hero.mana,
core.getRealStatus('manamax')
);
if (has(core.status.hero.manamax)) {
const manamax = getHeroStatusOn('manamax');
if (manamax >= 0 && getHeroStatusOn('mana') > manamax) {
core.status.hero.mana = manamax;
}
}
// 难度
if (core.statusBar.hard.innerText != core.status.hard) {
if (core.statusBar.hard.innerText !== core.status.hard) {
core.statusBar.hard.innerText = core.status.hard;
}
var hardColor = core.getFlag('__hardColor__');
if (hardColor == null) core.statusBar.hard.innerText = '';
if (core.statusBar.hard.getAttribute('_style') != hardColor) {
const hardColor = core.getFlag('__hardColor__');
if (!has(hardColor)) core.statusBar.hard.innerText = '';
if (core.statusBar.hard.getAttribute('_style') !== hardColor) {
core.statusBar.hard.style.color = hardColor;
core.statusBar.hard.setAttribute('_style', hardColor);
}

View File

@ -1312,5 +1312,51 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
core.insertAction(actions);
}
});
},
misc: function () {
// 把一些杂项放在这了
const { loading } = Mota.requireAll('var');
Mota.r(() => {
// 楼层滤镜配置
loading.once('coreInit', () => {
const { filterMap } = Mota.Plugin.require('gameCanvas_r');
// 楼层滤镜是一系列数组,数组第一项是一个数组,表示所有使用这个滤镜的楼层,第二项是滤镜内容
filterMap.push(
[
['sample0', 'sample1', 'sample2'], // 楼层列表
'brightness(120%)' // 滤镜内容
],
[['MT0'], 'contrast(120%)']
);
});
// 点光源配置,参考插件库点光源插件的配置方式
loading.once('coreInit', () => {
const { shadowInfo, backgroundInfo, blurInfo, immersionInfo } =
Mota.Plugin.require('gameShadow_r');
const { pColor } = Mota.require('module', 'RenderUtils');
// 光源信息
shadowInfo.MT0 = [
{
id: 'mt0_1',
x: 144,
y: 144,
decay: 20,
r: 150,
color: pColor('#e953'),
noShelter: true
}
];
// 背景色
backgroundInfo.MT0 = pColor('#0006');
// 虚化程度
blurInfo.MT0 = 3;
// 浸入墙壁程度
immersionInfo.MT0 = 4;
});
});
}
};

View File

@ -12,9 +12,7 @@ export function setGameCanvasFilter(filter: string) {
});
}
const filterMap: [FloorIds[], string][] = [
[['MT50'], 'brightness(80%)contrast(120%)'] // 童心佬的滤镜(
];
export const filterMap: [FloorIds[], string][] = [];
export function getCanvasFilterByFloorId(
floorId: FloorIds = core.status.floorId

View File

@ -46,7 +46,7 @@ export function init() {
});
}
const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
export const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
MT50: [
{
id: 'mt50_1',
@ -86,11 +86,11 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
}
]
};
const backgroundInfo: Partial<Record<FloorIds, Color>> = {
export const backgroundInfo: Partial<Record<FloorIds, Color>> = {
MT50: pColor('#0006')
};
const blurInfo: Partial<Record<FloorIds, number>> = {};
const immersionInfo: Partial<Record<FloorIds, number>> = {};
export const blurInfo: Partial<Record<FloorIds, number>> = {};
export const immersionInfo: Partial<Record<FloorIds, number>> = {};
const shadowCache: Partial<Record<FloorIds, Polygon[]>> = {};
let calMapShadow = true;