mirror of
https://github.com/motajs/template.git
synced 2026-10-16 18:40:17 +08:00
refactor: 渲染端配置文件
This commit is contained in:
parent
cc434a6c66
commit
d65b107819
6
.planning/milestone.lock
Normal file
6
.planning/milestone.lock
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"phase": "04",
|
||||
"session": "wt-session-b84829ae-9f7f-44f6-b3e6-65c99e0c49cb",
|
||||
"pid": 33048,
|
||||
"updated_at": 1789718455992
|
||||
}
|
||||
@ -10,10 +10,8 @@ import {
|
||||
} from '@motajs/audio';
|
||||
import { IRenderTreeRoot, MotaRenderer } from '@motajs/render';
|
||||
import {
|
||||
IMotaAssetsLoader,
|
||||
IMaterialManager,
|
||||
IAutotileProcessor,
|
||||
MotaAssetsLoader,
|
||||
MaterialManager,
|
||||
AutotileProcessor,
|
||||
ISaveSystem,
|
||||
@ -49,7 +47,6 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
readonly save: ISaveSystem;
|
||||
|
||||
// Layer 5 渲染顶层
|
||||
readonly loader: IMotaAssetsLoader;
|
||||
readonly materials: IMaterialManager;
|
||||
readonly autotile: IAutotileProcessor;
|
||||
|
||||
@ -89,14 +86,6 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
|
||||
//#endregion
|
||||
|
||||
this.loader = new MotaAssetsLoader(
|
||||
this.loadProgress,
|
||||
this.dataLoader,
|
||||
this.audioContext,
|
||||
this.soundPlayer,
|
||||
this.materials
|
||||
);
|
||||
|
||||
// 兼容层
|
||||
loading.once('loaded', () => {
|
||||
fallbackLoad(this.materials);
|
||||
|
||||
42
packages-user/client-modules/src/common.ts
Normal file
42
packages-user/client-modules/src/common.ts
Normal file
@ -0,0 +1,42 @@
|
||||
export interface IClientContentDefaultConfig {
|
||||
/** 贴图列表中每一项的默认值 */
|
||||
readonly textureDefault: string;
|
||||
/** 音频列表中每一项的默认值 */
|
||||
readonly audioDefault: string;
|
||||
/** 动画列表中每一项的默认值 */
|
||||
readonly animationDefault: string;
|
||||
/** 字体列表中每一项的默认值 */
|
||||
readonly fontDefault: string;
|
||||
}
|
||||
|
||||
export interface IClientContentConfig {
|
||||
/** 配置的默认对象配置路径 */
|
||||
readonly defaults: IClientContentDefaultConfig;
|
||||
/** 贴图文件夹路径 */
|
||||
readonly textureDir: string;
|
||||
/** 贴图列表文件路径 */
|
||||
readonly textureListDir: string;
|
||||
/** 音频文件夹路径 */
|
||||
readonly audioDir: string;
|
||||
/** 音频列表文件路径 */
|
||||
readonly audioListDir: string;
|
||||
/** 动画文件夹路径 */
|
||||
readonly animationDir: string;
|
||||
/** 动画列表文件路径 */
|
||||
readonly animationListDir: string;
|
||||
/** 字体文件夹路径 */
|
||||
readonly fontDir: string;
|
||||
/** 字体列表文件路径 */
|
||||
readonly fontListDir: string;
|
||||
}
|
||||
|
||||
export interface IClientConfig {
|
||||
/** 渲染端数据配置 */
|
||||
readonly content: IClientContentConfig;
|
||||
/** 标题界面使用的图片 */
|
||||
readonly titleImage: string;
|
||||
/** 标题界面使用的背景音乐 */
|
||||
readonly titleBGM: string;
|
||||
/** 初始状态下勇士使用的默认贴图 */
|
||||
readonly heroImage: string;
|
||||
}
|
||||
22
packages-user/client-modules/src/loader/hook.ts
Normal file
22
packages-user/client-modules/src/loader/hook.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import {
|
||||
IMotaDataLoader,
|
||||
IMotaDataLoaderHooks,
|
||||
ICoreStateCoreConfig
|
||||
} from '@user/data-state';
|
||||
|
||||
export class RenderLoaderHooks implements IMotaDataLoaderHooks {
|
||||
constructor(readonly clientDir: string) {}
|
||||
|
||||
awake(): void {}
|
||||
|
||||
destroy(): void {}
|
||||
|
||||
onCoreConfigLoaded?(
|
||||
_: ICoreStateCoreConfig,
|
||||
loader: IMotaDataLoader
|
||||
): Promise<void> {
|
||||
loader.addExtraConfig('client', this.clientDir);
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
0
packages-user/client-modules/src/loader/index.ts
Normal file
0
packages-user/client-modules/src/loader/index.ts
Normal file
@ -1,11 +1,8 @@
|
||||
import { IMapExtensionManager, IMapRenderer } from './render/map';
|
||||
import { IMotaAssetsLoader, IClientBase } from '@user/client-base';
|
||||
import { IClientBase } from '@user/client-base';
|
||||
import { IExcitation, IExcitationDivider } from '@motajs/animate';
|
||||
|
||||
export interface IClientCore extends IClientBase {
|
||||
/** 渲染端加载对象 */
|
||||
readonly loader: IMotaAssetsLoader;
|
||||
|
||||
/** 用于渲染系统的 Raf 激励源 */
|
||||
readonly rafExcitation: IExcitation<number>;
|
||||
/** 用于渲染系统的激励源分频器 */
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { IMapAreaInterval } from '@user/data-base';
|
||||
import { IHeroAttr } from '@user/data-common';
|
||||
|
||||
//#region 数据端主配置
|
||||
@ -82,6 +83,8 @@ export interface ICoreStateCoreConfig {
|
||||
readonly title: string;
|
||||
/** 游戏版本号,仅呈现作用,对游戏本身没有任何影响 */
|
||||
readonly version: string;
|
||||
/** 地图分区配置 */
|
||||
readonly floorAreas: IMapAreaInterval[];
|
||||
/** 游戏数据配置 */
|
||||
readonly content: ICoreStateContentConfig;
|
||||
/** 游戏的初始状态数据 */
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { logger } from '@motajs/common';
|
||||
import { ILoadManager, LoadManager } from '@motajs/loader';
|
||||
import {
|
||||
IRoleFaceBinder,
|
||||
IFaceManager,
|
||||
@ -59,7 +60,7 @@ import {
|
||||
} from './enemy';
|
||||
import { HERO_DEFAULT_ATTRIBUTE, TILE_HEIGHT, TILE_WIDTH } from './shared';
|
||||
import { DefaultHeroMoveTopImpl, DefaultPassPredicateImpl } from './hero';
|
||||
import { createEventRegistrations } from './event/registrations';
|
||||
import { createEventRegistrations } from './event';
|
||||
import {
|
||||
ReplayEquip,
|
||||
ReplayMove,
|
||||
@ -67,10 +68,11 @@ import {
|
||||
ReplayUnequip,
|
||||
ReplayUseItem
|
||||
} from './replay';
|
||||
import { IMotaDataLoader } from './loader/types';
|
||||
import { MotaDataLoader } from './loader/loader';
|
||||
import { ILoadManager, LoadManager } from '@motajs/loader';
|
||||
import { DefaultDataLoaderHook } from './loader/hook';
|
||||
import {
|
||||
IMotaDataLoader,
|
||||
MotaDataLoader,
|
||||
DefaultDataLoaderHook
|
||||
} from './loader';
|
||||
|
||||
export class CoreState implements ICoreState {
|
||||
// Layer 0 公共层,最底层的接口,不会依赖任何其他内容,一般是工具性接口及不需要存档的数据
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
export * from './enemy';
|
||||
export * from './event';
|
||||
export * from './hero';
|
||||
export * from './loader';
|
||||
export * from './replay';
|
||||
|
||||
export * from './common';
|
||||
export * from './core';
|
||||
export * from './ins';
|
||||
export * from './shared';
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
export * from './hook';
|
||||
export * from './jsoncProcessor';
|
||||
export * from './loader';
|
||||
export * from './types';
|
||||
3
src/content/audio/.list.jsonc
Normal file
3
src/content/audio/.list.jsonc
Normal file
@ -0,0 +1,3 @@
|
||||
// Type: type define required
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
@ -1,2 +1,23 @@
|
||||
// Type: packages-user/client-modules/src/common.ts IClientConfig
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
{
|
||||
"titleImage": "title.jpg",
|
||||
"titleBGM": "bgm.opus",
|
||||
"heroImage": "hero.png",
|
||||
"content": {
|
||||
"textureDir": "texture",
|
||||
"textureListDir": "texture/.list.jsonc",
|
||||
"audioDir": "audio",
|
||||
"audioListDir": "audio/.list.jsonc",
|
||||
"animationDir": "animation",
|
||||
"animationListDir": "animation/.list.jsonc",
|
||||
"fontDir": "font",
|
||||
"fontListDir": "font/.list.jsonc",
|
||||
"defaults": {
|
||||
"textureDefault": "defaults/texture.jsonc",
|
||||
"audioDefault": "defaults/audio.jsonc",
|
||||
"animationDefault": "defaults/animation.jsonc",
|
||||
"fontDefault": "defaults/font.jsonc"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
// Type: packages-user/data-state/src/types.ts ICoreStateCoreConfig
|
||||
// Type: packages-user/data-state/src/common.ts ICoreStateCoreConfig
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{
|
||||
"name": "template",
|
||||
"title": "魔塔样板",
|
||||
"version": "Ver 2.C",
|
||||
"floorAreas": [],
|
||||
"content": {
|
||||
"mapsDir": "maps",
|
||||
"mapListDir": "maps/.list.jsonc",
|
||||
|
||||
5
src/content/defaults/animation.jsonc
Normal file
5
src/content/defaults/animation.jsonc
Normal file
@ -0,0 +1,5 @@
|
||||
// Type: type required.
|
||||
// "@required" means the property is required.
|
||||
// For objects, system will compare every properties.
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
5
src/content/defaults/audio.jsonc
Normal file
5
src/content/defaults/audio.jsonc
Normal file
@ -0,0 +1,5 @@
|
||||
// Type: type required.
|
||||
// "@required" means the property is required.
|
||||
// For objects, system will compare every properties.
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
5
src/content/defaults/font.jsonc
Normal file
5
src/content/defaults/font.jsonc
Normal file
@ -0,0 +1,5 @@
|
||||
// Type: type required.
|
||||
// "@required" means the property is required.
|
||||
// For objects, system will compare every properties.
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
5
src/content/defaults/texture.jsonc
Normal file
5
src/content/defaults/texture.jsonc
Normal file
@ -0,0 +1,5 @@
|
||||
// Type: type required.
|
||||
// "@required" means the property is required.
|
||||
// For objects, system will compare every properties.
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
0
src/content/font/.list.jsonc
Normal file
0
src/content/font/.list.jsonc
Normal file
3
src/content/texture/.list.jsonc
Normal file
3
src/content/texture/.list.jsonc
Normal file
@ -0,0 +1,3 @@
|
||||
// Type: type define required
|
||||
// --- SYSTEM PREFIX END --- //
|
||||
{}
|
||||
Loading…
Reference in New Issue
Block a user