mirror of
https://github.com/motajs/template.git
synced 2026-11-18 02:04:30 +08:00
feat: Adding should replay flag
This commit is contained in:
1 parent
7743795948
commit
d74cc35c8e
16 files changed
+86
-186
No files matched your search
@@ -3,7 +3,8 @@ import {
|
||||
IDataCommon,
|
||||
ItemCategory,
|
||||
ReplayCode,
|
||||
SaveCompression
|
||||
SaveCompression,
|
||||
shouldReplay
|
||||
} from '@user/data-common';
|
||||
import { HeroEquipsStore } from './equipStore';
|
||||
import {
|
||||
@@ -75,6 +76,7 @@ export class HeroItems<THero> implements IHeroItems<THero> {
|
||||
return this.getItemState(item)?.count ?? 0;
|
||||
}
|
||||
|
||||
@shouldReplay('Adding item to hero should be replayed.')
|
||||
addItem(item: number | string, count: number = 1): void {
|
||||
const num = this.resolveNum(item);
|
||||
if (isNil(num)) return;
|
||||
@@ -113,6 +115,7 @@ export class HeroItems<THero> implements IHeroItems<THero> {
|
||||
this.addItem(item, 1);
|
||||
}
|
||||
|
||||
@shouldReplay('Using item should be replayed.')
|
||||
useItem(item: number | string): boolean {
|
||||
const state = this.internalGetItemState(item);
|
||||
if (!state) return false;
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
import {
|
||||
FaceDirection,
|
||||
IDataCommon,
|
||||
IFacedTileLocator
|
||||
IFacedTileLocator,
|
||||
shouldReplay
|
||||
} from '@user/data-common';
|
||||
import { HeroMover } from './mover';
|
||||
import {
|
||||
@@ -50,12 +51,14 @@ export class HeroLocation
|
||||
return new HookController(this, hook);
|
||||
}
|
||||
|
||||
@shouldReplay('Setting hero floor should be replayed.')
|
||||
setFloor(map: IGameMap): void {
|
||||
this.floorId = map.floorId;
|
||||
this.map = map;
|
||||
this.forEachHook(hook => hook.onSetFloor?.(map));
|
||||
}
|
||||
|
||||
@shouldReplay('Setting hero position should be replayed.')
|
||||
setPos(x: number, y: number): void {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
ObjectMover,
|
||||
ObjectMoveType,
|
||||
IDataCommon,
|
||||
ReplayCode
|
||||
ReplayCode,
|
||||
shouldReplay
|
||||
} from '@user/data-common';
|
||||
import {
|
||||
HeroMoveCode,
|
||||
@@ -152,6 +153,7 @@ export class HeroMover<T extends IHeroLocation>
|
||||
|
||||
protected async onMoveEnd(): Promise<void> {}
|
||||
|
||||
@shouldReplay('Hero moving step should be replayed.')
|
||||
protected async onStepStart(
|
||||
step: Readonly<ObjectMoveStep>,
|
||||
tile: IHeroLocation
|
||||
@@ -238,6 +240,7 @@ export class HeroMover<T extends IHeroLocation>
|
||||
return HeroMoveCode.Step;
|
||||
}
|
||||
|
||||
@shouldReplay('Hero moving step should be replayed.')
|
||||
protected async onStepEnd(
|
||||
code: number,
|
||||
step: Readonly<ObjectMoveStep>,
|
||||
@@ -279,6 +282,7 @@ export class HeroMover<T extends IHeroLocation>
|
||||
return { x: tile.x, y: tile.y };
|
||||
}
|
||||
|
||||
@shouldReplay('Hero moving step should be replayed.')
|
||||
protected async onStepSettled(
|
||||
before: ITileLocator,
|
||||
curr: ITileLocator,
|
||||
|
||||
Reference in new issue
Block a user