feat: Implement IsometricMap & refactor TileMap with some perf boosts (#2254)
Roadmap related
This PR implements Isometric TileMap support with a separate `IsometricMap` type. Individual tiles are implemented as individual entities to support unique sorting to preserve the 2.5D illusion. `IsometricEntityComponent` flags tiles as isometric and are processed by `IsometricEntitySystem` to update the z-index according to the elevation and y coordinate.
<img width="178" alt="image" src="https://user-images.githubusercontent.com/612071/154827957-4ca1d753-12a6-4a5c-8c1f-5205aa632162.png">
The isometric tiles are drawn from the bottom by default (can be configured to draw from top) to mirror how Tiled renders tiles as well as to preserve the illusion of placing objects down on a grid.
- New `ex.IsometricMap` for drawing isometric grids! (They also support custom colliders via the same mechanism as `ex.TileMap`)
```typescript
new ex.IsometricMap({
pos: ex.vec(250, 10),
tileWidth: 32,
tileHeight: 16,
width: 15,
height: 15
});
```
- `ex.IsometricTile` now come with a `ex.IsometricEntityComponent` which can be applied to any entity that needs to be correctly sorted to preserve the isometric illusion
- `ex.IsometricEntitySystem` generates a new z-index based on the `elevation` and y position of an entity with `ex.IsometricEntityComponent`
TileMaps also have some changes, notably custom colliders!
```typescript
const tileMap = new ex.TileMap(...);
const tile = tileMap.getTile(0, 0);
tile.solid = true;
tile.addCollider(...); // add your custom collider!
```
This will work with the Tiled plugin to allow custom colliders
<img width="158" alt="image" src="https://user-images.githubusercontent.com/612071/154827872-30f30c34-ca64-49b1-9257-a74df2c4fe57.png">
## Changes:
- Refactored and breaking changes to `TileMap`
- New `IsometricMap`
- New `IsometricEntityComponent`
- New `IsometricEntityComponent`
- New `OffscreenSystem` to handle offscreen tagging
- Performance enhancements to help enable larger maps
- Cache sorted transforms in GraphicSystem
- Improve Camera Transform performance
authored by
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.
This is a binary file and will not be displayed.