46 lines
893 B
JavaScript
46 lines
893 B
JavaScript
import {expect, test} from 'vitest';
|
|
|
|
import Ecs from '@/ecs/ecs.js';
|
|
|
|
import TileLayers from './tile-layers.js';
|
|
|
|
test('creates hulls', async () => {
|
|
const Component = new TileLayers(new Ecs());
|
|
const data = Array(64).fill(0);
|
|
data[9] = 1;
|
|
data[10] = 1;
|
|
data[17] = 1;
|
|
data[18] = 1;
|
|
const layers = await Component.create(1, {
|
|
layers: [
|
|
{
|
|
area: {x: 8, y: 8},
|
|
data,
|
|
source: '',
|
|
tileSize: {x: 16, y: 16},
|
|
}
|
|
],
|
|
});
|
|
expect(layers.layer(0).hulls)
|
|
.to.deep.equal([
|
|
[
|
|
{x: 20, y: 20},
|
|
{x: 44, y: 20},
|
|
{x: 44, y: 44},
|
|
{x: 20, y: 44},
|
|
]
|
|
]);
|
|
data[11] = 1;
|
|
expect(layers.layer(0).hulls)
|
|
.to.deep.equal([
|
|
[
|
|
{x: 20, y: 20},
|
|
{x: 60, y: 20},
|
|
{x: 60, y: 28},
|
|
{x: 44, y: 28},
|
|
{x: 44, y: 44},
|
|
{x: 20, y: 44},
|
|
]
|
|
]);
|
|
});
|