mirror of
https://github.com/motajs/template.git
synced 2026-10-21 23:00:29 +08:00
refactor: data-common/common
This commit is contained in:
parent
9fb04e3129
commit
1fb92c3976
@ -1,4 +1,3 @@
|
|||||||
import { isNil } from 'lodash-es';
|
|
||||||
import {
|
import {
|
||||||
FaceDirection,
|
FaceDirection,
|
||||||
IMoverController,
|
IMoverController,
|
||||||
@ -76,12 +75,7 @@ export class DynamicTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentFaceDirection(): FaceDirection {
|
getCurrentFaceDirection(): FaceDirection {
|
||||||
const curr = this.layer.faceBinder.getFaceDirection(this.tileNum);
|
return this.layer.faceBinder.getFaceDirection(this.tileNum);
|
||||||
if (isNil(curr)) {
|
|
||||||
return FaceDirection.Unknown;
|
|
||||||
} else {
|
|
||||||
return curr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@shouldReplay('Transfering dynamic tile to static should be replayed.')
|
@shouldReplay('Transfering dynamic tile to static should be replayed.')
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import {
|
|||||||
} from './types';
|
} from './types';
|
||||||
import { Hookable, HookController, ITileLocator, logger } from '@motajs/common';
|
import { Hookable, HookController, ITileLocator, logger } from '@motajs/common';
|
||||||
import {
|
import {
|
||||||
degradeFace,
|
|
||||||
FaceDirection,
|
FaceDirection,
|
||||||
IDataCommon,
|
IDataCommon,
|
||||||
IRoleFaceBinder,
|
IRoleFaceBinder,
|
||||||
@ -525,14 +524,7 @@ export class MapLayer
|
|||||||
|
|
||||||
@shouldReplay('Setting map layer block direction should be replayed.')
|
@shouldReplay('Setting map layer block direction should be replayed.')
|
||||||
setDynamicDirection(tile: IDynamicTile, direction: FaceDirection): number {
|
setDynamicDirection(tile: IDynamicTile, direction: FaceDirection): number {
|
||||||
const numBefore = tile.num();
|
return tile.setFaceDirection(direction);
|
||||||
tile.setFaceDirection(direction);
|
|
||||||
if (tile.num() !== numBefore) return tile.num();
|
|
||||||
const degraded = degradeFace(direction);
|
|
||||||
if (degraded !== direction) {
|
|
||||||
tile.setFaceDirection(degraded);
|
|
||||||
}
|
|
||||||
return tile.num();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@shouldReplay('Updating dynamic tile position should be replayed.')
|
@shouldReplay('Updating dynamic tile position should be replayed.')
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { ITileLocator, logger } from '@motajs/common';
|
import { ITileLocator, logger } from '@motajs/common';
|
||||||
import {
|
import {
|
||||||
getFaceMovement,
|
FaceGroup,
|
||||||
ObjectMover,
|
ObjectMover,
|
||||||
ObjectMoveStep,
|
ObjectMoveStep,
|
||||||
ObjectMoveType,
|
ObjectMoveType,
|
||||||
@ -46,16 +46,21 @@ export class DynamicTileMover extends ObjectMover<IDynamicTile> {
|
|||||||
x: tile.x,
|
x: tile.x,
|
||||||
y: tile.y
|
y: tile.y
|
||||||
};
|
};
|
||||||
|
const handler = tile.state.faceManager.get(FaceGroup.Dir8);
|
||||||
|
if (!handler) {
|
||||||
|
logger.warn(192);
|
||||||
|
return Promise.resolve({ x: tile.x, y: tile.y });
|
||||||
|
}
|
||||||
switch (step.type) {
|
switch (step.type) {
|
||||||
case ObjectMoveType.Dir: {
|
case ObjectMoveType.Dir: {
|
||||||
const { x, y } = getFaceMovement(step.move);
|
const { x, y } = handler.movement(step.move);
|
||||||
tile.setFaceDirection(step.move);
|
tile.setFaceDirection(step.move);
|
||||||
locator.x += x;
|
locator.x += x;
|
||||||
locator.y += y;
|
locator.y += y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ObjectMoveType.DirFace: {
|
case ObjectMoveType.DirFace: {
|
||||||
const { x, y } = getFaceMovement(step.move);
|
const { x, y } = handler.movement(step.move);
|
||||||
tile.setFaceDirection(step.face);
|
tile.setFaceDirection(step.face);
|
||||||
locator.x += x;
|
locator.x += x;
|
||||||
locator.y += y;
|
locator.y += y;
|
||||||
@ -66,7 +71,7 @@ export class DynamicTileMover extends ObjectMover<IDynamicTile> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ObjectMoveType.Special: {
|
case ObjectMoveType.Special: {
|
||||||
const { x, y } = getFaceMovement(this.moveDirection);
|
const { x, y } = handler.movement(this.moveDirection);
|
||||||
tile.setFaceDirection(this.faceDirection);
|
tile.setFaceDirection(this.faceDirection);
|
||||||
locator.x += x;
|
locator.x += x;
|
||||||
locator.y += y;
|
locator.y += y;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { ITileLocator } from '@motajs/common';
|
import { ITileLocator } from '@motajs/common';
|
||||||
import {
|
import {
|
||||||
FaceDirection,
|
FaceDirection,
|
||||||
|
FaceGroup,
|
||||||
IDataCommon,
|
IDataCommon,
|
||||||
IDataCommonExtended,
|
IDataCommonExtended,
|
||||||
ISaveableContent,
|
ISaveableContent,
|
||||||
@ -58,10 +59,17 @@ export abstract class MapTileBase<TSave extends IMapBlockSaveBase>
|
|||||||
const cur = this.num();
|
const cur = this.num();
|
||||||
const next = this.layer.faceBinder.getFaceOf(cur, direction);
|
const next = this.layer.faceBinder.getFaceOf(cur, direction);
|
||||||
if (next) {
|
if (next) {
|
||||||
|
// 先尝试在 dir8 中寻找
|
||||||
this.set(next.identifier);
|
this.set(next.identifier);
|
||||||
return next.identifier;
|
return next.identifier;
|
||||||
} else {
|
} else {
|
||||||
return cur;
|
// 找不到则降级到 dir4
|
||||||
|
const handler = this.state.faceManager.get(FaceGroup.Dir4);
|
||||||
|
if (!handler) return cur;
|
||||||
|
const degraded = handler.degrade(direction);
|
||||||
|
const next = this.layer.faceBinder.getFaceOf(cur, degraded);
|
||||||
|
if (next) return next.identifier;
|
||||||
|
else return cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { IFaceData, IRoleFaceBinder } from './types';
|
|||||||
import { isNil } from 'lodash-es';
|
import { isNil } from 'lodash-es';
|
||||||
import { FaceDirection } from './types';
|
import { FaceDirection } from './types';
|
||||||
|
|
||||||
interface FaceInfo {
|
interface IFaceInfo {
|
||||||
/** 此图块的朝向 */
|
/** 此图块的朝向 */
|
||||||
readonly face: FaceDirection;
|
readonly face: FaceDirection;
|
||||||
/** 此图块对应的映射 */
|
/** 此图块对应的映射 */
|
||||||
@ -12,7 +12,7 @@ interface FaceInfo {
|
|||||||
|
|
||||||
export class RoleFaceBinder implements IRoleFaceBinder {
|
export class RoleFaceBinder implements IRoleFaceBinder {
|
||||||
/** 每个图块对应的朝向信息 */
|
/** 每个图块对应的朝向信息 */
|
||||||
private faceMap: Map<number, FaceInfo> = new Map();
|
private faceMap: Map<number, IFaceInfo> = new Map();
|
||||||
/** 主要朝向映射 */
|
/** 主要朝向映射 */
|
||||||
private mainMap: Map<number, FaceDirection> = new Map();
|
private mainMap: Map<number, FaceDirection> = new Map();
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ export class RoleFaceBinder implements IRoleFaceBinder {
|
|||||||
this.mainMap.set(identifier, main);
|
this.mainMap.set(identifier, main);
|
||||||
const map = new Map<FaceDirection, number>();
|
const map = new Map<FaceDirection, number>();
|
||||||
map.set(main, identifier);
|
map.set(main, identifier);
|
||||||
const info: FaceInfo = { face: main, map };
|
const info: IFaceInfo = { face: main, map };
|
||||||
this.faceMap.set(identifier, info);
|
this.faceMap.set(identifier, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export class RoleFaceBinder implements IRoleFaceBinder {
|
|||||||
}
|
}
|
||||||
const { map } = this.faceMap.get(main)!;
|
const { map } = this.faceMap.get(main)!;
|
||||||
map.set(face, identifier);
|
map.set(face, identifier);
|
||||||
const info: FaceInfo = { face, map };
|
const info: IFaceInfo = { face, map };
|
||||||
this.faceMap.set(identifier, info);
|
this.faceMap.set(identifier, info);
|
||||||
this.mainMap.set(identifier, mainFace);
|
this.mainMap.set(identifier, mainFace);
|
||||||
}
|
}
|
||||||
@ -50,8 +50,8 @@ export class RoleFaceBinder implements IRoleFaceBinder {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFaceDirection(identifier: number): FaceDirection | undefined {
|
getFaceDirection(identifier: number): FaceDirection {
|
||||||
return this.faceMap.get(identifier)?.face;
|
return this.faceMap.get(identifier)?.face ?? FaceDirection.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMainFace(identifier: number): IFaceData | null {
|
getMainFace(identifier: number): IFaceData | null {
|
||||||
|
|||||||
@ -117,6 +117,13 @@ export class Dir8FaceHandler implements IFaceHandler<FaceDirection> {
|
|||||||
return map.get(degraded) ?? FaceDirection.Unknown;
|
return map.get(degraded) ?? FaceDirection.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dirOf(dx: number, dy: number): FaceDirection {
|
||||||
|
for (const [dir, { x, y }] of DIR8_MOVEMENTS) {
|
||||||
|
if (x === dx && y === dy) return dir;
|
||||||
|
}
|
||||||
|
return FaceDirection.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
mapDirection(): Iterable<FaceDirection> {
|
mapDirection(): Iterable<FaceDirection> {
|
||||||
return DIR8_MOVEMENTS.keys();
|
return DIR8_MOVEMENTS.keys();
|
||||||
}
|
}
|
||||||
@ -192,6 +199,13 @@ export class Dir4FaceHandler implements IFaceHandler<FaceDirection> {
|
|||||||
return map.get(degraded) ?? FaceDirection.Unknown;
|
return map.get(degraded) ?? FaceDirection.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dirOf(dx: number, dy: number): FaceDirection {
|
||||||
|
for (const [dir, { x, y }] of DIR8_MOVEMENTS) {
|
||||||
|
if (x === dx && y === dy) return dir;
|
||||||
|
}
|
||||||
|
return FaceDirection.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
mapDirection(): Iterable<FaceDirection> {
|
mapDirection(): Iterable<FaceDirection> {
|
||||||
return DIR4_MOVEMENTS.keys();
|
return DIR4_MOVEMENTS.keys();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,4 +3,3 @@ export * from './faceManager';
|
|||||||
export * from './indexer';
|
export * from './indexer';
|
||||||
export * from './mover';
|
export * from './mover';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export * from './utils';
|
|
||||||
|
|||||||
@ -463,20 +463,6 @@ export abstract class ObjectMover<T extends IObjectMovable>
|
|||||||
this.moveQueue.push(step);
|
this.moveQueue.push(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取相对移动(如前进)所使用的基准方向
|
|
||||||
*
|
|
||||||
* 优先取本步之前已确定的移动方向,使多步前进保持同轴;否则回退到当前朝向。
|
|
||||||
* 后退不使用此基准,一律以当前朝向为准
|
|
||||||
*/
|
|
||||||
private getCurrentDirection(): FaceDirection {
|
|
||||||
if (this.moveDirection !== FaceDirection.Unknown) {
|
|
||||||
return this.moveDirection;
|
|
||||||
} else {
|
|
||||||
return this.faceDirection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据步骤内容预先同步移动器内部状态
|
* 根据步骤内容预先同步移动器内部状态
|
||||||
*
|
*
|
||||||
@ -498,13 +484,11 @@ export abstract class ObjectMover<T extends IObjectMovable>
|
|||||||
this.faceDirection = step.value;
|
this.faceDirection = step.value;
|
||||||
break;
|
break;
|
||||||
case ObjectMoveType.Special: {
|
case ObjectMoveType.Special: {
|
||||||
|
const dir = this.faceDirection;
|
||||||
if (step.direction === ObjectSpecialStep.Backward) {
|
if (step.direction === ObjectSpecialStep.Backward) {
|
||||||
// 后退基准固定为当前朝向,避免被本步写入的反方向改写后摆动
|
|
||||||
const dir = this.faceDirection;
|
|
||||||
this.moveDirection = this.faceHandler.opposite(dir);
|
this.moveDirection = this.faceHandler.opposite(dir);
|
||||||
this.faceDirection = dir;
|
this.faceDirection = dir;
|
||||||
} else {
|
} else {
|
||||||
const dir = this.getCurrentDirection();
|
|
||||||
this.moveDirection = dir;
|
this.moveDirection = dir;
|
||||||
this.faceDirection = dir;
|
this.faceDirection = dir;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,10 +48,10 @@ export interface IRoleFaceBinder {
|
|||||||
getFaceOf(identifier: number, face: FaceDirection): IFaceData | null;
|
getFaceOf(identifier: number, face: FaceDirection): IFaceData | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定图块数字是哪个朝向
|
* 获取指定图块数字是哪个朝向,如果没有指定图块的数据,那么返回 `FaceDirection.Unknown`
|
||||||
* @param identifier 图块数字
|
* @param identifier 图块数字
|
||||||
*/
|
*/
|
||||||
getFaceDirection(identifier: number): FaceDirection | undefined;
|
getFaceDirection(identifier: number): FaceDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定图块数字绑定至的主朝向
|
* 获取指定图块数字绑定至的主朝向
|
||||||
|
|||||||
@ -1,186 +0,0 @@
|
|||||||
import { FaceDirection } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 用 `IFaceHandler` 接口
|
|
||||||
* 获取指定朝向的坐标偏移量
|
|
||||||
* @param dir 朝向
|
|
||||||
*/
|
|
||||||
export function getFaceMovement(dir: FaceDirection): Loc {
|
|
||||||
switch (dir) {
|
|
||||||
case FaceDirection.Left:
|
|
||||||
return { x: -1, y: 0 };
|
|
||||||
case FaceDirection.Right:
|
|
||||||
return { x: 1, y: 0 };
|
|
||||||
case FaceDirection.Up:
|
|
||||||
return { x: 0, y: -1 };
|
|
||||||
case FaceDirection.Down:
|
|
||||||
return { x: 0, y: 1 };
|
|
||||||
case FaceDirection.LeftUp:
|
|
||||||
return { x: -1, y: -1 };
|
|
||||||
case FaceDirection.RightUp:
|
|
||||||
return { x: 1, y: -1 };
|
|
||||||
case FaceDirection.LeftDown:
|
|
||||||
return { x: -1, y: 1 };
|
|
||||||
case FaceDirection.RightDown:
|
|
||||||
return { x: 1, y: 1 };
|
|
||||||
case FaceDirection.Unknown:
|
|
||||||
return { x: 0, y: 0 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 用 `IFaceHandler` 接口
|
|
||||||
* 将八方向朝向降级为四方向朝向
|
|
||||||
* @param dir 朝向
|
|
||||||
* @param unknown 如果朝向是 `FaceDirection.Unknown`,那么会返回什么,默认值是未知
|
|
||||||
*/
|
|
||||||
export function degradeFace(
|
|
||||||
dir: FaceDirection,
|
|
||||||
unknown: FaceDirection = FaceDirection.Unknown
|
|
||||||
): FaceDirection {
|
|
||||||
switch (dir) {
|
|
||||||
case FaceDirection.LeftUp:
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case FaceDirection.LeftDown:
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case FaceDirection.RightUp:
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case FaceDirection.RightDown:
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case FaceDirection.Unknown:
|
|
||||||
return unknown;
|
|
||||||
}
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 用 `IFaceHandler` 接口
|
|
||||||
* 获取指定朝向旋转后的朝向
|
|
||||||
* @param dir 当前朝向
|
|
||||||
* @param anticlockwise 是否逆时针旋转,默认顺时针
|
|
||||||
* @param face8 是否使用八朝向。为 `false` 时,旋转为九十度旋转,即 上->右->下->左,左上->右上->右下->左下。
|
|
||||||
* 为 `true` 时,旋转为四十五度旋转,即 上->右上->右->右下->下->左下->左->左上。逆时针反过来旋转。
|
|
||||||
*/
|
|
||||||
export function nextFaceDirection(
|
|
||||||
dir: FaceDirection,
|
|
||||||
anticlockwise: boolean = false,
|
|
||||||
face8: boolean = false
|
|
||||||
): FaceDirection {
|
|
||||||
if (face8) {
|
|
||||||
if (anticlockwise) {
|
|
||||||
switch (dir) {
|
|
||||||
case FaceDirection.Left:
|
|
||||||
return FaceDirection.LeftDown;
|
|
||||||
case FaceDirection.LeftDown:
|
|
||||||
return FaceDirection.Down;
|
|
||||||
case FaceDirection.Down:
|
|
||||||
return FaceDirection.RightDown;
|
|
||||||
case FaceDirection.RightDown:
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case FaceDirection.Right:
|
|
||||||
return FaceDirection.RightUp;
|
|
||||||
case FaceDirection.RightUp:
|
|
||||||
return FaceDirection.Up;
|
|
||||||
case FaceDirection.Up:
|
|
||||||
return FaceDirection.LeftUp;
|
|
||||||
case FaceDirection.LeftUp:
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case FaceDirection.Unknown:
|
|
||||||
return FaceDirection.Unknown;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (dir) {
|
|
||||||
case FaceDirection.Left:
|
|
||||||
return FaceDirection.LeftUp;
|
|
||||||
case FaceDirection.LeftUp:
|
|
||||||
return FaceDirection.Up;
|
|
||||||
case FaceDirection.Up:
|
|
||||||
return FaceDirection.RightUp;
|
|
||||||
case FaceDirection.RightUp:
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case FaceDirection.Right:
|
|
||||||
return FaceDirection.RightDown;
|
|
||||||
case FaceDirection.RightDown:
|
|
||||||
return FaceDirection.Down;
|
|
||||||
case FaceDirection.Down:
|
|
||||||
return FaceDirection.LeftDown;
|
|
||||||
case FaceDirection.LeftDown:
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case FaceDirection.Unknown:
|
|
||||||
return FaceDirection.Unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (anticlockwise) {
|
|
||||||
switch (dir) {
|
|
||||||
case FaceDirection.Left:
|
|
||||||
return FaceDirection.Down;
|
|
||||||
case FaceDirection.Down:
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case FaceDirection.Right:
|
|
||||||
return FaceDirection.Up;
|
|
||||||
case FaceDirection.Up:
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case FaceDirection.LeftUp:
|
|
||||||
return FaceDirection.LeftDown;
|
|
||||||
case FaceDirection.LeftDown:
|
|
||||||
return FaceDirection.RightDown;
|
|
||||||
case FaceDirection.RightDown:
|
|
||||||
return FaceDirection.RightUp;
|
|
||||||
case FaceDirection.RightUp:
|
|
||||||
return FaceDirection.LeftUp;
|
|
||||||
case FaceDirection.Unknown:
|
|
||||||
return FaceDirection.Unknown;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (dir) {
|
|
||||||
case FaceDirection.Left:
|
|
||||||
return FaceDirection.Up;
|
|
||||||
case FaceDirection.Up:
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case FaceDirection.Right:
|
|
||||||
return FaceDirection.Down;
|
|
||||||
case FaceDirection.Down:
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case FaceDirection.LeftUp:
|
|
||||||
return FaceDirection.RightUp;
|
|
||||||
case FaceDirection.RightUp:
|
|
||||||
return FaceDirection.RightDown;
|
|
||||||
case FaceDirection.RightDown:
|
|
||||||
return FaceDirection.LeftDown;
|
|
||||||
case FaceDirection.LeftDown:
|
|
||||||
return FaceDirection.LeftUp;
|
|
||||||
case FaceDirection.Unknown:
|
|
||||||
return FaceDirection.Unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 用 `IFaceHandler` 接口
|
|
||||||
* 根据朝向字符串获取朝向枚举值
|
|
||||||
* @param dir 朝向字符串
|
|
||||||
*/
|
|
||||||
export function fromDirectionString(dir: Dir2): FaceDirection {
|
|
||||||
switch (dir) {
|
|
||||||
case 'left':
|
|
||||||
return FaceDirection.Left;
|
|
||||||
case 'right':
|
|
||||||
return FaceDirection.Right;
|
|
||||||
case 'up':
|
|
||||||
return FaceDirection.Up;
|
|
||||||
case 'down':
|
|
||||||
return FaceDirection.Down;
|
|
||||||
case 'leftup':
|
|
||||||
return FaceDirection.LeftUp;
|
|
||||||
case 'rightup':
|
|
||||||
return FaceDirection.RightUp;
|
|
||||||
case 'leftdown':
|
|
||||||
return FaceDirection.LeftDown;
|
|
||||||
case 'rightdown':
|
|
||||||
return FaceDirection.RightDown;
|
|
||||||
default:
|
|
||||||
return FaceDirection.Unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -270,6 +270,7 @@
|
|||||||
"189": "Cannot flatten autotile since it cannot be splitted evenly. Autotile width: $1, frames: $2.",
|
"189": "Cannot flatten autotile since it cannot be splitted evenly. Autotile width: $1, frames: $2.",
|
||||||
"190": "Cannot flatten autotile since its width or height cannot be divided evenly. Autotile frame size: [$1,$2].",
|
"190": "Cannot flatten autotile since its width or height cannot be divided evenly. Autotile frame size: [$1,$2].",
|
||||||
"191": "Cannot cache autotile since no its frame or type data stored.",
|
"191": "Cannot cache autotile since no its frame or type data stored.",
|
||||||
|
"192": "A FaceGroup.Dir8 face handler registration is expected.",
|
||||||
"1001": "Event(setBlock): Unknown tile '$1' when setting block."
|
"1001": "Event(setBlock): Unknown tile '$1' when setting block."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,6 +185,13 @@ export interface IFaceHandler<T extends number> {
|
|||||||
*/
|
*/
|
||||||
next(dir: number, anticlockwise?: boolean): T;
|
next(dir: number, anticlockwise?: boolean): T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应于指定偏移量的朝向方向。如果有多个符合要求,那么会返回其中一个符合要求的朝向
|
||||||
|
* @param dx 横坐标移动偏移量
|
||||||
|
* @param dy 纵坐标移动偏移量
|
||||||
|
*/
|
||||||
|
dirOf(dx: number, dy: number): T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 迭代本组支持的所有朝向,包含 `Unknown`
|
* 迭代本组支持的所有朝向,包含 `Unknown`
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user