feat: 图块信息接口

This commit is contained in:
AncTe committed 2026-06-28 19:32:46 +08:00
1 parent 3e150c4a1d
commit eb34d63e96
8 files changed
+176 -24

No files matched your search

+1 -3
View File
@@ -17,7 +17,6 @@ import {
} from '@user/data-common';
import {
EnemyManager,
HeroMoveController,
IEnemyManager,
HeroAttribute,
HeroState,
@@ -129,9 +128,8 @@ export class CoreState implements ICoreState {
this.maps = new MapStore(tileStore, this);
// 勇士
const heroMover = new HeroMoveController();
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
const heroState = new HeroState(heroMover, heroAttribute);
const heroState = new HeroState(this, dir8, heroAttribute);
this.hero = heroState;
this.loadProgress = new LoadProgressTotal();
+74 -9
View File
@@ -1,21 +1,14 @@
import {
ITileLegacyConverter,
ITilePassData,
ITileRawData,
PassBit,
TileType
} from '@user/data-common';
export type LegacyTileData = MapDataOf<keyof NumberToId>;
export class TileLegacyBridge implements ITileLegacyConverter<LegacyTileData> {
fromLegacy(num: number, legacy: LegacyTileData): ITileRawData {
return {
num,
id: legacy.id,
trigger: -1,
type: this.getTileType(num, legacy)
};
}
private getTileType(num: number, legacy: LegacyTileData): TileType {
if (num === 0) return TileType.None;
switch (legacy.cls) {
@@ -40,4 +33,76 @@ export class TileLegacyBridge implements ITileLegacyConverter<LegacyTileData> {
return TileType.Unknown;
}
}
private getPass(num: number, legacy: LegacyTileData): ITilePassData {
if (num === 0) {
return {
onlyEvents: true,
inPass: 0b1111,
outPass: 0b1111
};
} else if (num === 17) {
return {
onlyEvents: false,
inPass: 0b0000,
outPass: 0b0000
};
} else {
if (legacy.noPass) {
return {
onlyEvents: true,
inPass: 0b0000,
outPass: 0b1111
};
} else if (legacy.cannotIn && legacy.cannotOut) {
let inPass = 0b1111;
let outPass = 0b1111;
if (legacy.cannotIn.includes('up')) {
inPass &= ~PassBit.Up;
}
if (legacy.cannotIn.includes('right')) {
inPass &= ~PassBit.Right;
}
if (legacy.cannotIn.includes('down')) {
inPass &= ~PassBit.Down;
}
if (legacy.cannotIn.includes('left')) {
inPass &= ~PassBit.Left;
}
if (legacy.cannotOut.includes('up')) {
outPass &= ~PassBit.Up;
}
if (legacy.cannotOut.includes('right')) {
outPass &= ~PassBit.Right;
}
if (legacy.cannotOut.includes('down')) {
outPass &= ~PassBit.Down;
}
if (legacy.cannotOut.includes('left')) {
outPass &= ~PassBit.Left;
}
return {
onlyEvents: false,
inPass,
outPass
};
} else {
return {
onlyEvents: true,
inPass: 0b1111,
outPass: 0b1111
};
}
}
}
fromLegacy(num: number, legacy: LegacyTileData): ITileRawData {
return {
num,
id: legacy.id,
trigger: -1,
type: this.getTileType(num, legacy),
pass: this.getPass(num, legacy)
};
}
}