1501 lines
45 KiB
Markdown
1501 lines
45 KiB
Markdown
---
|
||
sidebarDepth: 1
|
||
---
|
||
# 微软粒子
|
||
|
||
## BindEntity
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
绑定粒子发射器到指定实体的指定骨骼上
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id 需要已经创建且未被销毁的粒子发射器 |
|
||
| entity_id | str或int | 需要绑定的实体id |
|
||
| bone_name | str | 需要绑定的骨骼名称(不区分大小写) 默认值为"body" |
|
||
| offset | tuple | 三维 表示粒子发射器的绑定偏移 默认值为(0, 0, 0) |
|
||
| rotation | tuple | 表示粒子发射器绑定的三维旋转(角度制,按照ZYX顺序旋转) 默认值为(0, 0, 0) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 绑定变换的计算是在局部空间下完成的。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.Create("netease:tutorial_particle")
|
||
comp.BindEntity(parId, localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
```
|
||
|
||
|
||
|
||
## BindModel
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
绑定粒子发射器到指定骨骼模型的指定骨骼上
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id 需要已经创建且未被销毁的粒子发射器 |
|
||
| model_id | int | 绑定的骨骼模型的ID(见model组件的GetModelId) |
|
||
| bone_name | str | 绑定具体骨骼的名称(不区分大小写),默认值为"root" |
|
||
| offset | tuple(float,float,float) | 三维 表示粒子发射器的绑定偏移 默认值为(0, 0, 0) |
|
||
| rotation | tuple(float,float,float) | 表示粒子发射器绑定的三维旋转(角度制,按照ZYX顺序旋转) 默认值为(0, 0, 0) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 绑定变换的计算是在局部空间下完成的,没有指定骨骼的情况下默认绑定到"root"上,如果root不存在则该粒子不会显示,也不会被销毁。
|
||
- 切换至其他骨骼模型后导致model_id改变,所以绑定到原model_id上的粒子发射器也会一起消失。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(clientApi.GetLevelId())
|
||
|
||
par_Id = comp.Create("netease:tutorial_particle")
|
||
comp.BindModel(par_Id, model_id, "root", (0, 0, 0), (0, 0, 0))
|
||
```
|
||
|
||
|
||
|
||
## Create
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
创建粒子发射器, 创建后立即播放
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| effect_name | str | 粒子发射器名称(粒子发射器json文件中的identifier) |
|
||
| offset | tuple | 三维 表示在某处创建粒子发射器 默认值为(0, 0, 0) |
|
||
| rotation | tuple | 粒子发射器创建后使用的三维旋转(使用角度制,按照ZYX顺序旋转) 默认值为(0, 0, 0) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| int | 粒子发射器实例ID 返回0表示创建失败 |
|
||
|
||
- 备注
|
||
- 粒子发射器json文件可以通过微软官方编辑器SnowStorm进行创建编辑,
|
||
开发者们可以通过访问在线网站 https://snowstorm.app 或在Visual Studio Code扩展商店中搜索"snowstorm"来使用这个编辑器
|
||
- 粒子发射器json文件应存放在 资源包/particles 路径下
|
||
- 粒子发射器json文件内容不应该包含中文,否则会无法解析
|
||
- 请注意,如果粒子发射器出现在世界空间(即 没有绑定实体),
|
||
即使粒子发射器json文件定义了minecraft:emitter_lifetime_looping组件,
|
||
也只会播放一次或一个周期,随后销毁
|
||
- 部分原版粒子使用了minecraft:emitter_rate_manual组件,需要额外调用EmitManually函数才能发射粒子
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
parId = comp.Create("netease:tutorial_particle", (0, 0, 0), (0, 0, 0))
|
||
```
|
||
|
||
|
||
|
||
## CreateBindEntity
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
创建粒子发射器并绑定到指定实体的指定骨骼上, 创建后立即播放
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| effect_name | str | 粒子发射器名称(粒子发射器json文件中的identifier) |
|
||
| entity_id | str或int | 需要绑定的实体id |
|
||
| bone_name | str | 需要绑定的骨骼名称(不区分大小写) 默认值为"body" |
|
||
| offset | tuple | 三维 表示粒子发射器的绑定偏移 默认值为(0, 0, 0) |
|
||
| rotation | tuple | 表示粒子发射器绑定的三维旋转(使用角度制,按照ZYX顺序旋转) 默认值为(0, 0, 0) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| int | 粒子发射器实例id 返回0表示创建失败 |
|
||
|
||
- 备注
|
||
- 粒子发射器json文件可以通过微软官方编辑器SnowStorm进行创建编辑,
|
||
开发者们可以通过访问在线网站 https://snowstorm.app 或在Visual Studio Code扩展商店中搜索"snowstorm"来使用这个编辑器
|
||
- 粒子发射器json文件应存放在 资源包/particles 路径下
|
||
- 粒子发射器json文件内容不应该包含中文,否则会无法解析
|
||
- 绑定变换的计算是在局部空间下完成的。
|
||
- 部分原版粒子使用了minecraft:emitter_rate_manual组件,需要额外调用EmitManually函数才能发射粒子
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
```
|
||
|
||
|
||
|
||
## EmitManually
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
手动发射粒子一次
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id 需要已经创建且未被销毁的粒子发射器 |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 部分原版粒子使用了minecraft:emitter_rate_manual组件,在创建粒子发射器后不会自动发射粒子,需要额外调用该函数
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("minecraft:water_evaporation_manual", localId, "rightitem")
|
||
comp.EmitManually(parId) # 手动发射一次粒子
|
||
```
|
||
|
||
|
||
|
||
## Exist
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
判断指定粒子发射器是否存在
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 返回True时,表示指定的粒子发射器存在于场景中 |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.Exist(parId)
|
||
comp.RemoveAll()
|
||
print comp.Exist(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetActiveDuration
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器的激活周期
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| float | 表示粒子发射器激活周期 粒子发射器无效时会返回0.0 |
|
||
|
||
- 备注
|
||
- 粒子发射器的激活周期在其对应的json文件(资源包/particles/xxx.json)中定义
|
||
- 粒子发射器的播放周期等于 激活周期(active_time) + 休眠周期(sleep_time)
|
||
- 对于没有定义激活周期的粒子发射器,其返回值为一个较大的数字(大约为1000000)
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetActiveDuration(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetBindingID
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
返回绑定的目标id 没有则返回"0"
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| str | 绑定的实体id |
|
||
|
||
- 备注
|
||
- 可用GetBindingModleID获取绑定的骨骼模型id
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.Create("netease:tutorial_particle")
|
||
print comp.GetBindingID(parId)
|
||
|
||
comp.BindEntity(parId, localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetBindingID(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetBindingModleID
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
返回绑定的骨骼模型id 没有则返回-1
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| int | 绑定的骨骼模型id |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(clientApi.GetLevelId())
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.Create("netease:tutorial_particle")
|
||
print comp.GetBindingID(parId)
|
||
|
||
comp.BindModel(parId, modID, 'root', (0, 0, 0), (0, 0, 0))
|
||
print comp.GetBindingModleID(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetDuration
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器的播放周期(激活+休眠时间)
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| float | 表示粒子发射器播放周期 粒子发射器无效时会返回0.0 |
|
||
|
||
- 备注
|
||
- 粒子发射器的播放周期在其对应的json文件(资源包/particles/xxx.json)中定义
|
||
- 粒子发射器的播放周期等于 激活周期(active_time) + 休眠周期(sleep_time)
|
||
- 对于没有定义播放周期的粒子发射器,其返回值为一个较大的数字(大约为1000000)
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetDuration(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetFacingMode
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
返回粒子发射器的粒子朝向模式
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| str | 粒子朝向模式字符串 返回字符串"none"表示非法 |
|
||
|
||
- 备注
|
||
- 朝向模式暂不支持使用脚本设置,可以在粒子编辑器SnowStorm中编辑该属性:https://snowstorm.app
|
||
- 目前支持的朝向模式如下:
|
||
|
||
rotate_xyz 粒子朝向相机,面片与相机视角垂直
|
||
rotate_y 粒子朝向相机,但是面片只旋转世界Y轴
|
||
lookat_xyz 粒子旋转XYZ轴看向相机位置
|
||
lookat_y 粒子仅旋转Y轴来看向相机位置
|
||
lookat_direction 可以选择根据速度方向或者自定义方向来决定粒子面片朝向
|
||
direction_x 粒子面片朝向发射器的x轴
|
||
direction_y 粒子面片朝向发射器的y轴
|
||
direction_z 粒子面片朝向发射器的z轴
|
||
emitter_transform_xy 跟随粒子发射器的xy面朝向
|
||
emitter_transform_xz 跟随粒子发射器的xz面朝向
|
||
emitter_transform_yz 跟随粒子发射器的yz面朝向
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetFacingMode(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetLoopAge
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器当前播放周期内已播放的时间
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| float | 表示粒子发射器在当前播放周期内已播放的时间 粒子发射器id无效时会返回0.0 |
|
||
|
||
- 备注
|
||
- 0.0 <= 已播放的时间 <= 粒子发射器播放周期
|
||
- 返回的周期内已播放时间,受到SetTimeScale、Replay和PlayAt等函数的影响。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetLoopAge(parId)
|
||
comp.PlayAt(parId, 0.5)
|
||
print comp.GetLoopAge(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetPos
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器位置
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| is_local | bool | 是否获取局部空间 | 绑定偏移 默认值为True(即 默认获取局部空间位置 | 绑定偏移) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| Tuple | 表示粒子发射器位置的三维向量 |
|
||
|
||
- 备注
|
||
- 如果粒子没有进行绑定(即 没有放在世界空间),则它的局部空间位置等于世界空间位置。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId0 = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 1, 0), (0, 0, 0))
|
||
parId1 = comp.Create("netease:tutorial_particle", (0, 1, 0), (0, 0, 0))
|
||
print 'local position:', comp.GetPos(parId0, True)
|
||
print 'local position:', comp.GetPos(parId1)
|
||
|
||
print 'world position:', comp.GetPos(parId0, False)
|
||
print 'world position:', comp.GetPos(parId1, False)
|
||
```
|
||
|
||
|
||
|
||
## GetRot
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器局部旋转
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| is_local | bool | 表示是否获取局部空间旋转 默认值为True(即 默认获取局部空间旋转) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| Tuple | 粒子发射器三维旋转(使用角度制) |
|
||
|
||
- 备注
|
||
- 如果粒子发射器没有进行绑定,则它的局部空间旋转等于世界空间旋转
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (45, 0, 45))
|
||
print comp.GetRot(parId) # True
|
||
print comp.GetRot(parId, False)
|
||
```
|
||
|
||
|
||
|
||
## GetSleepDuration
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器的休眠周期
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| float | 表示粒子发射器休眠周期 粒子发射器无效时会返回0.0 |
|
||
|
||
- 备注
|
||
- 粒子发射器的休眠周期在其对应的json文件(资源包/particles/xxx.json)中定义
|
||
- 粒子发射器的播放周期等于 激活周期(active_time) + 休眠周期(sleep_time)
|
||
- 对于没有定义休眠周期的粒子发射器,其返回值为0.0
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetSleepDuration(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetTimeScale
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器的播放速度
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| float | 表示粒子发射器播放速度 粒子发射器无效时会返回0.0 |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem")
|
||
print comp.GetTimeScale(parId)
|
||
comp.SetTimeScale(parId, 0.2)
|
||
print comp.GetTimeScale(parId)
|
||
```
|
||
|
||
|
||
|
||
## GetVariable
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
获取粒子发射器的Molang变量值
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| variable_name | str | Molang变量名(例如variable.emitter_age) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| float | 表示粒子发射器的Molang变量值 无效时会返回0.0 |
|
||
|
||
- 备注
|
||
- Molang变量可以在粒子发射器json文件内自行定义。
|
||
- 另外,粒子发射器以及粒子内置了一些Molang变量可供使用:
|
||
|
||
variable.emitter_random_1 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_random_2 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_random_3 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_random_4 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_lifetime 粒子发射器的播放周期(生命周期)
|
||
variable.emitter_age 粒子发射器当前播放时间
|
||
variable.entity_scale 当粒子发射器绑定实体时,这个值表示绑定实体的大小缩放
|
||
variable.particle_lifetime 粒子的生命周期
|
||
variable.particle_age 粒子生成后已经过的时间
|
||
variable.particle_random_1 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
variable.particle_random_2 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
variable.particle_random_3 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
variable.particle_random_4 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
- 关于Molang表达式的使用,目前大家可以参考微软官方文档:
|
||
https://docs.microsoft.com/en-us/minecraft/creator/reference/content/molangreference/examples/molangconcepts/molangintroduction
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetVariable(parId, 'variable.custom_size') # variable.custom_size 是粒子json文件中自定义的变量
|
||
```
|
||
|
||
|
||
|
||
## Hide
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
隐藏粒子发射器(不渲染)
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 请注意,这个函数并不停止粒子发射器的更新,因此粒子发射器在没有绑定实体或被设计为仅播放一次的情况下,会因为播放结束而自然销毁。
|
||
- 可以和Show函数配合使用。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.IsHiding(parId)
|
||
|
||
# 可以等待粒子出现后调用
|
||
comp.Hide(parId)
|
||
print comp.IsHiding(parId)
|
||
```
|
||
|
||
|
||
|
||
## IsHiding
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
返回粒子发射器是否正在被隐藏(不渲染)
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示粒子发射器是否正在隐藏 |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.IsHiding(parId)
|
||
comp.Hide(parId)
|
||
print comp.IsHiding(parId)
|
||
```
|
||
|
||
|
||
|
||
## IsPausing
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
返回粒子发射器的逻辑是否正在被暂停
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示粒子发射器是否被暂停 |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.IsPausing(parId)
|
||
comp.Pause(parId)
|
||
print comp.IsPausing(parId)
|
||
```
|
||
|
||
|
||
|
||
## Pause
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
暂停粒子发射器的逻辑更新,但保持渲染状态
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 可以和Resume函数配合使用,用于暂停粒子发射器的逻辑。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.IsPausing(parId)
|
||
|
||
# 等待一段时间后调用可以看到时间静止的效果
|
||
comp.Pause(parId)
|
||
print comp.IsPausing(parId)
|
||
```
|
||
|
||
|
||
|
||
## Play
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
播放粒子发射器
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 粒子发射器在创建时就会立即播放,因此不需要手动调用这个函数。
|
||
- 这个函数等价于调用Resume和Show,如果同时需要这两个功能,建议直接使用这个函数。
|
||
- 这个函数用于和Stop函数配合使用,可以使粒子发射器在被停止的时间点继续播放(恢复逻辑更新、开启渲染)。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
comp.Stop(parId)
|
||
print comp.IsHiding(parId)
|
||
print comp.IsPausing(parId)
|
||
|
||
comp.Play(parId)
|
||
print comp.IsHiding(parId)
|
||
print comp.IsPausing(parId)
|
||
```
|
||
|
||
|
||
|
||
## PlayAt
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
设置粒子发射器播放时间点
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| at_second | float | 播放时间点 |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 这个函数可以和Stop函数配合使用(跳转到指定时间点、继续逻辑更新且开启渲染)。
|
||
- 这个函数可以使粒子发射器跳转到它的某个时间点进行播放。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.GetLoopAge(parId)
|
||
|
||
comp.PlayAt(parId, 0.5)
|
||
print comp.GetLoopAge(parId)
|
||
```
|
||
|
||
|
||
|
||
## Remove
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
销毁指定粒子发射器
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id 对于不存在的粒子发射器id不会进行任何操作 |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 原版的雨水等粒子发射器目前无法通过类似接口销毁,可能是因为它们使用了旧版的微软粒子系统
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.Exist(parId)
|
||
comp.Remove(parId)
|
||
print comp.Exist(parId)
|
||
```
|
||
|
||
|
||
|
||
## RemoveByName
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
销毁场景中指定名称(粒子发射器json中的identifier)的所有粒子发射器
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| effect_name | str | 粒子发射器名称(json中的identifier) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 原版的雨水等粒子发射器目前无法通过类似接口销毁,可能是因为它们使用了旧版的微软粒子系统进行管理
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.Exist(parId)
|
||
comp.RemoveByName("netease:tutorial_particle")
|
||
print comp.Exist(parId)
|
||
```
|
||
|
||
|
||
|
||
## Replay
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
重播粒子发射器
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 这个函数可以和Stop函数配合使用(重新进行逻辑更新、开启渲染)。
|
||
- 这个函数可以使粒子发射器回到它的时间点零,重新播放(不能用于已经被销毁的粒子发射器)。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
|
||
# 可以等待一段时间后调用
|
||
comp.Replay(parId)
|
||
```
|
||
|
||
|
||
|
||
## Resume
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
恢复粒子发射器的逻辑更新,不影响渲染状态
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 可以和Pause函数配合使用,用于恢复粒子发射器的逻辑更新。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
comp.Pause(parId)
|
||
print comp.IsPausing(parId)
|
||
|
||
# 可以等待一段时间后调用
|
||
comp.Resume(parId)
|
||
print comp.IsPausing(parId)
|
||
```
|
||
|
||
|
||
|
||
## SetPos
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
设置粒子发射器位置
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| pos | Tuple | 三维 表示粒子发射器局部空间位置 默认值为(0, 0, 0) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 粒子发射器没有进行绑定(即 被放在世界空间)时,它的局部空间位置就是世界空间位置。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId0 = comp.CreateBindEntity("netease:tutorial_particle", localId, "leftitem", (0, 1, 0), (0, 0, 0))
|
||
parId1 = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, -1, 0), (0, 0, 0))
|
||
|
||
comp.SetPos(parId0, (0, 0.5, 0))
|
||
comp.SetPos(parId1) # (0, 0, 0)
|
||
```
|
||
|
||
|
||
|
||
## SetRelative
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
设置粒子是否在局部空间进行计算
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id 需要粒子发射器已绑定实体 |
|
||
| is_relative | bool | 表示粒子是否在局部空间进行计算 默认参数值为True |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 此函数对于没有绑定的粒子发射器无效
|
||
- 有关的值可以在粒子发射器json文件中的minecraft:emitter_local_space组件内预先定义,
|
||
如果没有该组件,则默认在世界坐标系下(False)进行变换
|
||
- 设置relative为False时,涉及粒子运动相关的计算都会当作是在世界空间进行的。
|
||
- 设置relative为True时,涉及粒子运动相关的计算都会当作是在局部空间进行的。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
# 开发者可以对比两者的区别来理解两个不同的计算空间
|
||
parId0 = comp.CreateBindEntity("netease:tutorial_particle", localId, "leftitem", (0, 1.0, 0), (90, 0, 0))
|
||
comp.SetRelative(parId0, False)
|
||
parId1 = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 1.0, 0), (90, 0, 0))
|
||
comp.SetRelative(parId1, True)
|
||
```
|
||
|
||
|
||
|
||
## SetRot
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
设置粒子发射器局部旋转
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| rot | Tuple | 粒子发射器三维旋转(使用角度制,按照ZYX顺序旋转) 默认值为(0, 0, 0) |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 如果粒子发射器没有进行绑定,则它的局部空间旋转就是世界空间旋转
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId0 = comp.CreateBindEntity("netease:tutorial_particle", localId, "leftitem", (0, 0, 0), (0, 0, 0))
|
||
parId1 = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
comp.SetRot(parId1, (0, 0, 90))
|
||
```
|
||
|
||
|
||
|
||
## SetTimeScale
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
设置粒子发射器的播放速度
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| scale | float | 表示播放倍率 可以为负数进行倒放 |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 倒放时已经消失的粒子(请注意是单个粒子而不是粒子发射器)不会重新出现,也不会生成新的粒子
|
||
- 如果倒放到了时间点0,没有绑定或者不循环播放的粒子发射器会被销毁
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId0 = comp.CreateBindEntity("netease:tutorial_particle", localId, "leftitem")
|
||
# comp.SetTimeScale(parId0, 1.0)
|
||
parId1 = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem")
|
||
comp.SetTimeScale(parId1, 0.2)
|
||
```
|
||
|
||
|
||
|
||
## SetVariable
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
设置粒子发射器的Molang变量值
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
| variable_name | str | Molang变量名 |
|
||
| value | float | 表示粒子发射器的Molang变量值 |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- Molang变量可以在粒子发射器json文件内自行定义。
|
||
- 另外,粒子发射器以及粒子内置了一些Molang变量可供使用:
|
||
|
||
variable.emitter_random_1 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_random_2 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_random_3 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_random_4 粒子发射器随机数,范围是0.0到1.0,仅在粒子发射器创建时生成一次
|
||
variable.emitter_lifetime 粒子发射器的播放周期(生命周期)
|
||
variable.emitter_age 粒子发射器当前播放时间
|
||
variable.entity_scale 当粒子发射器绑定实体时,这个值表示绑定实体的大小缩放
|
||
variable.particle_lifetime 粒子的生命周期
|
||
variable.particle_age 粒子生成后已经过的时间
|
||
variable.particle_random_1 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
variable.particle_random_2 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
variable.particle_random_3 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
variable.particle_random_4 粒子随机数,范围是0.0到1.0,仅在粒子生成时生成一次
|
||
部分内置的变量(例如variable.emitter_age)会每帧进行刷新,修改它们的值可能会没有任何效果。
|
||
- 关于Molang表达式的使用,目前大家可以参考微软官方文档:
|
||
https://docs.microsoft.com/en-us/minecraft/creator/reference/content/molangreference/examples/molangconcepts/molangintroduction
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId0 = comp.CreateBindEntity("netease:tutorial_particle", localId, "leftitem", (0, 0, 0), (0, 0, 0))
|
||
parId1 = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
|
||
comp.SetVariable(parId1, "variable.custom_size", 0.1) # 修改内置的Molang值效果不明显甚至无效,因此建议自定义变量名
|
||
```
|
||
|
||
|
||
|
||
## Show
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
显示粒子发射器(开启渲染)
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 可以和Hide函数配合使用,用于恢复粒子发射器的显示。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
# 可以等待粒子出现后调用
|
||
comp.Hide(parId)
|
||
print comp.IsHiding(parId)
|
||
|
||
# 可以等待粒子隐藏后调用
|
||
comp.Show(parId)
|
||
print comp.IsHiding(parId)
|
||
```
|
||
|
||
|
||
|
||
## Stop
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
停止粒子发射器播放(不渲染且不更新逻辑)
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- 这个函数等价于调用Pause和Hide,如果同时需要这两个功能,建议直接使用这个函数。
|
||
- 因为逻辑被停止更新,所以粒子发射器不会由于播放结束而被自然销毁。
|
||
- 可以使用Play、Replay或PlayAt函数来播放被停止的粒子发射器。
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (0, 0, 0), (0, 0, 0))
|
||
print comp.IsHiding(parId)
|
||
print comp.IsPausing(parId)
|
||
|
||
# 可以等待一段时间后调用
|
||
comp.Stop(parId)
|
||
print comp.IsHiding(parId)
|
||
print comp.IsPausing(parId)
|
||
```
|
||
|
||
|
||
|
||
## Unbind
|
||
|
||
<span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
method in mod.client.component.particleSystemCompClient.ParticleSystemCompClient
|
||
|
||
- 描述
|
||
|
||
解除指定粒子发射器的绑定状态
|
||
|
||
- 参数
|
||
|
||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- | :--- |
|
||
| par_id | int | 粒子发射器id 需要已经创建且未被销毁的粒子发射器 |
|
||
| keep_position | bool | 解绑后是否保持粒子发射器在世界空间的位置 默认值为True |
|
||
| keep_rotation | bool | 解绑后是否保持粒子发射器在世界空间的旋转 默认值为True |
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| bool | 表示调用是否成功 |
|
||
|
||
- 备注
|
||
- keep_position为False时,解绑后的粒子发射器将使用绑定时的局部偏移作为世界空间位置(即例子中的(6, 6, 6))
|
||
keep_rotation为False时,解绑后的粒子发射器将使用绑定时的局部旋转作为世界空间旋转(即例子中的(0, 0, 0))
|
||
- keep_position为True时,解绑后的粒子发射器会保持在解绑前一刻所在的世界空间位置
|
||
keep_rotation为True时,解绑后的粒子发射器会保持解绑前一刻的世界空间旋转
|
||
- 请注意,如果粒子发射器出现在世界空间(即 没有绑定实体),
|
||
即使粒子发射器json文件定义了minecraft:emitter_lifetime_looping组件,
|
||
也只会播放一次或一个周期,随后销毁
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateParticleSystem(None)
|
||
localId = clientApi.GetLocalPlayerId()
|
||
|
||
parId = comp.CreateBindEntity("netease:tutorial_particle", localId, "rightitem", (6, 6, 6), (0, 0, 0))
|
||
comp.Unbind(parId)
|
||
```
|
||
|
||
|
||
|