-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
- 移除
SelfData依赖 - 拓展一个专用的
Game_NPCEvent - 整理了之前讨论的场景外NPC活动规则
====
对象属性
| 属性名 | 说明 | 类型 |
|---|---|---|
offSceneCounter |
场景外 NPC 移动计数 | number |
routine |
路径队列 | Queue<Game_PathNode> |
patrol |
巡逻队列 | Queue<Game_PathNode> |
pos |
NPC 位置 | [MapId, x, y, d] |
name |
NPC 事件标识 | string |
event |
场景内事件对象 | Game_NPCEvent |
patterns |
行为模式组 | List<Pattern> |
dialogueName |
NPC 对话模式标识 (事件页条件) | string |
behaviorName |
NPC 移动模式标识 | string |
actionName |
NPC 动作模式标识 (待更新) | string |
初始化
在加载完$dataEventMap后:
- 遍历
$dataEventMap.events里所有的事件e:- 如果
e.meta.GameNPC为true- (待更新) 读取
e.pages[0].list的注释, 遍历每一行初始化数据
- (待更新) 读取
- 如果
时间驱动: updateOffScene
对于每个场景外 NPC, 每经过周期 x 执行:
-
设置队列
l的值:- 如果
routine不为空 则设l为routine - 如果
patrol不为空 则设l为patrol - 否则跳过剩余动作
- 如果
-
设
l的列头为目标点p -
offSceneCounter增加x -
重复
offSceneCounter大于p.cost:offSceneCounter减少p.cost- 将
p从l中出队 - 如果
l为patrol:- 将
p加入队列l
- 将
- 如果
l为routine且为空- 设置
l为patrol
- 设置
- 如果
l为空- 跳过剩余动作
- 重新设
p的值为l列头
-
将
p.pos赋给pos -
如果
pos所在的mapId为$gameMap._mapId- 创建标识符为
name的Game_NPCEvent实例, 并赋值给event - 加载
Sprite_Character到Scene
- 创建标识符为
地图移动驱动: updateOnSceneMovement
对于每个在场景内的 NPC, 每次刷新时若没有其他行动则:
-
设置队列
l的值:- 如果
routine不为空 则设l为routine - 如果
patrol不为空 则设l为patrol - 否则跳过剩余动作
- 如果
-
设
l的列头为目标点p-
如果
pos和p.pos相等:- 将
p从l中出队 - 如果
l为patrol:- 将
p加入队列l
- 将
- 如果
l为routine且为空- 设置
l为patrol
- 设置
- 如果
l为空- 跳过剩余动作
- 重新设
p的值为l列头
- 将
-
-
如果
p所在的mapId不为$gameMap._mapId- 则移除
event - 移除
event对应的sprite - 跳过剩余动作
- 则移除
-
设置
d为event.findDirectionTo求到p.pos位置的方向 -
执行
event.moveforward -
将
pos设置为pos位移 d 方向 1 格的坐标
地图动作: updateOnSceneAction
(待更新)
行为模式切换
对于所有 NPC, 当外界状态发生变化时, 或对某一 NPC, 自身状态发生变化时:
-
遍历
patterns中的每一个pattern:-
如果
pattern中的conditions均满足条件- 设
newPattern为 pattern
- 设
-
如果
behaviorName不相等- 更新
routine,patrol(跨地图寻路)
- 更新
-
更新
dialogueName和actionName
-
-
刷新地图,
$gameMap.requestRefresh()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation