分析 SpellCasting 源码。最后造一个轮子,用来做Spell控制。 笑。内容比较多我这里会分多个章节阐述原理。我看了好多遍目录结构发现它现在的内容远比我想象的要多。本篇作为个人笔记 后续写一些造轮子的心得干货 。

概念

节点组成

Spell树形结构有2n+N个节点组成。所谓的2就是起点加终点。
StartNodes : 允许多个。
EndNodes : 允许多个。EndNodes 就像普通节点一样处理,给当前Spell销毁创造一个机会 ,EndNode一定会被调用即使cancel这个spell也会调用

Components

Spells are made up of special parts that determine the flow and results of the spell. Understanding these components will help you control the flow.

Spell

Container that holds all the nodes and links. This represents the template that spell instances will be created from.

Node

Individual graph node in a spell that is a container. Its purpose is to hold a single action and help provide flow control within the spell.
Node就是Spell的容器

Spell Action

The spell action is what the node contains. During the life cycle, when a node is reached the action is activated. It’s this action that will have any number of different implementations.
Spell就是具体实现施法代码的地方,位于node容器内

A link is what ties two nodes together and creates the actual flow.
将两个节点连在一起

Links can have different actions on them that help to control the flow. Think of them as gates that prevent a flow from continuing.
链接两个Actiond的纽带,可以看做两个Action过渡的大门

未完待续