mirror of
https://github.com/motajs/template.git
synced 2026-10-09 05:50:16 +08:00
chore: 调整部分错误
This commit is contained in:
parent
75a39ad573
commit
ce459d9e2d
@ -2,4 +2,3 @@ export * from './autotile';
|
||||
export * from './builder';
|
||||
export * from './manager';
|
||||
export * from './types';
|
||||
export * from './utils';
|
||||
|
||||
@ -35,6 +35,7 @@ interface ITilesetCache {
|
||||
}
|
||||
|
||||
export class TextureManager implements ITextureManager {
|
||||
readonly tiles: ITileStore;
|
||||
readonly autotile: IAutotileProcessor;
|
||||
|
||||
readonly textures: ITextureStore = new TextureStore();
|
||||
@ -83,10 +84,10 @@ export class TextureManager implements ITextureManager {
|
||||
|
||||
constructor(
|
||||
readonly state: ICoreState,
|
||||
readonly tiles: ITileStore,
|
||||
readonly tilesetReserve: number,
|
||||
readonly tilesetUnit: number
|
||||
) {
|
||||
this.tiles = state.tileStore;
|
||||
this.autotile = new AutotileProcessor(state);
|
||||
this.assetBuilder = new AssetBuilder(this, state);
|
||||
this.assetBuilder.pipe(this.assetStore);
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
import { ITexture } from '@motajs/render';
|
||||
import { BlockCls } from './types';
|
||||
|
||||
/**
|
||||
* @deprecated 后续理应不需要此接口
|
||||
*/
|
||||
export function getClsByString(cls: Cls): BlockCls {
|
||||
switch (cls) {
|
||||
case 'terrains':
|
||||
return BlockCls.Terrains;
|
||||
case 'animates':
|
||||
return BlockCls.Animates;
|
||||
case 'autotile':
|
||||
return BlockCls.Autotile;
|
||||
case 'enemys':
|
||||
return BlockCls.Enemys;
|
||||
case 'items':
|
||||
return BlockCls.Items;
|
||||
case 'npcs':
|
||||
return BlockCls.Npcs;
|
||||
case 'npc48':
|
||||
return BlockCls.Npc48;
|
||||
case 'enemy48':
|
||||
return BlockCls.Enemy48;
|
||||
case 'tileset':
|
||||
return BlockCls.Tileset;
|
||||
default:
|
||||
return BlockCls.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 后续应对存储结构进行重构,每个 tile 都可以自定义帧数
|
||||
*/
|
||||
export function getTextureFrame(cls: BlockCls, texture: ITexture) {
|
||||
switch (cls) {
|
||||
case BlockCls.Animates:
|
||||
case BlockCls.Enemy48:
|
||||
case BlockCls.Npc48:
|
||||
return 4;
|
||||
case BlockCls.Autotile:
|
||||
return texture.width === 384 ? 4 : 1;
|
||||
case BlockCls.Enemys:
|
||||
case BlockCls.Npcs:
|
||||
return 2;
|
||||
case BlockCls.Items:
|
||||
case BlockCls.Terrains:
|
||||
case BlockCls.Tileset:
|
||||
return 1;
|
||||
case BlockCls.Unknown:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -43,23 +43,21 @@ import { UIController } from '@motajs/system';
|
||||
export class ClientCore extends CoreState implements IClientCore {
|
||||
// Layer 4 渲染基础层
|
||||
readonly save: ISaveSystem;
|
||||
|
||||
// Layer 5 渲染顶层
|
||||
readonly materials: ITextureManager;
|
||||
|
||||
readonly audioContext: IMotaAudioContext;
|
||||
readonly soundPlayer: ISoundPlayer<SoundIds>;
|
||||
readonly bgmPlayer: IBGMPlayer<BgmIds>;
|
||||
readonly rafExcitation: IExcitation<number>;
|
||||
readonly excitationDivider: IExcitationDivider<number>;
|
||||
readonly renderer: IRenderTreeRoot;
|
||||
readonly materials: ITextureManager;
|
||||
|
||||
// Layer 5 渲染顶层
|
||||
readonly using: IRendererUsing;
|
||||
readonly mainMapRenderer: IMapRenderer;
|
||||
readonly mainMapExtension: IMapExtensionManager;
|
||||
readonly sceneController: UIController;
|
||||
readonly mainUIController: UIController;
|
||||
|
||||
readonly audioContext: IMotaAudioContext;
|
||||
readonly soundPlayer: ISoundPlayer<SoundIds>;
|
||||
readonly bgmPlayer: IBGMPlayer<BgmIds>;
|
||||
|
||||
constructor(config: IClientCoreConfig) {
|
||||
super({
|
||||
loadStarter: new WebLoadStarter(),
|
||||
@ -83,7 +81,6 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
|
||||
this.materials = new TextureManager(
|
||||
this,
|
||||
this.tileStore,
|
||||
config.tilesetReserve,
|
||||
config.tilesetUnit
|
||||
);
|
||||
|
||||
@ -49,7 +49,6 @@ import {
|
||||
import { ICoreState, ICoreStateConfig, ISaveableExecutor } from './types';
|
||||
import {
|
||||
CommonAuraConverter,
|
||||
EnemyLegacyBridge,
|
||||
GuardAuraConverter,
|
||||
MainDamageCalculator,
|
||||
MainEnemyFinalEffect,
|
||||
@ -139,7 +138,7 @@ export class CoreState implements ICoreState {
|
||||
this.flags = new FlagSystem();
|
||||
|
||||
// 地图
|
||||
this.maps = new MapState(this.tileStore, this);
|
||||
this.maps = new MapState(this);
|
||||
|
||||
// 勇士
|
||||
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
||||
@ -148,7 +147,7 @@ export class CoreState implements ICoreState {
|
||||
|
||||
// 怪物管理器
|
||||
const comparer = new MainEnemyComparer();
|
||||
const enemyManager = new EnemyManager(new EnemyLegacyBridge());
|
||||
const enemyManager = new EnemyManager<IEnemyAttr>(this.tileStore);
|
||||
enemyManager.attachEnemyComparer(comparer);
|
||||
enemyManager.setAttributeDefaults('hp', 0);
|
||||
enemyManager.setAttributeDefaults('atk', 0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user