Compare commits
6 Commits
@esengine/
...
@esengine/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7caa69a22e | ||
|
|
5a5daf7565 | ||
|
|
3415737fcc | ||
|
|
876312deb2 | ||
|
|
a790fc9e92 | ||
|
|
fa593a3c69 |
@@ -7,37 +7,26 @@ This document explains how to install and use the blueprint visual scripting edi
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### 1. Copy Extension to Project
|
### 1. Download Extension
|
||||||
|
|
||||||
Copy the `cocos-node-editor` extension to your Cocos Creator project's `extensions` directory:
|
Download the `cocos-node-editor.zip` extension package from the release page.
|
||||||
|
|
||||||
```
|
### 2. Import Extension
|
||||||
your-project/
|
|
||||||
├── assets/
|
|
||||||
├── extensions/
|
|
||||||
│ └── cocos-node-editor/ # Blueprint editor extension
|
|
||||||
└── ...
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Install Dependencies
|
|
||||||
|
|
||||||
Install dependencies in the extension directory:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd extensions/cocos-node-editor
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Enable Extension
|
|
||||||
|
|
||||||
1. Open Cocos Creator
|
1. Open Cocos Creator
|
||||||
2. Go to **Extensions → Extension Manager**
|
2. Go to **Extensions → Extension Manager**
|
||||||
3. Find `cocos-node-editor` and enable it
|
3. Click the **Import Extension** button
|
||||||
|
4. Select the downloaded `cocos-node-editor.zip` file
|
||||||
|
5. Enable the extension after importing
|
||||||
|
|
||||||
## Opening the Blueprint Editor
|
## Opening the Blueprint Editor
|
||||||
|
|
||||||
Open the blueprint editor panel via menu **Panel → Node Editor**.
|
Open the blueprint editor panel via menu **Panel → Node Editor**.
|
||||||
|
|
||||||
|
### First Launch - Install Dependencies
|
||||||
|
|
||||||
|
When opening the panel for the first time, the plugin will check if `@esengine/blueprint` is installed in your project. If not installed, it will display **"Missing required dependencies"** prompt. Click the **"Install Dependencies"** button to install automatically.
|
||||||
|
|
||||||
## Editor Interface
|
## Editor Interface
|
||||||
|
|
||||||
### Toolbar
|
### Toolbar
|
||||||
@@ -110,89 +99,22 @@ Blueprints are saved as `.blueprint.json` files, fully compatible with runtime:
|
|||||||
|
|
||||||
## Running Blueprints in Game
|
## Running Blueprints in Game
|
||||||
|
|
||||||
Use ECS system to manage and execute blueprints.
|
The `@esengine/blueprint` package provides complete ECS integration, including `BlueprintComponent` and `BlueprintSystem` ready to use.
|
||||||
|
|
||||||
### 1. Define Blueprint Component
|
### 1. Add Blueprint System to Scene
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { Component, ECSComponent, Property, Serialize } from '@esengine/ecs-framework';
|
import { BlueprintSystem } from '@esengine/blueprint';
|
||||||
import type { BlueprintAsset } from '@esengine/blueprint';
|
|
||||||
|
|
||||||
@ECSComponent('Blueprint')
|
// Add blueprint system during scene initialization
|
||||||
export class BlueprintComponent extends Component {
|
scene.addSystem(new BlueprintSystem());
|
||||||
@Serialize()
|
|
||||||
@Property({ type: 'asset', label: 'Blueprint Asset' })
|
|
||||||
blueprintPath: string = '';
|
|
||||||
|
|
||||||
@Serialize()
|
|
||||||
@Property({ type: 'boolean', label: 'Auto Start' })
|
|
||||||
autoStart: boolean = true;
|
|
||||||
|
|
||||||
// Runtime data (not serialized)
|
|
||||||
blueprintAsset: BlueprintAsset | null = null;
|
|
||||||
vm: BlueprintVM | null = null;
|
|
||||||
isStarted: boolean = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create Blueprint Execution System
|
### 2. Load Blueprint and Add to Entity
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { EntitySystem, Matcher, Entity } from '@esengine/ecs-framework';
|
|
||||||
import {
|
|
||||||
BlueprintVM,
|
|
||||||
validateBlueprintAsset
|
|
||||||
} from '@esengine/blueprint';
|
|
||||||
import { BlueprintComponent } from './BlueprintComponent';
|
|
||||||
|
|
||||||
export class BlueprintExecutionSystem extends EntitySystem {
|
|
||||||
constructor() {
|
|
||||||
super(Matcher.empty().all(BlueprintComponent));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override process(entities: readonly Entity[]): void {
|
|
||||||
const dt = Time.deltaTime;
|
|
||||||
|
|
||||||
for (const entity of entities) {
|
|
||||||
const bp = entity.getComponent(BlueprintComponent)!;
|
|
||||||
|
|
||||||
// Skip entities without blueprint asset
|
|
||||||
if (!bp.blueprintAsset) continue;
|
|
||||||
|
|
||||||
// Initialize VM
|
|
||||||
if (!bp.vm) {
|
|
||||||
bp.vm = new BlueprintVM(bp.blueprintAsset, entity, this.scene!);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Auto start
|
|
||||||
if (bp.autoStart && !bp.isStarted) {
|
|
||||||
bp.vm.start();
|
|
||||||
bp.isStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update blueprint
|
|
||||||
if (bp.isStarted) {
|
|
||||||
bp.vm.tick(dt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override onRemoved(entity: Entity): void {
|
|
||||||
const bp = entity.getComponent(BlueprintComponent);
|
|
||||||
if (bp?.vm && bp.isStarted) {
|
|
||||||
bp.vm.stop();
|
|
||||||
bp.vm = null;
|
|
||||||
bp.isStarted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Load Blueprint and Add to Entity
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { resources, JsonAsset } from 'cc';
|
import { resources, JsonAsset } from 'cc';
|
||||||
import { validateBlueprintAsset } from '@esengine/blueprint';
|
import { BlueprintComponent, validateBlueprintAsset, BlueprintAsset } from '@esengine/blueprint';
|
||||||
|
|
||||||
// Load blueprint asset
|
// Load blueprint asset
|
||||||
async function loadBlueprint(path: string): Promise<BlueprintAsset | null> {
|
async function loadBlueprint(path: string): Promise<BlueprintAsset | null> {
|
||||||
@@ -227,12 +149,22 @@ async function createBlueprintEntity(scene: IScene, blueprintPath: string): Prom
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Register System to Scene
|
### BlueprintComponent Properties
|
||||||
|
|
||||||
```typescript
|
| Property | Type | Description |
|
||||||
// During scene initialization
|
|----------|------|-------------|
|
||||||
scene.addSystem(new BlueprintExecutionSystem());
|
| `blueprintAsset` | `BlueprintAsset \| null` | Blueprint asset data |
|
||||||
```
|
| `blueprintPath` | `string` | Blueprint asset path (for serialization) |
|
||||||
|
| `autoStart` | `boolean` | Auto-start execution (default `true`) |
|
||||||
|
| `debug` | `boolean` | Enable debug mode |
|
||||||
|
|
||||||
|
### BlueprintComponent Methods
|
||||||
|
|
||||||
|
| Method | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `start()` | Manually start blueprint execution |
|
||||||
|
| `stop()` | Stop blueprint execution |
|
||||||
|
| `cleanup()` | Cleanup blueprint resources |
|
||||||
|
|
||||||
## Creating Custom Nodes
|
## Creating Custom Nodes
|
||||||
|
|
||||||
|
|||||||
@@ -7,37 +7,26 @@ description: "在 Cocos Creator 中使用蓝图可视化脚本系统"
|
|||||||
|
|
||||||
## 安装扩展
|
## 安装扩展
|
||||||
|
|
||||||
### 1. 复制扩展到项目
|
### 1. 下载扩展
|
||||||
|
|
||||||
将 `cocos-node-editor` 扩展复制到你的 Cocos Creator 项目的 `extensions` 目录:
|
从发布页面下载 `cocos-node-editor.zip` 扩展包。
|
||||||
|
|
||||||
```
|
### 2. 导入扩展
|
||||||
your-project/
|
|
||||||
├── assets/
|
|
||||||
├── extensions/
|
|
||||||
│ └── cocos-node-editor/ # 蓝图编辑器扩展
|
|
||||||
└── ...
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 安装依赖
|
|
||||||
|
|
||||||
在扩展目录中安装依赖:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd extensions/cocos-node-editor
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 启用扩展
|
|
||||||
|
|
||||||
1. 打开 Cocos Creator
|
1. 打开 Cocos Creator
|
||||||
2. 进入 **扩展 → 扩展管理器**
|
2. 进入 **扩展 → 扩展管理器**
|
||||||
3. 找到 `cocos-node-editor` 并启用
|
3. 点击 **导入扩展包** 按钮
|
||||||
|
4. 选择下载的 `cocos-node-editor.zip` 文件
|
||||||
|
5. 导入后启用扩展
|
||||||
|
|
||||||
## 打开蓝图编辑器
|
## 打开蓝图编辑器
|
||||||
|
|
||||||
通过菜单 **面板 → Node Editor** 打开蓝图编辑器面板。
|
通过菜单 **面板 → Node Editor** 打开蓝图编辑器面板。
|
||||||
|
|
||||||
|
### 首次打开 - 安装依赖
|
||||||
|
|
||||||
|
首次打开面板时,插件会检测项目中是否安装了 `@esengine/blueprint` 依赖包。如果未安装,会显示 **"缺少必要的依赖包"** 提示,点击 **"安装依赖"** 按钮即可自动安装。
|
||||||
|
|
||||||
## 编辑器界面
|
## 编辑器界面
|
||||||
|
|
||||||
### 工具栏
|
### 工具栏
|
||||||
@@ -110,89 +99,22 @@ npm install
|
|||||||
|
|
||||||
## 在游戏中运行蓝图
|
## 在游戏中运行蓝图
|
||||||
|
|
||||||
使用 ECS 系统方式管理和执行蓝图。
|
`@esengine/blueprint` 包已提供完整的 ECS 集成,包括 `BlueprintComponent` 和 `BlueprintSystem`,可以直接使用。
|
||||||
|
|
||||||
### 1. 定义蓝图组件
|
### 1. 添加蓝图系统到场景
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { Component, ECSComponent, Property, Serialize } from '@esengine/ecs-framework';
|
import { BlueprintSystem } from '@esengine/blueprint';
|
||||||
import type { BlueprintAsset } from '@esengine/blueprint';
|
|
||||||
|
|
||||||
@ECSComponent('Blueprint')
|
// 在场景初始化时添加蓝图系统
|
||||||
export class BlueprintComponent extends Component {
|
scene.addSystem(new BlueprintSystem());
|
||||||
@Serialize()
|
|
||||||
@Property({ type: 'asset', label: 'Blueprint Asset' })
|
|
||||||
blueprintPath: string = '';
|
|
||||||
|
|
||||||
@Serialize()
|
|
||||||
@Property({ type: 'boolean', label: 'Auto Start' })
|
|
||||||
autoStart: boolean = true;
|
|
||||||
|
|
||||||
// 运行时数据(不序列化)
|
|
||||||
blueprintAsset: BlueprintAsset | null = null;
|
|
||||||
vm: BlueprintVM | null = null;
|
|
||||||
isStarted: boolean = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. 创建蓝图执行系统
|
### 2. 加载蓝图并添加到实体
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { EntitySystem, Matcher, Entity } from '@esengine/ecs-framework';
|
|
||||||
import {
|
|
||||||
BlueprintVM,
|
|
||||||
validateBlueprintAsset
|
|
||||||
} from '@esengine/blueprint';
|
|
||||||
import { BlueprintComponent } from './BlueprintComponent';
|
|
||||||
|
|
||||||
export class BlueprintExecutionSystem extends EntitySystem {
|
|
||||||
constructor() {
|
|
||||||
super(Matcher.empty().all(BlueprintComponent));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override process(entities: readonly Entity[]): void {
|
|
||||||
const dt = Time.deltaTime;
|
|
||||||
|
|
||||||
for (const entity of entities) {
|
|
||||||
const bp = entity.getComponent(BlueprintComponent)!;
|
|
||||||
|
|
||||||
// 跳过没有蓝图资产的实体
|
|
||||||
if (!bp.blueprintAsset) continue;
|
|
||||||
|
|
||||||
// 初始化 VM
|
|
||||||
if (!bp.vm) {
|
|
||||||
bp.vm = new BlueprintVM(bp.blueprintAsset, entity, this.scene!);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自动启动
|
|
||||||
if (bp.autoStart && !bp.isStarted) {
|
|
||||||
bp.vm.start();
|
|
||||||
bp.isStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新蓝图
|
|
||||||
if (bp.isStarted) {
|
|
||||||
bp.vm.tick(dt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override onRemoved(entity: Entity): void {
|
|
||||||
const bp = entity.getComponent(BlueprintComponent);
|
|
||||||
if (bp?.vm && bp.isStarted) {
|
|
||||||
bp.vm.stop();
|
|
||||||
bp.vm = null;
|
|
||||||
bp.isStarted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 加载蓝图并添加到实体
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { resources, JsonAsset } from 'cc';
|
import { resources, JsonAsset } from 'cc';
|
||||||
import { validateBlueprintAsset } from '@esengine/blueprint';
|
import { BlueprintComponent, validateBlueprintAsset, BlueprintAsset } from '@esengine/blueprint';
|
||||||
|
|
||||||
// 加载蓝图资产
|
// 加载蓝图资产
|
||||||
async function loadBlueprint(path: string): Promise<BlueprintAsset | null> {
|
async function loadBlueprint(path: string): Promise<BlueprintAsset | null> {
|
||||||
@@ -227,12 +149,22 @@ async function createBlueprintEntity(scene: IScene, blueprintPath: string): Prom
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. 注册系统到场景
|
### BlueprintComponent 属性
|
||||||
|
|
||||||
```typescript
|
| 属性 | 类型 | 说明 |
|
||||||
// 在场景初始化时
|
|------|------|------|
|
||||||
scene.addSystem(new BlueprintExecutionSystem());
|
| `blueprintAsset` | `BlueprintAsset \| null` | 蓝图资产数据 |
|
||||||
```
|
| `blueprintPath` | `string` | 蓝图资产路径(用于序列化) |
|
||||||
|
| `autoStart` | `boolean` | 是否自动开始执行(默认 `true`) |
|
||||||
|
| `debug` | `boolean` | 是否启用调试模式 |
|
||||||
|
|
||||||
|
### BlueprintComponent 方法
|
||||||
|
|
||||||
|
| 方法 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| `start()` | 手动开始执行蓝图 |
|
||||||
|
| `stop()` | 停止蓝图执行 |
|
||||||
|
| `cleanup()` | 清理蓝图资源 |
|
||||||
|
|
||||||
## 创建自定义节点
|
## 创建自定义节点
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
# @esengine/ecs-framework-math
|
# @esengine/ecs-framework-math
|
||||||
|
|
||||||
|
## 2.10.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- [#444](https://github.com/esengine/esengine/pull/444) [`fa593a3`](https://github.com/esengine/esengine/commit/fa593a3c69292207800750f8106f418465cb7c0f) Thanks [@esengine](https://github.com/esengine)! - feat(math): add blueprint nodes for math library
|
||||||
|
- Add Vector2 blueprint nodes (Make, Break, Add, Sub, Mul, Length, Normalize, Dot, Cross, Distance, Lerp, Rotate, FromAngle)
|
||||||
|
- Add Fixed32 blueprint nodes (FromFloat, FromInt, ToFloat, ToInt, arithmetic operations, Abs, Sqrt, Floor, Ceil, Round, Sign, Min, Max, Clamp, Lerp)
|
||||||
|
- Add FixedVector2 blueprint nodes (Make, Break, Add, Sub, Mul, Negate, Length, Normalize, Dot, Cross, Distance, Lerp)
|
||||||
|
- Add Color blueprint nodes (Make, Break, FromHex, ToHex, FromHSL, ToHSL, Lerp, Lighten, Darken, Saturate, Desaturate, Invert, Grayscale, Luminance, constants)
|
||||||
|
- Add documentation for math blueprint nodes (Chinese and English)
|
||||||
|
|
||||||
## 2.9.0
|
## 2.9.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/ecs-framework-math",
|
"name": "@esengine/ecs-framework-math",
|
||||||
"version": "2.9.0",
|
"version": "2.10.0",
|
||||||
"description": "ECS框架2D数学库 - 提供向量、矩阵、几何形状和碰撞检测功能",
|
"description": "ECS框架2D数学库 - 提供向量、矩阵、几何形状和碰撞检测功能",
|
||||||
"main": "bin/index.js",
|
"main": "bin/index.js",
|
||||||
"types": "bin/index.d.ts",
|
"types": "bin/index.d.ts",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @esengine/network
|
# @esengine/network
|
||||||
|
|
||||||
|
## 12.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`fa593a3`](https://github.com/esengine/esengine/commit/fa593a3c69292207800750f8106f418465cb7c0f)]:
|
||||||
|
- @esengine/ecs-framework-math@2.10.0
|
||||||
|
|
||||||
## 11.0.0
|
## 11.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/network",
|
"name": "@esengine/network",
|
||||||
"version": "11.0.0",
|
"version": "12.0.0",
|
||||||
"description": "Network synchronization for multiplayer games",
|
"description": "Network synchronization for multiplayer games",
|
||||||
"esengine": {
|
"esengine": {
|
||||||
"plugin": true,
|
"plugin": true,
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @esengine/pathfinding
|
# @esengine/pathfinding
|
||||||
|
|
||||||
|
## 11.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`fa593a3`](https://github.com/esengine/esengine/commit/fa593a3c69292207800750f8106f418465cb7c0f)]:
|
||||||
|
- @esengine/ecs-framework-math@2.10.0
|
||||||
|
|
||||||
## 10.0.0
|
## 10.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/pathfinding",
|
"name": "@esengine/pathfinding",
|
||||||
"version": "10.0.0",
|
"version": "11.0.0",
|
||||||
"description": "寻路系统 | Pathfinding System - A*, Grid, NavMesh",
|
"description": "寻路系统 | Pathfinding System - A*, Grid, NavMesh",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @esengine/spatial
|
# @esengine/spatial
|
||||||
|
|
||||||
|
## 11.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`fa593a3`](https://github.com/esengine/esengine/commit/fa593a3c69292207800750f8106f418465cb7c0f)]:
|
||||||
|
- @esengine/ecs-framework-math@2.10.0
|
||||||
|
|
||||||
## 10.0.0
|
## 10.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/spatial",
|
"name": "@esengine/spatial",
|
||||||
"version": "10.0.0",
|
"version": "11.0.0",
|
||||||
"description": "Spatial query and indexing system for ECS Framework / ECS 框架的空间查询和索引系统",
|
"description": "Spatial query and indexing system for ECS Framework / ECS 框架的空间查询和索引系统",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @esengine/demos
|
# @esengine/demos
|
||||||
|
|
||||||
|
## 1.0.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/pathfinding@11.0.0
|
||||||
|
- @esengine/spatial@11.0.0
|
||||||
|
|
||||||
## 1.0.16
|
## 1.0.16
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/demos",
|
"name": "@esengine/demos",
|
||||||
"version": "1.0.16",
|
"version": "1.0.17",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Demo tests for ESEngine modules documentation",
|
"description": "Demo tests for ESEngine modules documentation",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
Reference in New Issue
Block a user