mirror of
https://github.com/motajs/template.git
synced 2026-11-12 14:04:31 +08:00
feat: 录像记录 & CoreState 存储接口
This commit is contained in:
1 parent
5470f7a90e
commit
cee843981f
16 files changed
+156
-51
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { isNil } from 'lodash-es';
|
||||
import { IDataCommon } from '@user/data-common';
|
||||
import { IDataCommon, ReplayCommandCode } from '@user/data-common';
|
||||
import {
|
||||
EquipStatus,
|
||||
IEquipmentState,
|
||||
@@ -127,6 +127,11 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
// 记录录像
|
||||
// TODO: 可以考虑把禁用录像记录放到录像系统里面,避免每个可能由代码触发的行动都写一个 noRoute 参数
|
||||
const replay = this.state.replaySystem;
|
||||
replay.route.add(ReplayCommandCode.Equip, [uid]);
|
||||
|
||||
if (typeof slot === 'number') {
|
||||
// 数字槽位,直接进行指定替换
|
||||
const curr = this.equips.get(slot);
|
||||
@@ -176,6 +181,10 @@ export class HeroEquipment<THero> implements IHeroEquipment<THero> {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
// 记录录像
|
||||
const replay = this.state.replaySystem;
|
||||
replay.route.add(ReplayCommandCode.Unequip, [slot]);
|
||||
|
||||
this.unloadEquipEffect(state);
|
||||
this.equips.delete(slot);
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { isNil } from 'lodash-es';
|
||||
import { IDataCommon, ItemCategory, SaveCompression } from '@user/data-common';
|
||||
import {
|
||||
IDataCommon,
|
||||
ItemCategory,
|
||||
ReplayCommandCode,
|
||||
SaveCompression
|
||||
} from '@user/data-common';
|
||||
import { HeroEquipsStore } from './equipStore';
|
||||
import {
|
||||
IHeroItems,
|
||||
@@ -107,7 +112,7 @@ export class HeroItems<THero> implements IHeroItems<THero> {
|
||||
this.addItem(item, 1);
|
||||
}
|
||||
|
||||
useItem(item: number | string): boolean {
|
||||
useItem(item: number | string, noRoute: boolean = false): boolean {
|
||||
const state = this.internalGetItemState(item);
|
||||
if (!state) return false;
|
||||
|
||||
@@ -121,6 +126,11 @@ export class HeroItems<THero> implements IHeroItems<THero> {
|
||||
|
||||
if (!raw.effect.canUse(raw)) return false;
|
||||
|
||||
if (!noRoute) {
|
||||
const replay = this.state.replaySystem;
|
||||
replay.route.add(ReplayCommandCode.UseItem, [raw.num]);
|
||||
}
|
||||
|
||||
raw.effect.useEffect(raw);
|
||||
|
||||
if (raw.category === ItemCategory.Consumable) {
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
ObjectMoveStep,
|
||||
ObjectMover,
|
||||
ObjectMoveType,
|
||||
IDataCommon
|
||||
IDataCommon,
|
||||
ReplayCommandCode
|
||||
} from '@user/data-common';
|
||||
import {
|
||||
HeroMoveCode,
|
||||
@@ -177,6 +178,29 @@ export class HeroMover<T extends IHeroLocation>
|
||||
type === ObjectMoveType.DirFace ||
|
||||
type === ObjectMoveType.Special
|
||||
) {
|
||||
// 录像记录
|
||||
if (!this.noRoute) {
|
||||
const replay = this.state.replaySystem;
|
||||
switch (handler.direction) {
|
||||
case FaceDirection.Up:
|
||||
replay.route.add(ReplayCommandCode.Up, []);
|
||||
break;
|
||||
case FaceDirection.Right:
|
||||
replay.route.add(ReplayCommandCode.Right, []);
|
||||
break;
|
||||
case FaceDirection.Left:
|
||||
replay.route.add(ReplayCommandCode.Left, []);
|
||||
break;
|
||||
case FaceDirection.Down:
|
||||
replay.route.add(ReplayCommandCode.Down, []);
|
||||
break;
|
||||
default:
|
||||
logger.warn(176);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 移动判断
|
||||
if (this.ignoreTerrain) {
|
||||
return HeroMoveCode.Step;
|
||||
} else {
|
||||
|
||||
@@ -562,9 +562,10 @@ export interface IHeroItems<THero>
|
||||
/**
|
||||
* 使用道具,仅对 Constant 与 Consumable 类型生效。Consumable 类型使用后数量减一。
|
||||
* @param item 道具图块数字或字符串 id
|
||||
* @param noRoute 是否不计入录像
|
||||
* @returns 道具是否使用成功
|
||||
*/
|
||||
useItem(item: number | string): boolean;
|
||||
useItem(item: number | string, noRoute?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* 获取指定道具的持有数量
|
||||
|
||||
Reference in new issue
Block a user