fix: ECS size change

This commit is contained in:
cha0s 2024-07-23 17:03:12 -05:00
parent df0e012338
commit c27ab133a9

View File

@ -12,8 +12,27 @@ import {CHUNK_SIZE, RESOLUTION} from '@/util/constants.js';
import {deferredLighting} from './lights.js'; import {deferredLighting} from './lights.js';
const TileLayerInternal = PixiComponent('TileLayer', { const TileLayerInternal = PixiComponent('TileLayer', {
create: ({group, tileLayer}) => { create: () => {
const container = new Container(); const container = new Container();
return container;
},
applyProps: (container, {tileLayer: oldTileLayer}, props) => {
const {asset, group, renderer, tileLayer} = props;
const extless = tileLayer.source.slice('/assets/'.length, -'.json'.length);
const {textures} = asset;
if (tileLayer === oldTileLayer) {
return;
}
if (
!oldTileLayer
|| (
oldTileLayer.area.x !== tileLayer.area.x
|| oldTileLayer.area.y !== tileLayer.area.y
|| oldTileLayer.tileSize.x !== tileLayer.tileSize.x
|| oldTileLayer.tileSize.y !== tileLayer.tileSize.y
)
) {
container.removeChildren();
const {area, tileSize} = tileLayer; const {area, tileSize} = tileLayer;
const g = new Graphics(); const g = new Graphics();
g.beginFill(group === deferredLighting.diffuseGroup ? 0x000000 : 0x7777ff); g.beginFill(group === deferredLighting.diffuseGroup ? 0x000000 : 0x7777ff);
@ -61,14 +80,6 @@ const TileLayerInternal = PixiComponent('TileLayer', {
container.addChild(sprite); container.addChild(sprite);
} }
} }
return container;
},
applyProps: (container, {tileLayer: oldTileLayer}, props) => {
const {asset, group, renderer, tileLayer} = props;
const extless = tileLayer.source.slice('/assets/'.length, -'.json'.length);
const {textures} = asset;
if (tileLayer === oldTileLayer) {
return;
} }
for (const i in tileLayer.$$chunks) { for (const i in tileLayer.$$chunks) {
if (!oldTileLayer || oldTileLayer.$$chunks[i] !== tileLayer.$$chunks[i]) { if (!oldTileLayer || oldTileLayer.$$chunks[i] !== tileLayer.$$chunks[i]) {