fix(08-05): expose MapTileBase.restoreDefaultEvents and use it in toStatic

- MapTileBase.restoreDefaultEvents: protected -> public; declare on ITileBase with jsDoc

- MapLayer.toStatic(keepEvent=false): reset reused static tile via restoreDefaultEvents() instead of loadState({})
This commit is contained in:
unanmed 2026-10-05 16:34:18 +08:00
parent 0d41abdaf6
commit 58def1809d
3 changed files with 7 additions and 2 deletions

View File

@ -383,7 +383,7 @@ export class MapLayer
staticTile.syncTileEvent(tile);
} else {
// 不保留事件时,将复用的静态图块重置为默认事件
staticTile.loadState({});
staticTile.restoreDefaultEvents();
}
this.removeDynamic(tile, tile.x, tile.y);
this.forEachHook(hook => hook.onDeleteDynamic?.(tile));

View File

@ -43,7 +43,7 @@ export abstract class MapTileBase<TSave extends IMapBlockSaveBase>
/**
* 根据当前图块原始数据恢复默认事件并建立干净基准
*/
protected restoreDefaultEvents(): void {
restoreDefaultEvents(): void {
const eventView = this.tileEvent();
eventView.clear();
const data = this.raw();

View File

@ -139,6 +139,11 @@ export interface ITileBase extends IReadonlyTileBase {
* @param origin 要从哪个图块复制
*/
syncTileEvent(origin: IReadonlyTileBase): void;
/**
* 根据当前图块原始数据恢复默认事件并建立干净基准
*/
restoreDefaultEvents(): void;
}
export interface IStaticTile