refactor: Range 接口重构

This commit is contained in:
AncTe committed 2026-04-15 15:07:17 +08:00
1 parent a24911400f
commit 4c0960fff7
5 files changed
+30 -34

No files matched your search

+4 -9
View File
@@ -32,11 +32,11 @@ export class CommonAuraConverter implements IAuraConverter<IEnemyAttributes> {
}
convert(
special: ISpecial<any>,
special: ISpecial<IHaloValue>,
enemy: IReadonlyEnemy<IEnemyAttributes>,
locator: ITileLocator
): CommonAura {
return new CommonAura(enemy, special as ISpecial<IHaloValue>, locator);
return new CommonAura(enemy, special, locator);
}
}
@@ -134,17 +134,12 @@ export class GuardAuraConverter implements IAuraConverter<IEnemyAttributes> {
}
convert(
special: ISpecial<any>,
special: ISpecial<void>,
enemy: IReadonlyEnemy<IEnemyAttributes>,
locator: ITileLocator,
context: IEnemyContext<IEnemyAttributes>
): GuardAura {
return new GuardAura(
context,
enemy,
special as ISpecial<void>,
locator
);
return new GuardAura(context, enemy, special, locator);
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
export * from './aura';
export * from './damage';
export * from './mapSpecials';
export * from './mapDamage';
export * from './special';
@@ -74,20 +74,6 @@ abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
}
};
}
/**
* 判断一个点是否在上下文范围内
* @param x 横坐标
* @param y 纵坐标
*/
protected isInBounds(x: number, y: number): boolean {
return (
x >= 0 &&
y >= 0 &&
x < this.context.width &&
y < this.context.height
);
}
}
export class ZoneDamageView extends BaseMapDamageView<
@@ -232,7 +218,9 @@ export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
const otherX = locator.x + deltaX;
const otherY = locator.y + deltaY;
if (!this.isInBounds(otherX, otherY)) {
const range = this.getRange();
range.bindHost(this.context);
if (!range.inBound(otherX, otherY)) {
return null;
}