mirror of
https://github.com/4ian/GDevelop.git
synced 2026-10-12 02:01:17 +00:00
Improve tile map collision precision (#6895)
This commit is contained in:
@@ -96,6 +96,16 @@ namespace gdjs {
|
||||
(this._transformationUpToDateCount + 1) % Number.MAX_SAFE_INTEGER;
|
||||
}
|
||||
|
||||
invalidateTile(layerIndex: integer, x: integer, y: integer) {
|
||||
const layer = this.getLayer(layerIndex);
|
||||
if (layer) {
|
||||
const tile = layer.get(x, y);
|
||||
if (tile) {
|
||||
tile.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The tile map width in pixels.
|
||||
*/
|
||||
@@ -690,6 +700,28 @@ namespace gdjs {
|
||||
this.affineTransformationUpToDateCount = this.layer.tileMap._transformationUpToDateCount;
|
||||
}
|
||||
|
||||
invalidate() {
|
||||
this.affineTransformationUpToDateCount = -1;
|
||||
// Also invalidate neighbors because their hit boxes may need to be
|
||||
// extended differently.
|
||||
let neighbor = this.layer.get(this.x - 1, this.y);
|
||||
if (neighbor) {
|
||||
neighbor.affineTransformationUpToDateCount = -1;
|
||||
}
|
||||
neighbor = this.layer.get(this.x + 1, this.y);
|
||||
if (neighbor) {
|
||||
neighbor.affineTransformationUpToDateCount = -1;
|
||||
}
|
||||
neighbor = this.layer.get(this.x, this.y - 1);
|
||||
if (neighbor) {
|
||||
neighbor.affineTransformationUpToDateCount = -1;
|
||||
}
|
||||
neighbor = this.layer.get(this.x, this.y + 1);
|
||||
if (neighbor) {
|
||||
neighbor.affineTransformationUpToDateCount = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The hitboxes of this tile in the scene basis.
|
||||
*/
|
||||
@@ -701,7 +733,6 @@ namespace gdjs {
|
||||
const definition = this.getDefinition();
|
||||
if (!definition) {
|
||||
this._setHitboxesUpToDate();
|
||||
// It should already be []
|
||||
this.hitBoxes.length = 0;
|
||||
return this.hitBoxes;
|
||||
}
|
||||
@@ -709,14 +740,100 @@ namespace gdjs {
|
||||
const definitionHitboxes = definition.getHitBoxes(tag);
|
||||
if (!definitionHitboxes) {
|
||||
this._setHitboxesUpToDate();
|
||||
// It should already be []
|
||||
this.hitBoxes.length = 0;
|
||||
return this.hitBoxes;
|
||||
}
|
||||
|
||||
const layerTransformation = this.layer.tileMap.getTransformation();
|
||||
const width = this.layer.tileMap.getTileWidth();
|
||||
const height = this.layer.tileMap.getTileHeight();
|
||||
const tileMap = this.layer.tileMap;
|
||||
const width = tileMap.getTileWidth();
|
||||
const height = tileMap.getTileHeight();
|
||||
|
||||
// Extend the hit boxes.
|
||||
// It avoids small objects to be pushed side way into a wall when they
|
||||
// should be pop out of the wall.
|
||||
|
||||
const hasFullHitBox =
|
||||
definitionHitboxes.length === 1 && definition.hasFullHitBox(tag);
|
||||
if (hasFullHitBox) {
|
||||
const isLeftFull = this._hasNeighborFullHitBox(-1, 0);
|
||||
const isRightFull = this._hasNeighborFullHitBox(1, 0);
|
||||
const isTopFull = this._hasNeighborFullHitBox(0, -1);
|
||||
const isBottomFull = this._hasNeighborFullHitBox(0, 1);
|
||||
|
||||
let hitBoxesCount = 0;
|
||||
if (isLeftFull || isRightFull) {
|
||||
let minX = isLeftFull ? -width : 0;
|
||||
let maxX = isRightFull ? 2 * width : width;
|
||||
if (hitBoxesCount >= this.hitBoxes.length) {
|
||||
this.hitBoxes[hitBoxesCount] = gdjs.Polygon.createRectangle(0, 0);
|
||||
}
|
||||
TransformedCollisionTile.setRectangle(
|
||||
this.hitBoxes[hitBoxesCount],
|
||||
minX,
|
||||
0,
|
||||
maxX,
|
||||
height
|
||||
);
|
||||
hitBoxesCount++;
|
||||
}
|
||||
if (isTopFull || isBottomFull) {
|
||||
let minY = isTopFull ? -height : 0;
|
||||
let maxY = isBottomFull ? 2 * height : height;
|
||||
if (hitBoxesCount >= this.hitBoxes.length) {
|
||||
this.hitBoxes[hitBoxesCount] = gdjs.Polygon.createRectangle(0, 0);
|
||||
}
|
||||
TransformedCollisionTile.setRectangle(
|
||||
this.hitBoxes[hitBoxesCount],
|
||||
0,
|
||||
minY,
|
||||
width,
|
||||
maxY
|
||||
);
|
||||
hitBoxesCount++;
|
||||
}
|
||||
if (hitBoxesCount === 0) {
|
||||
if (this.hitBoxes.length === 0) {
|
||||
this.hitBoxes[0] = gdjs.Polygon.createRectangle(0, 0);
|
||||
}
|
||||
TransformedCollisionTile.setRectangle(
|
||||
this.hitBoxes[0],
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height
|
||||
);
|
||||
hitBoxesCount++;
|
||||
}
|
||||
this.hitBoxes.length = hitBoxesCount;
|
||||
} else {
|
||||
for (
|
||||
let polygonIndex = 0;
|
||||
polygonIndex < definitionHitboxes.length;
|
||||
polygonIndex++
|
||||
) {
|
||||
const defPolygon = definitionHitboxes[polygonIndex];
|
||||
if (polygonIndex >= this.hitBoxes.length) {
|
||||
// This can't happen in practice as only the simple tile map can be
|
||||
// modify and it only contains full hit boxes.
|
||||
this.hitBoxes[polygonIndex] = gdjs.Polygon.createRectangle(0, 0);
|
||||
}
|
||||
const polygon = this.hitBoxes[polygonIndex];
|
||||
|
||||
for (
|
||||
let vertexIndex = 0;
|
||||
vertexIndex < polygon.vertices.length;
|
||||
vertexIndex++
|
||||
) {
|
||||
const defVertex = defPolygon[vertexIndex];
|
||||
const vertex = polygon.vertices[vertexIndex];
|
||||
|
||||
vertex[0] = defVertex[0];
|
||||
vertex[1] = defVertex[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Transform the hit boxes.
|
||||
|
||||
const tileTransformation =
|
||||
TransformedCollisionTile.workingTransformation;
|
||||
@@ -731,16 +848,12 @@ namespace gdjs {
|
||||
tileTransformation.flipX(width / 2);
|
||||
tileTransformation.rotateAround(Math.PI / 2, width / 2, height / 2);
|
||||
}
|
||||
tileTransformation.preConcatenate(layerTransformation);
|
||||
|
||||
// The tile map can't change at runtime so the existing arrays can be
|
||||
// reused safely.
|
||||
tileTransformation.preConcatenate(tileMap.getTransformation());
|
||||
for (
|
||||
let polygonIndex = 0;
|
||||
polygonIndex < this.hitBoxes.length;
|
||||
polygonIndex++
|
||||
) {
|
||||
const defPolygon = definitionHitboxes[polygonIndex];
|
||||
const polygon = this.hitBoxes[polygonIndex];
|
||||
|
||||
for (
|
||||
@@ -748,15 +861,42 @@ namespace gdjs {
|
||||
vertexIndex < polygon.vertices.length;
|
||||
vertexIndex++
|
||||
) {
|
||||
const defVertex = defPolygon[vertexIndex];
|
||||
const vertex = polygon.vertices[vertexIndex];
|
||||
|
||||
tileTransformation.transform(defVertex, vertex);
|
||||
tileTransformation.transform(vertex, vertex);
|
||||
}
|
||||
}
|
||||
this._setHitboxesUpToDate();
|
||||
return this.hitBoxes;
|
||||
}
|
||||
|
||||
private _hasNeighborFullHitBox(deltaX: integer, deltaY: integer) {
|
||||
const sourceLayer = this.layer._source;
|
||||
const tileId = sourceLayer.getTileId(this.x + deltaX, this.y + deltaY);
|
||||
const tileDefinition =
|
||||
tileId && this.layer.tileMap.getTileDefinition(tileId);
|
||||
return (
|
||||
tileDefinition && tileDefinition.hasFullHitBox(this.layer.tileMap.tag)
|
||||
);
|
||||
}
|
||||
|
||||
private static setRectangle(
|
||||
polygon: gdjs.Polygon,
|
||||
minX: float,
|
||||
minY: float,
|
||||
maxX: float,
|
||||
maxY: float
|
||||
) {
|
||||
const vertices = polygon.vertices;
|
||||
vertices[0][0] = minX;
|
||||
vertices[0][1] = minY;
|
||||
vertices[1][0] = maxX;
|
||||
vertices[1][1] = minY;
|
||||
vertices[2][0] = maxX;
|
||||
vertices[2][1] = maxY;
|
||||
vertices[3][0] = minX;
|
||||
vertices[3][1] = maxY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
import { LDtkTileMap } from '../load/ldtk/LDtkFormat';
|
||||
import { TiledTileMap } from '../load/tiled/TiledFormat';
|
||||
export type TileMapFileContent =
|
||||
export declare type TileMapFileContent =
|
||||
| {
|
||||
kind: 'tiled';
|
||||
data: TiledTileMap;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapFileContent.d.ts","sourceRoot":"","sources":["../../src/load/TileMapFileContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAC1B;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
||||
{"version":3,"file":"TileMapFileContent.d.ts","sourceRoot":"","sources":["../../src/load/TileMapFileContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,oBAAY,kBAAkB,GAC1B;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
||||
+24
-24
@@ -2,7 +2,7 @@ import { integer } from '../../model/CommonTypes';
|
||||
/**
|
||||
* version 1.1.3 - https://github.com/deepnight/ldtk/blob/66fff7199932357f3ab9b044c2fc2a856f527831/docs/JSON_SCHEMA.json
|
||||
*/
|
||||
export type LDtkTileMap = {
|
||||
export declare type LDtkTileMap = {
|
||||
/** LDtk application build identifier.<br/> This is only used to identify the LDtk version that generated this particular project file, which can be useful for specific bug fixing. Note that the build identifier is just the date of the release, so it's not unique to each user (one single global ID per LDtk public release), and as a result, completely anonymous. */
|
||||
appBuildId: number;
|
||||
/** Number of backup files to keep, if the `backupOnSave` is TRUE */
|
||||
@@ -72,7 +72,7 @@ export type LDtkTileMap = {
|
||||
| null;
|
||||
};
|
||||
/** Auto-layer rule group */
|
||||
type LDtkAutoLayerRuleGroup = {
|
||||
declare type LDtkAutoLayerRuleGroup = {
|
||||
/** */
|
||||
active: boolean;
|
||||
/** *This field was removed in 1.0.0 and should no longer be used.* */
|
||||
@@ -87,9 +87,9 @@ type LDtkAutoLayerRuleGroup = {
|
||||
uid: integer;
|
||||
};
|
||||
/** This complex section isn't meant to be used by game devs at all, as these rules are completely resolved internally by the editor before any saving. You should just ignore this part. */
|
||||
type LDtkAutoRuleDef = {};
|
||||
declare type LDtkAutoRuleDef = {};
|
||||
/** If you're writing your own LDtk importer, you should probably just ignore *most* stuff in the `defs` section, as it contains data that are mostly important to the editor. To keep you away from the `defs` section and avoid some unnecessary JSON parsing, important data from definitions is often duplicated in fields prefixed with a double underscore (eg. `__identifier` or `__type`). The 2 only definition types you might need here are **Tilesets** and **Enums**. */
|
||||
type LDtkDefinition = {
|
||||
declare type LDtkDefinition = {
|
||||
/** All entities definitions, including their custom fields */
|
||||
entities: LDtkEntityDef[];
|
||||
/** All internal enums */
|
||||
@@ -104,7 +104,7 @@ type LDtkDefinition = {
|
||||
tilesets: LDtkTilesetDef[];
|
||||
};
|
||||
/** Entity definition */
|
||||
type LDtkEntityDef = {
|
||||
declare type LDtkEntityDef = {
|
||||
/** Base entity color */
|
||||
color: string;
|
||||
/** Array of field definitions */
|
||||
@@ -166,7 +166,7 @@ type LDtkEntityDef = {
|
||||
width: integer;
|
||||
};
|
||||
/** Entity instance */
|
||||
type LDtkEntityInstance = {
|
||||
declare type LDtkEntityInstance = {
|
||||
/** Grid-based coordinates (`[x,y]` format) */
|
||||
__grid: integer[];
|
||||
/** Entity definition identifier */
|
||||
@@ -193,7 +193,7 @@ type LDtkEntityInstance = {
|
||||
width: integer;
|
||||
};
|
||||
/** Enum definition */
|
||||
type LDtkEnumDef = {
|
||||
declare type LDtkEnumDef = {
|
||||
/** */
|
||||
externalFileChecksum: string | null;
|
||||
/** Relative path to the external file providing this Enum */
|
||||
@@ -210,7 +210,7 @@ type LDtkEnumDef = {
|
||||
values: LDtkEnumDefValues[];
|
||||
};
|
||||
/** Enum value definition */
|
||||
type LDtkEnumDefValues = {
|
||||
declare type LDtkEnumDefValues = {
|
||||
/** An array of 4 Int values that refers to the tile in the tileset image: `[ x, y, width, height ]` */
|
||||
__tileSrcRect: integer[] | null;
|
||||
/** Optional color */
|
||||
@@ -221,14 +221,14 @@ type LDtkEnumDefValues = {
|
||||
tileId: integer | null;
|
||||
};
|
||||
/** In a tileset definition, enum based tag infos */
|
||||
type LDtkEnumTagValue = {
|
||||
declare type LDtkEnumTagValue = {
|
||||
/** */
|
||||
enumValueId: string;
|
||||
/** */
|
||||
tileIds: integer[];
|
||||
};
|
||||
/** This section is mostly only intended for the LDtk editor app itself. You can safely ignore it. */
|
||||
type LDtkFieldDef = {
|
||||
declare type LDtkFieldDef = {
|
||||
/** Human readable value type. Possible values: `Int, Float, String, Bool, Color, ExternEnum.XXX, LocalEnum.XXX, Point, FilePath`.<br/> If the field is an array, this field will look like `Array<...>` (eg. `Array<Int>`, `Array<Point>` etc.)<br/> NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */
|
||||
__type: string;
|
||||
/** Optional list of accepted file extensions for FilePath value type. Includes the dot: `.ext` */
|
||||
@@ -310,7 +310,7 @@ type LDtkFieldDef = {
|
||||
useForSmartColor: boolean;
|
||||
};
|
||||
/** Field instance */
|
||||
type LDtkFieldInstance = {
|
||||
declare type LDtkFieldInstance = {
|
||||
/** Field definition identifier */
|
||||
__identifier: string;
|
||||
/** Optional TilesetRect used to display this field (this can be the field own Tile, or some other Tile guessed from the value, like an Enum). */
|
||||
@@ -324,7 +324,7 @@ type LDtkFieldInstance = {
|
||||
/** Editor internal raw values */
|
||||
realEditorValues: any[];
|
||||
};
|
||||
type LDtkFlag =
|
||||
declare type LDtkFlag =
|
||||
| 'DiscardPreCsvIntGrid'
|
||||
| 'ExportPreCsvIntGridFormat'
|
||||
| 'IgnoreBackupSuggest'
|
||||
@@ -332,7 +332,7 @@ type LDtkFlag =
|
||||
| 'MultiWorlds'
|
||||
| 'UseMultilinesType';
|
||||
/** IntGrid value definition */
|
||||
type LDtkIntGridValueDef = {
|
||||
declare type LDtkIntGridValueDef = {
|
||||
/** */
|
||||
color: string;
|
||||
/** User defined unique identifier */
|
||||
@@ -341,14 +341,14 @@ type LDtkIntGridValueDef = {
|
||||
value: integer;
|
||||
};
|
||||
/** IntGrid value instance */
|
||||
type LDtkIntGridValueInstance = {
|
||||
declare type LDtkIntGridValueInstance = {
|
||||
/** Coordinate ID in the layer grid */
|
||||
coordId: integer;
|
||||
/** IntGrid value */
|
||||
v: integer;
|
||||
};
|
||||
/** Layer definition */
|
||||
type LDtkLayerDef = {
|
||||
declare type LDtkLayerDef = {
|
||||
/** Type of the layer (*IntGrid, Entities, Tiles or AutoLayer*) */
|
||||
__type: string;
|
||||
/** Contains all the auto-layer rule definitions. */
|
||||
@@ -401,7 +401,7 @@ type LDtkLayerDef = {
|
||||
uid: integer;
|
||||
};
|
||||
/** Layer instance */
|
||||
type LDtkLayerInstance = {
|
||||
declare type LDtkLayerInstance = {
|
||||
/** Grid-based height */
|
||||
__cHei: integer;
|
||||
/** Grid-based width */
|
||||
@@ -452,7 +452,7 @@ type LDtkLayerInstance = {
|
||||
visible: boolean;
|
||||
};
|
||||
/** This section contains all the level data. It can be found in 2 distinct forms, depending on Project current settings: - If \"*Separate level files*\" is **disabled** (default): full level data is *embedded* inside the main Project JSON file, - If \"*Separate level files*\" is **enabled**: level data is stored in *separate* standalone `.ldtkl` files (one per level). In this case, the main Project JSON file will still contain most level data, except heavy sections, like the `layerInstances` array (which will be null). The `externalRelPath` string points to the `ldtkl` file. A `ldtkl` file is just a JSON file containing exactly what is described below. */
|
||||
type LDtkLevel = {
|
||||
declare type LDtkLevel = {
|
||||
/** Background color of the level (same as `bgColor`, except the default value is automatically used here if its value is `null`) */
|
||||
__bgColor: string;
|
||||
/** Position informations of the background image, if there is one. */
|
||||
@@ -497,7 +497,7 @@ type LDtkLevel = {
|
||||
worldY: integer;
|
||||
};
|
||||
/** Level background image position info */
|
||||
type LDtkLevelBgPosInfos = {
|
||||
declare type LDtkLevelBgPosInfos = {
|
||||
/** An array of 4 float values describing the cropped sub-rectangle of the displayed background image. This cropping happens when original is larger than the level bounds. Array format: `[ cropX, cropY, cropWidth, cropHeight ]` */
|
||||
cropRect: number[];
|
||||
/** An array containing the `[scaleX,scaleY]` values of the **cropped** background image, depending on `bgPos` option. */
|
||||
@@ -506,7 +506,7 @@ type LDtkLevelBgPosInfos = {
|
||||
topLeftPx: integer[];
|
||||
};
|
||||
/** Nearby level info */
|
||||
type LDtkNeighbourLevel = {
|
||||
declare type LDtkNeighbourLevel = {
|
||||
/** A single lowercase character tipping on the level location (`n`orth, `s`outh, `w`est, `e`ast). */
|
||||
dir: string;
|
||||
/** Neighbour Instance Identifier */
|
||||
@@ -515,7 +515,7 @@ type LDtkNeighbourLevel = {
|
||||
levelUid: integer;
|
||||
};
|
||||
/** This structure represents a single tile from a given Tileset. */
|
||||
type LDtkTile = {
|
||||
declare type LDtkTile = {
|
||||
/** Internal data used by the editor.<br/> For auto-layer tiles: `[ruleId, coordId]`.<br/> For tile-layer tiles: `[coordId]`. */
|
||||
d: integer[];
|
||||
/** \"Flip bits\", a 2-bits integer to represent the mirror transformations of the tile.<br/> - Bit 0 = X flip<br/> - Bit 1 = Y flip<br/> Examples: f=0 (no flip), f=1 (X flip only), f=2 (Y flip only), f=3 (both flips) */
|
||||
@@ -528,7 +528,7 @@ type LDtkTile = {
|
||||
t: integer;
|
||||
};
|
||||
/** The `Tileset` definition is the most important part among project definitions. It contains some extra informations about each integrated tileset. If you only had to parse one definition section, that would be the one. */
|
||||
export type LDtkTilesetDef = {
|
||||
export declare type LDtkTilesetDef = {
|
||||
/** Grid-based height */
|
||||
__cHei: integer;
|
||||
/** Grid-based width */
|
||||
@@ -565,14 +565,14 @@ export type LDtkTilesetDef = {
|
||||
uid: integer;
|
||||
};
|
||||
/** In a tileset definition, user defined meta-data of a tile. */
|
||||
type LDtkTileCustomMetadata = {
|
||||
declare type LDtkTileCustomMetadata = {
|
||||
/** */
|
||||
data: string;
|
||||
/** */
|
||||
tileId: integer;
|
||||
};
|
||||
/** This object represents a custom sub rectangle in a Tileset image. */
|
||||
type LDtkTilesetRect = {
|
||||
declare type LDtkTilesetRect = {
|
||||
/** Height in pixels */
|
||||
h: integer;
|
||||
/** UID of the tileset */
|
||||
@@ -584,6 +584,6 @@ type LDtkTilesetRect = {
|
||||
/** Y pixels coordinate of the top-left corner in the Tileset image */
|
||||
y: integer;
|
||||
};
|
||||
type LDtkWorld = {};
|
||||
declare type LDtkWorld = {};
|
||||
export {};
|
||||
//# sourceMappingURL=LDtkFormat.d.ts.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+18
-18
@@ -2,7 +2,7 @@ import { float, integer } from '../../model/CommonTypes';
|
||||
/**
|
||||
* Tiled JSON format (https://github.com/mapeditor/tiled/blob/master/docs/reference/json-map-format.rst).
|
||||
*/
|
||||
export type TiledTileMap = {
|
||||
export declare type TiledTileMap = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
|
||||
backgroundcolor?: string;
|
||||
/** The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default) */
|
||||
@@ -44,7 +44,7 @@ export type TiledTileMap = {
|
||||
/** Number of tile columns */
|
||||
width: integer;
|
||||
};
|
||||
export type TiledLayer = {
|
||||
export declare type TiledLayer = {
|
||||
/** Array of {@link TiledChunk} (optional). `tilelayer` only. */
|
||||
chunks?: Array<TiledChunk>;
|
||||
/** `zlib`, `gzip`, `zstd` (since Tiled 1.3) or empty (default). `tilelayer` only. */
|
||||
@@ -98,7 +98,7 @@ export type TiledLayer = {
|
||||
/** Vertical layer offset in tiles. Always 0. */
|
||||
y: integer;
|
||||
};
|
||||
export type TiledChunk = {
|
||||
export declare type TiledChunk = {
|
||||
/** Array of `unsigned` `integer` (GIDs) or base64-encoded data */
|
||||
data: Array<integer> | string;
|
||||
/** Height in tiles */
|
||||
@@ -110,7 +110,7 @@ export type TiledChunk = {
|
||||
/** Y coordinate in tiles */
|
||||
y: integer;
|
||||
};
|
||||
export type TiledObject = {
|
||||
export declare type TiledObject = {
|
||||
/** The class of the object (was saved as class in 1.9, optional) */
|
||||
type?: string;
|
||||
/** The class of the object (used only in 1.9, optional) */
|
||||
@@ -148,7 +148,7 @@ export type TiledObject = {
|
||||
/** Y coordinate in pixels */
|
||||
y: float;
|
||||
};
|
||||
export type TiledText = {
|
||||
export declare type TiledText = {
|
||||
/** Whether to use a bold font (default: `false`) */
|
||||
bold: boolean;
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (default: `#000000`) */
|
||||
@@ -174,7 +174,7 @@ export type TiledText = {
|
||||
/** Whether the text is wrapped within the object bounds (default: `false`) */
|
||||
wrap: boolean;
|
||||
};
|
||||
export type TiledTileset = {
|
||||
export declare type TiledTileset = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
|
||||
backgroundcolor?: string;
|
||||
/** The number of tile columns in the tileset */
|
||||
@@ -226,7 +226,7 @@ export type TiledTileset = {
|
||||
/** Array of {@link TiledWangSet} (since 1.1.5) */
|
||||
wangsets?: Array<TiledWangSet>;
|
||||
};
|
||||
export type TiledGrid = {
|
||||
export declare type TiledGrid = {
|
||||
/** Cell height of tile grid */
|
||||
height: integer;
|
||||
/** `orthogonal` (default) or `isometric` */
|
||||
@@ -234,13 +234,13 @@ export type TiledGrid = {
|
||||
/** Cell width of tile grid */
|
||||
width: integer;
|
||||
};
|
||||
export type TileOffset = {
|
||||
export declare type TileOffset = {
|
||||
/** Horizontal offset in pixels */
|
||||
x: integer;
|
||||
/** Vertical offset in pixels (positive is down) */
|
||||
y: integer;
|
||||
};
|
||||
export type TiledTransformations = {
|
||||
export declare type TiledTransformations = {
|
||||
/** Tiles can be flipped horizontally */
|
||||
hflip: boolean;
|
||||
/** Tiles can be flipped vertically */
|
||||
@@ -250,7 +250,7 @@ export type TiledTransformations = {
|
||||
/** Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more variations */
|
||||
preferuntransformed: boolean;
|
||||
};
|
||||
export type TiledTileDefinition = {
|
||||
export declare type TiledTileDefinition = {
|
||||
/** Array of {@link TiledTiles} */
|
||||
animation?: Array<TiledTileDefinition>;
|
||||
/** The class of the object (was saved as class in 1.9, optional) */
|
||||
@@ -274,13 +274,13 @@ export type TiledTileDefinition = {
|
||||
/** Index of terrain for each corner of tile (optional) */
|
||||
terrain?: Array<integer>;
|
||||
};
|
||||
export type TiledFrame = {
|
||||
export declare type TiledFrame = {
|
||||
/** Frame duration in milliseconds */
|
||||
duration: integer;
|
||||
/** Local tile ID representing this frame */
|
||||
tileid: integer;
|
||||
};
|
||||
export type TiledTerrain = {
|
||||
export declare type TiledTerrain = {
|
||||
/** Name of terrain */
|
||||
name: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
@@ -288,7 +288,7 @@ export type TiledTerrain = {
|
||||
/** Local ID of tile representing terrain */
|
||||
tile: integer;
|
||||
};
|
||||
export type TiledWangSet = {
|
||||
export declare type TiledWangSet = {
|
||||
/** Array of {@link TiledWangColor} */
|
||||
colors: Array<TiledWangColor>;
|
||||
/** Name of the Wang set */
|
||||
@@ -300,7 +300,7 @@ export type TiledWangSet = {
|
||||
/** Array of {@link TiledWangTile} */
|
||||
wangtiles: Array<TiledWangTile>;
|
||||
};
|
||||
export type TiledWangColor = {
|
||||
export declare type TiledWangColor = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) */
|
||||
color: string;
|
||||
/** Name of the Wang color */
|
||||
@@ -312,13 +312,13 @@ export type TiledWangColor = {
|
||||
/** Local ID of tile representing the Wang color */
|
||||
tile: integer;
|
||||
};
|
||||
export type TiledWangTile = {
|
||||
export declare type TiledWangTile = {
|
||||
/** Local ID of tile */
|
||||
tileid: integer;
|
||||
/** Array of Wang color indexes (`uchar[8]`) */
|
||||
wangid: Array<integer>;
|
||||
};
|
||||
export type TiledObjectTemplate = {
|
||||
export declare type TiledObjectTemplate = {
|
||||
/** `template` */
|
||||
type: string;
|
||||
/** External tileset used by the template (optional) */
|
||||
@@ -326,7 +326,7 @@ export type TiledObjectTemplate = {
|
||||
/** The object instantiated by this template */
|
||||
object: Object;
|
||||
};
|
||||
export type TiledProperty = {
|
||||
export declare type TiledProperty = {
|
||||
/** Name of the property */
|
||||
name: string;
|
||||
/** type of the property (`string` (default), `integer`, `float`, `boolean`, `color` or `file` (since 0.16, with `color` and `file` added in 0.17)) */
|
||||
@@ -334,7 +334,7 @@ export type TiledProperty = {
|
||||
/** Value of the property */
|
||||
value: string | number;
|
||||
};
|
||||
export type TiledPoint = {
|
||||
export declare type TiledPoint = {
|
||||
/** X coordinate in pixels */
|
||||
x: float;
|
||||
/** Y coordinate in pixels */
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"version":3,"file":"TiledTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;GAEG;AACH,yBAAiB,kBAAkB,CAAC;IAClC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CA2KxB;CACF"}
|
||||
{"version":3,"file":"TiledTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;GAEG;AACH,yBAAiB,kBAAkB,CAAC;IAClC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CAkLxB;CACF"}
|
||||
@@ -12,7 +12,7 @@ export declare const decodeBase64LayerData: (
|
||||
pako: any,
|
||||
tiledLayer: TiledLayer
|
||||
) => number[];
|
||||
export type TiledGID = {
|
||||
export declare type TiledGID = {
|
||||
id: integer;
|
||||
flippedHorizontally: boolean;
|
||||
flippedVertically: boolean;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"TiledTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoaderHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,cAAc,UAAU,aAgDtE,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACvB,OAAO,KACrB,QAmBF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAEpB"}
|
||||
{"version":3,"file":"TiledTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoaderHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,cAAc,UAAU,aAgDtE,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACvB,OAAO,KACrB,QAmBF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAEpB"}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
export declare type integer = number;
|
||||
export declare type float = number;
|
||||
export type FloatPoint = [float, float];
|
||||
export type PolygonVertices = FloatPoint[];
|
||||
export type EditableTileMapLayerAsJsObject = {
|
||||
export declare type FloatPoint = [float, float];
|
||||
export declare type PolygonVertices = FloatPoint[];
|
||||
export declare type EditableTileMapLayerAsJsObject = {
|
||||
id: number;
|
||||
alpha: number;
|
||||
tiles: number[][];
|
||||
};
|
||||
export type EditableTileMapAsJsObject = {
|
||||
export declare type EditableTileMapAsJsObject = {
|
||||
tileWidth: number;
|
||||
tileHeight: number;
|
||||
dimX: number;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"CommonTypes.d.ts","sourceRoot":"","sources":["../../src/model/CommonTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,OAAO,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,UAAU,EAAE,CAAC;AAE3C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,8BAA8B,EAAE,CAAC;CAC1C,CAAC"}
|
||||
{"version":3,"file":"CommonTypes.d.ts","sourceRoot":"","sources":["../../src/model/CommonTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,OAAO,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,MAAM,CAAC;AACnC,oBAAY,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExC,oBAAY,eAAe,GAAG,UAAU,EAAE,CAAC;AAE3C,oBAAY,8BAA8B,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,8BAA8B,EAAE,CAAC;CAC1C,CAAC"}
|
||||
+12
-1
@@ -431,8 +431,13 @@ export declare class TileDefinition {
|
||||
* Add a polygon for the collision layer
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
* @param polygon The polygon to use for collisions.
|
||||
* @param hasFullHitBox Set to `true` when the hitBox cover the whole tile.
|
||||
*/
|
||||
addHitBox(tag: string, polygon: PolygonVertices): void;
|
||||
addHitBox(
|
||||
tag: string,
|
||||
polygon: PolygonVertices,
|
||||
hasFullHitBox: boolean
|
||||
): void;
|
||||
/**
|
||||
* This property is used by {@link TransformedCollisionTileMap}
|
||||
* to make collision classes.
|
||||
@@ -446,6 +451,12 @@ export declare class TileDefinition {
|
||||
* @returns The hit boxes for this tile.
|
||||
*/
|
||||
getHitBoxes(tag: string): PolygonVertices[] | undefined;
|
||||
/**
|
||||
* Return `true` if the hit-box cover the whole tile.
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
* @returns `true` if the hit-box cover the whole tile.
|
||||
*/
|
||||
hasFullHitBox(tag: string): boolean;
|
||||
/**
|
||||
* Animated tiles have a limitation:
|
||||
* they are only able to use frames arranged horizontally one next
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapManager.d.ts","sourceRoot":"","sources":["../../src/render/TileMapManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,mBAAmB,CAAkC;;IAO7D;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc;IAWzD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,kBAAkB,GAAG,IAAI;IAwBrD;;;;;;;OAOG;IACH,gBAAgB,CACd,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,KAC9D,IAAI,EACT,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,GAClD,IAAI;IAiCP,sBAAsB,CACpB,iBAAiB,EAAE,yBAAyB,EAC5C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,EAAE,MAAM,EAGvB,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAC3C,IAAI;IAeP;;;;;;;;OAQG;IACH,qBAAqB,CACnB,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,KAC9D,IAAI,EACT,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpE,sBAAsB,EAAE,MAAM,EAC9B,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;IAwCP;;;;;;;OAOG;IACH,kCAAkC,CAChC,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpE,sBAAsB,EAAE,MAAM,EAC9B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;IAqBP,WAAW,IAAI,IAAI;CAIpB"}
|
||||
{"version":3,"file":"TileMapManager.d.ts","sourceRoot":"","sources":["../../src/render/TileMapManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,mBAAmB,CAAkC;;IAO7D;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc;IAWzD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,kBAAkB,GAAG,IAAI;IAwBrD;;;;;;;OAOG;IACH,gBAAgB,CACd,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,KAC9D,IAAI,EACT,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,GAClD,IAAI;IAiCP,sBAAsB,CACpB,iBAAiB,EAAE,yBAAyB,EAC5C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,EAAE,MAAM,EAGvB,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAC3C,IAAI;IAYP;;;;;;;;OAQG;IACH,qBAAqB,CACnB,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,KAC9D,IAAI,EACT,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpE,sBAAsB,EAAE,MAAM,EAC9B,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;IAwCP;;;;;;;OAOG;IACH,kCAAkC,CAChC,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpE,sBAAsB,EAAE,MAAM,EAC9B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;IAqBP,WAAW,IAAI,IAAI;CAIpB"}
|
||||
@@ -1,7 +1,9 @@
|
||||
import { TileTextureCache } from '../TileTextureCache';
|
||||
import { LDtkTileMap } from '../../load/ldtk/LDtkFormat';
|
||||
type Texture = PIXI.BaseTexture<PIXI.Resource>;
|
||||
type TextureLoader = (textureName: string) => PIXI.BaseTexture<PIXI.Resource>;
|
||||
declare type Texture = PIXI.BaseTexture<PIXI.Resource>;
|
||||
declare type TextureLoader = (
|
||||
textureName: string
|
||||
) => PIXI.BaseTexture<PIXI.Resource>;
|
||||
export declare namespace LDtkPixiHelper {
|
||||
/**
|
||||
* Split an atlas image into Pixi textures.
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAGzE,KAAK,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAmC9E,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,UAAU,EAAE,aAAa,GACxB,gBAAgB,GAAG,IAAI,CAoFzB;CACF"}
|
||||
{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAGzE,aAAK,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,aAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAmC9E,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,UAAU,EAAE,aAAa,GACxB,gBAAgB,GAAG,IAAI,CAoFzB;CACF"}
|
||||
@@ -231,12 +231,16 @@ namespace gdjs {
|
||||
);
|
||||
return;
|
||||
}
|
||||
tileDefinition.addHitBox(this._hitBoxTag, [
|
||||
[0, 0],
|
||||
[0, tileMap.getTileHeight()],
|
||||
[tileMap.getTileWidth(), tileMap.getTileHeight()],
|
||||
[tileMap.getTileWidth(), 0],
|
||||
]);
|
||||
tileDefinition.addHitBox(
|
||||
this._hitBoxTag,
|
||||
[
|
||||
[0, 0],
|
||||
[0, tileMap.getTileHeight()],
|
||||
[tileMap.getTileWidth(), tileMap.getTileHeight()],
|
||||
[tileMap.getTileWidth(), 0],
|
||||
],
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
this._tileMapManager.getOrLoadSimpleTileMapTextureCache(
|
||||
@@ -624,7 +628,38 @@ namespace gdjs {
|
||||
columnIndex: integer,
|
||||
rowIndex: integer
|
||||
) {
|
||||
this._renderer.setTileId(columnIndex, rowIndex, 0, tileId);
|
||||
const tileMap = this._renderer._tileMap;
|
||||
if (!tileMap) {
|
||||
return;
|
||||
}
|
||||
const layer = tileMap.getTileLayer(this._layerIndex);
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
const oldTileId = layer.getTileId(columnIndex, rowIndex);
|
||||
if (tileId === oldTileId) {
|
||||
return;
|
||||
}
|
||||
layer.setTile(columnIndex, rowIndex, tileId);
|
||||
|
||||
if (this._collisionTileMap) {
|
||||
const oldTileDefinition =
|
||||
oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);
|
||||
const newTileDefinition = tileMap.getTileDefinition(tileId);
|
||||
const hadFullHitBox =
|
||||
!!oldTileDefinition &&
|
||||
oldTileDefinition.hasFullHitBox(this._hitBoxTag);
|
||||
const haveFullHitBox =
|
||||
!!newTileDefinition &&
|
||||
newTileDefinition.hasFullHitBox(this._hitBoxTag);
|
||||
if (hadFullHitBox !== haveFullHitBox) {
|
||||
this._collisionTileMap.invalidateTile(
|
||||
this._layerIndex,
|
||||
columnIndex,
|
||||
rowIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
this._isTileMapDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
@@ -702,7 +737,26 @@ namespace gdjs {
|
||||
}
|
||||
|
||||
removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {
|
||||
this._renderer.removeTile(columnIndex, rowIndex, 0);
|
||||
const tileMap = this._renderer._tileMap;
|
||||
if (!tileMap) {
|
||||
return;
|
||||
}
|
||||
const layer = tileMap.getTileLayer(this._layerIndex);
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
const oldTileId = layer.getTileId(columnIndex, rowIndex);
|
||||
if (oldTileId === undefined) {
|
||||
return;
|
||||
}
|
||||
layer.removeTile(columnIndex, rowIndex);
|
||||
if (this._collisionTileMap) {
|
||||
this._collisionTileMap.invalidateTile(
|
||||
this._layerIndex,
|
||||
columnIndex,
|
||||
rowIndex
|
||||
);
|
||||
}
|
||||
this._isTileMapDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace gdjs {
|
||||
private _object:
|
||||
| gdjs.TileMapRuntimeObject
|
||||
| gdjs.SimpleTileMapRuntimeObject;
|
||||
private _tileMap: TileMapHelper.EditableTileMap | null = null;
|
||||
// TODO Move this attribute in the object as it's a model.
|
||||
_tileMap: TileMapHelper.EditableTileMap | null = null;
|
||||
|
||||
private _pixiObject: PIXI.tilemap.CompositeTilemap;
|
||||
|
||||
@@ -173,18 +174,6 @@ namespace gdjs {
|
||||
return tileMap.getTileId(x, y, layerIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The layer column.
|
||||
* @param y The layer row.
|
||||
* @param layerIndex The layer index.
|
||||
* @param tileId The tile's id.
|
||||
*/
|
||||
setTileId(x: integer, y: integer, layerIndex: integer, tileId: number) {
|
||||
const tileMap = this._tileMap;
|
||||
if (!tileMap) return;
|
||||
return tileMap.setTile(x, y, layerIndex, tileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The layer column.
|
||||
* @param y The layer row.
|
||||
@@ -231,17 +220,6 @@ namespace gdjs {
|
||||
return tileMap.isTileFlippedOnY(x, y, layerIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The layer column.
|
||||
* @param y The layer row.
|
||||
* @param layerIndex The layer index.
|
||||
*/
|
||||
removeTile(x: integer, y: integer, layerIndex: integer) {
|
||||
const tileMap = this._tileMap;
|
||||
if (!tileMap) return;
|
||||
return tileMap.removeTile(x, y, layerIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetRowCount The number of rows to have.
|
||||
*/
|
||||
|
||||
@@ -75,7 +75,7 @@ export namespace LDtkTileMapLoader {
|
||||
gridSize,
|
||||
dimX,
|
||||
dimY,
|
||||
tileSet,
|
||||
tileSet
|
||||
);
|
||||
const composedTileMap = new Map<string, TileDefinition>();
|
||||
let nextComposedTileId = 0xfffffff;
|
||||
|
||||
@@ -51,6 +51,7 @@ export namespace TiledTileMapLoader {
|
||||
continue;
|
||||
}
|
||||
let polygon: PolygonVertices | null = null;
|
||||
let hasFullHitBox = false;
|
||||
if (object.polygon) {
|
||||
const angle = (object.rotation * Math.PI) / 180;
|
||||
let cos = Math.cos(angle);
|
||||
@@ -67,6 +68,7 @@ export namespace TiledTileMapLoader {
|
||||
object.y + point.x * sin + point.y * cos,
|
||||
]);
|
||||
//TODO check that polygons are convex or split them?
|
||||
// TODO Set hasFullHitBox to true if the polygon covers the whole tile.
|
||||
}
|
||||
// TODO handle ellipses by creating a polygon?
|
||||
// Make an object property for the number of vertices or always create 8 ones?
|
||||
@@ -83,9 +85,14 @@ export namespace TiledTileMapLoader {
|
||||
[object.x + object.width, object.y + object.height],
|
||||
[object.x + object.width, object.y],
|
||||
];
|
||||
hasFullHitBox =
|
||||
object.x === 0 &&
|
||||
object.y === 0 &&
|
||||
object.width === tiledTileMap.tilewidth &&
|
||||
object.height === tiledTileMap.tileheight;
|
||||
}
|
||||
if (polygon) {
|
||||
tileDefinition.addHitBox(tag, polygon);
|
||||
tileDefinition.addHitBox(tag, polygon, hasFullHitBox);
|
||||
}
|
||||
}
|
||||
} else if (tileClass) {
|
||||
@@ -96,7 +103,7 @@ export namespace TiledTileMapLoader {
|
||||
[tiledTileMap.tilewidth, tiledTileMap.tileheight],
|
||||
[tiledTileMap.tilewidth, 0],
|
||||
];
|
||||
tileDefinition.addHitBox(tileClass, polygon);
|
||||
tileDefinition.addHitBox(tileClass, polygon, true);
|
||||
}
|
||||
definitions.set(
|
||||
getTileIdFromTiledGUI(firstGid + tile.id),
|
||||
@@ -117,7 +124,7 @@ export namespace TiledTileMapLoader {
|
||||
tiledTileMap.tileheight,
|
||||
tiledTileMap.width,
|
||||
tiledTileMap.height,
|
||||
definitions,
|
||||
definitions
|
||||
);
|
||||
|
||||
for (const tiledLayer of tiledTileMap.layers) {
|
||||
|
||||
@@ -1056,6 +1056,7 @@ export class TileDefinition {
|
||||
private readonly taggedHitBoxes: {
|
||||
tag: string;
|
||||
polygons: PolygonVertices[];
|
||||
hasFullHitBox: boolean;
|
||||
}[];
|
||||
private readonly animationLength: integer;
|
||||
|
||||
@@ -1078,13 +1079,19 @@ export class TileDefinition {
|
||||
* Add a polygon for the collision layer
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
* @param polygon The polygon to use for collisions.
|
||||
* @param hasFullHitBox Set to `true` when the hitBox cover the whole tile.
|
||||
*/
|
||||
addHitBox(tag: string, polygon: PolygonVertices): void {
|
||||
addHitBox(
|
||||
tag: string,
|
||||
polygon: PolygonVertices,
|
||||
hasFullHitBox: boolean
|
||||
): void {
|
||||
let taggedHitBox = this.taggedHitBoxes.find((hitbox) => hitbox.tag === tag);
|
||||
if (!taggedHitBox) {
|
||||
taggedHitBox = { tag, polygons: [] };
|
||||
taggedHitBox = { tag, polygons: [], hasFullHitBox: false };
|
||||
this.taggedHitBoxes.push(taggedHitBox);
|
||||
}
|
||||
taggedHitBox.hasFullHitBox ||= hasFullHitBox;
|
||||
taggedHitBox.polygons.push(polygon);
|
||||
}
|
||||
|
||||
@@ -1110,6 +1117,18 @@ export class TileDefinition {
|
||||
return taggedHitBox && taggedHitBox.polygons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return `true` if the hit-box cover the whole tile.
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
* @returns `true` if the hit-box cover the whole tile.
|
||||
*/
|
||||
hasFullHitBox(tag: string): boolean {
|
||||
const taggedHitBox = this.taggedHitBoxes.find(
|
||||
(hitbox) => hitbox.tag === tag
|
||||
);
|
||||
return taggedHitBox && taggedHitBox.hasFullHitBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Animated tiles have a limitation:
|
||||
* they are only able to use frames arranged horizontally one next
|
||||
|
||||
@@ -131,14 +131,11 @@ export class TileMapManager {
|
||||
// TODO: Is it useful to cache the tilemap since it belongs to an instance?
|
||||
// const key = `${objectName}|${tileSize}|${tileSetColumnCount}|${tileSetRowCount}`;
|
||||
|
||||
const editableTileMap = EditableTileMap.from(
|
||||
tileMapAsJsObject,
|
||||
{
|
||||
tileSize,
|
||||
tileSetColumnCount,
|
||||
tileSetRowCount,
|
||||
},
|
||||
);
|
||||
const editableTileMap = EditableTileMap.from(tileMapAsJsObject, {
|
||||
tileSize,
|
||||
tileSetColumnCount,
|
||||
tileSetRowCount,
|
||||
});
|
||||
callback(editableTileMap);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user