Skip to content

Commit 19cb7db

Browse files
committed
build
1 parent 6b83949 commit 19cb7db

5 files changed

Lines changed: 185 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- name: Build release artifacts
3636
run: |
37-
./gradlew --no-daemon clean :common:jar :fabric:remapJar :fabric:sourceWithCommon :neoforge:jar :neoforge:sourceWithCommon
37+
./gradlew --no-daemon clean build
3838
3939
- name: Show artifacts
4040
run: |

common/src/main/kotlin/cn/coostack/cooparticlesapi/animation/Animate.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package cn.coostack.cooparticlesapi.animation
22

3+
import cn.coostack.cooparticlesapi.api.controler.Tickable
34
import java.util.function.Predicate
45

56

6-
class Animate {
7+
class Animate : Tickable<Animate> {
78
var timestarp = 0
89
val nodes = ArrayList<Pair<AnimateNode, Int>>()
910
var currentNode: AnimateNode? = null
@@ -54,7 +55,11 @@ class Animate {
5455
timestarp = 0
5556
}
5657

57-
fun tick() {
58+
override fun addPreTickAction(action: Animate.() -> Unit): Tickable<Animate> {
59+
return this
60+
}
61+
62+
override fun tick() {
5863
if (!display || done) return
5964
if (currentNode?.checkDone() ?: true) {
6065
if (currentInterval < timestarp) {

common/src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/composition/ParticleShapeComposition.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ParticleShapeComposition(uuid: UUID) : ParticleComposition(Vec3.ZERO, null
2121
private val beforeInvokes =
2222
ArrayList<ParticleShapeComposition.(map: Map<CompositionData, RelativeLocation>) -> Unit>()
2323

24-
private var scaleHelper: ScaleHelper? = null
24+
var scaleHelper: ScaleHelper? = null
25+
private set
2526
var spawnAge = 0
2627

2728
/**
@@ -34,7 +35,6 @@ class ParticleShapeComposition(uuid: UUID) : ParticleComposition(Vec3.ZERO, null
3435
* 设置为true时 利用scaleHelper 每tick减弱一点
3536
*/
3637
var scaleReversed = false
37-
private set
3838

3939
fun loadScaleHelper(min: Double, max: Double, scalingTick: Int): ParticleShapeComposition {
4040
scaleHelper = CompositionScaleHelper(min, max, scalingTick)

common/src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/composition/SequencedParticleShapeComposition.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SequencedParticleShapeComposition(uuid: UUID) : SequencedParticleCompositi
2828
private val beforeInvokes =
2929
ArrayList<SequencedParticleShapeComposition.(map: SortedMap<CompositionData, RelativeLocation>) -> Unit>()
3030

31-
private var scaleHelper: ScaleHelper? = null
31+
var scaleHelper: ScaleHelper? = null
3232

3333
var spawnAge = 0
3434

require.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# 需求
2+
## 快捷生成Composition
3+
1. 使用类似pointsbuilder卡片的方式编辑
4+
2. 左边是卡片框,右边是预览框, 代码生成在该页面的第二子页面
5+
3. 可选是否实时生成代码, 要有pointsbuilder同款的 设置页面和快捷键页面
6+
7+
## 项目选项
8+
可以修改项目名字 (代表生成的是项目名.kt)
9+
可以选择类型
10+
如果选择ParticleComposition 那么就继承 AutoParticleComposition
11+
如果选择 SequencedParticleComposition 那么就继承 AutoSequencedParticleComposition
12+
13+
如果是SequencedParticleComposition 可以添加animate
14+
animate格式如下
15+
```kotlin
16+
init{
17+
// 第一个参数数字代表生成的点个数 (只能选择常数整数)
18+
// 第二个是条件表达式
19+
// 条件表达式里的可选变量是 composition的全局变量 + composition默认提供的变量
20+
animate.addAnimate(1) { age > 1 }
21+
.addAnimate(1) { age > 6 }
22+
.addAnimate(2) { age > 11 }
23+
.addAnimate(1) { age > 16 }
24+
}
25+
```
26+
27+
可以设置消散延迟 单位tick:
28+
```kotlin
29+
init{
30+
setDisabledInterval(常数)
31+
}
32+
33+
```
34+
## 卡片设置
35+
卡片是这样设置的
36+
1. 绑定一个pointsbuilder 或者point
37+
2. 设置点
38+
39+
## 点设置
40+
1. 可以设置点类型 ParticleShapeComposition 或者 SequencedParticleShapeComposition 或者 single
41+
2. 如果是single, 点选项改为如下
42+
1. `addParticleInstanceInit` 对应粒子选项(color,size,age,alpha,textureSheet)等
43+
2. `addParticleControlerInstanceInit` 可以设置粒子controler的tick变化
44+
设置方式如下(kotlin)
45+
```kotlin
46+
data.addParticleControlerInstanceInit{
47+
it.addPreTickAction{
48+
// 可以获取和修改如下参数
49+
// color,size,age,alpha,textureSheet
50+
}
51+
}
52+
```
53+
3. 卡片可以设置如下内容
54+
1. 添加PointsBuilder, 编辑PointsBuilder时,会跳转到pointsbuilder相似的编辑器
55+
> 注意 这里的pointsbuilder不是直接跳转到pointsbuilder.html 而是复制pointsbuilder.html相同的页面
56+
>
57+
> 然后加入一些标识(防止和pointsbuilder数据搞混) 然后这个 "builder" 可以直接返回到主页面
58+
>
59+
> 所有的操作手感应该和pointsbuilder完全一致
60+
2. 可以加入绕轴旋转,rotateToWithAngle
61+
> 如果设置了rotateToWithAngle,那么就要指定to, 可以指定设定的全局变量
62+
3. 可以设置生长动画
63+
4. 如果是SequencedParticleShapeComposition 那么可以设置animate
64+
65+
## 一些补充
66+
ControlableParticle对象的实现和 single要输入的ParticleDisplayer.withSingle 要输入的effect我都放在了参考/particle 里面
67+
ParticleDisplayer我也放在了参考里面, 只考虑withComposition和withSingle
68+
69+
依旧是 中键旋转,滚轮缩放,右键平移
70+
然后左键用来框选预览的点到对应的卡片
71+
72+
73+
# 使用 / 生成代码 举例
74+
## 项目设置
75+
项目名字: TestComposition
76+
## 项目卡片设置
77+
类型: ParticleComposition
78+
### display行为
79+
#### display action 1
80+
rotateToWithAngle卡片
81+
82+
设定
83+
84+
rotateSpeed= 10
85+
86+
to = direction.asRelative()
87+
88+
### 全局变量列表
89+
color - Vec3 - Vector3f(0,1,1)
90+
91+
size - Float - 1
92+
93+
radius - Double - 2
94+
95+
countPow - int - 4
96+
97+
direction - Vec3 // to只接收RelativeLocation和Vec3 如果写Vec3 那么上面就要变成xxx.asRelative()
98+
### 全局非同步常量列表
99+
options - Int - 4
100+
101+
## 卡片编辑
102+
### PointsBuilder <- 导入了一个builder(这里比如只有一个ball)
103+
PointsBuilder的addBall卡片的radius参数设置为 这里的全局radius
104+
### Data设置
105+
Effect -> Single (ControlableEnchantmentEffect)
106+
### Single设置
107+
#### particle init
108+
currentAge = Random.nextInt(lifetime) // 可以选择定值 也可以选择随机值
109+
color = this@TestComposition.color
110+
#### controler init
111+
定义局部变量 tick - boolean - true
112+
##### tick action 1
113+
写表达式
114+
```javascript
115+
if (particle.particleAlpha >= 0.9) {
116+
tick = false
117+
}
118+
if (particle.particleAlpha <= 0.2) {
119+
tick = true
120+
}
121+
particle.particleAlpha += tick ? 0.05 : -0.05
122+
```
123+
124+
## 最后生成的代码如下
125+
```kotlin
126+
127+
@CooAutoRegister
128+
class TestComposition(position: Vec3, world: Level? = null) : AutoParticleComposition(position, world) {
129+
@CodecField
130+
var color: Vector3f = Vector3f(0f,1f,1f)
131+
132+
@CodecField
133+
var size: Float = 1f
134+
135+
@CodecField
136+
var r: Double = 2.0
137+
138+
@CodecField
139+
var countPow: Int = 4
140+
val options: Int = 4
141+
142+
override fun getParticles(): Map<CompositionData, RelativeLocation> {
143+
return PointsBuilder().addBall(r, countPow * options / 2)
144+
.createWithCompositionData {
145+
CompositionData().setDisplayerSupplier {
146+
ParticleDisplayer.withSingle(
147+
ControlableEnchantmentEffect(it)
148+
)
149+
}.addParticleInstanceInit {
150+
color = this@TestComposition.color
151+
size = this@TestComposition.size
152+
currentAge = Random.nextInt(lifetime)
153+
}.addParticleControlerInstanceInit {
154+
var tick = true
155+
addPreTickAction { // 注意下面是由js翻译过来的
156+
if (particle.particleAlpha >= 0.9f) {
157+
tick = false
158+
}
159+
if (particle.particleAlpha <= 0.2f) {
160+
tick = true
161+
}
162+
particle.particleAlpha += if (tick) 0.05f else -0.05f
163+
}
164+
}
165+
}
166+
}
167+
168+
override fun onDisplay() {
169+
addPreTickAction { // 如果是卡片就直接加, 如果是表达式就翻译成kotlin
170+
rotateToWithAngle(direction,speed / 180 * PI)
171+
}
172+
}
173+
}
174+
```

0 commit comments

Comments
 (0)