mirror of
https://github.com/motajs/template.git
synced 2026-11-15 08:14:30 +08:00
refactor: ReplaySystem.route -> ReplaySystem.array,修复 disabled 标记在 setReplayArray 中清零可能导致意外记录的问题
This commit is contained in:
1 parent
3a3a6ac82d
commit
a2a8e6ec35
19 files changed
+96
-87
No files matched your search
@@ -192,7 +192,7 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
||||
|
||||
// 最后恢复录像记录并记录录像
|
||||
replay.revert();
|
||||
replay.route.add(ReplayCode.Equip, [uid]);
|
||||
replay.array.add(ReplayCode.Equip, [uid]);
|
||||
|
||||
return curr;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
||||
|
||||
// 记录录像
|
||||
const replay = this.state.replaySystem;
|
||||
replay.route.add(ReplayCode.Unequip, [slot]);
|
||||
replay.array.add(ReplayCode.Unequip, [slot]);
|
||||
|
||||
this.unloadEquipEffect(state);
|
||||
this.equips.delete(slot);
|
||||
@@ -346,16 +346,8 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
||||
});
|
||||
// 由于装备修饰器不进存档,所以此时的勇士处于没有任何装备修饰器的状态,故可以安全清除
|
||||
this.equips.clear();
|
||||
// 读档期间经 equip 恢复槽位会产生真实录像指令,故暂时禁用录像记录
|
||||
const replay = this.state.replaySystem;
|
||||
replay.disable();
|
||||
try {
|
||||
for (const [index, uid] of state.equipped) {
|
||||
this.equip(uid, index);
|
||||
}
|
||||
} finally {
|
||||
// 必须保证所有路径都恢复录像记录,否则会永久吞掉后续录像
|
||||
replay.revert();
|
||||
for (const [index, uid] of state.equipped) {
|
||||
this.equip(uid, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export class HeroItems<THero> implements IHeroItems<THero> {
|
||||
if (!raw.effect.canUse(raw)) return false;
|
||||
|
||||
const replay = this.state.replaySystem;
|
||||
replay.route.add(ReplayCode.UseItem, [raw.num]);
|
||||
replay.array.add(ReplayCode.UseItem, [raw.num]);
|
||||
|
||||
raw.effect.useEffect(raw);
|
||||
|
||||
|
||||
@@ -176,16 +176,16 @@ export class HeroMover<T extends IHeroLocation>
|
||||
const replay = this.state.replaySystem;
|
||||
switch (handler.direction) {
|
||||
case FaceDirection.Up:
|
||||
replay.route.add(ReplayCode.Up, []);
|
||||
replay.array.add(ReplayCode.Up, []);
|
||||
break;
|
||||
case FaceDirection.Right:
|
||||
replay.route.add(ReplayCode.Right, []);
|
||||
replay.array.add(ReplayCode.Right, []);
|
||||
break;
|
||||
case FaceDirection.Left:
|
||||
replay.route.add(ReplayCode.Left, []);
|
||||
replay.array.add(ReplayCode.Left, []);
|
||||
break;
|
||||
case FaceDirection.Down:
|
||||
replay.route.add(ReplayCode.Down, []);
|
||||
replay.array.add(ReplayCode.Down, []);
|
||||
break;
|
||||
default:
|
||||
logger.warn(176);
|
||||
|
||||
Reference in new issue
Block a user