diff --git a/src/main/kotlin/com/bytedice/bde_particles/Bde_particles.kt b/src/main/kotlin/com/bytedice/bde_particles/Bde_particles.kt index 91be9ee..c363172 100644 --- a/src/main/kotlin/com/bytedice/bde_particles/Bde_particles.kt +++ b/src/main/kotlin/com/bytedice/bde_particles/Bde_particles.kt @@ -201,12 +201,15 @@ fun emitterListArg(argName: String) : RequiredArgumentBuilder { +fun curveListArg(argName: String): RequiredArgumentBuilder { return CommandManager.argument(argName, StringArgumentType.string()) .suggests { _, builder -> - LerpCurves::class.nestedClasses.forEach { nestClass -> - builder.suggest(nestClass.simpleName) - } + LerpCurves.Companion::class.members + .filterIsInstance>() + .filter { it.returnType.classifier == LerpCurves::class } + .forEach { property -> + builder.suggest(property.name) + } CompletableFuture.completedFuture(builder.build()) } } diff --git a/src/main/kotlin/com/bytedice/bde_particles/commands/ConfigArgs.kt b/src/main/kotlin/com/bytedice/bde_particles/commands/ConfigArgs.kt index 62a5367..3b360bf 100644 --- a/src/main/kotlin/com/bytedice/bde_particles/commands/ConfigArgs.kt +++ b/src/main/kotlin/com/bytedice/bde_particles/commands/ConfigArgs.kt @@ -81,11 +81,14 @@ fun parseArgTypeToFunc(type: KType) : CommandArgumentBuilder? { ParamClasses.PairInt::class -> ::pairIntArg SpawningShape::class -> ::shapeArg ParamClasses.PairVec3f::class -> ::pairVec3fArg - ParamClasses.PairFloat::class -> ::pairFloatArg + ParamClasses.PairFloat::class -> ::pairFloatArg // unexpected error ParamClasses.TransformWithVel::class -> ::transformWithVelArg - ParamClasses.StringCurve::class -> ::stringCurveArg - ParamClasses.LerpVal::class -> ::lerpValArg - ParamClasses.ForceFieldArray::class -> ::forceFieldArg + ParamClasses.StringCurve::class -> ::stringCurveArg // curve suggestion is only "companion" (bypassing doesn't work) + // doesn't add items (added items result with a space: "acacia boat" instead of "acacia_boat") + // doesn't remove items + ParamClasses.LerpVal::class -> ::lerpValArg // curve suggestion (see above) + ParamClasses.ForceFieldArray::class -> ::forceFieldArg // doesn't add force fields + // removing gives unexpected error (because index error) else -> null } } @@ -272,12 +275,14 @@ fun shapeArgExec(paramName: String, access: KProperty1 { val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge") val x = FloatArgumentType.getFloat(context, "X") val y = FloatArgumentType.getFloat(context, "Y") updateParam(id, access, SpawningShape.Rect(Vector2f(x, y), onEdge)) + successText(access, "Rect", id, context) } "Cube" -> { val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge") @@ -285,18 +290,19 @@ fun shapeArgExec(paramName: String, access: KProperty1 { val radius = FloatArgumentType.getFloat(context, "Radius") val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge") updateParam(id, access, SpawningShape.Sphere(radius, onEdge)) + successText(access, "Sphere", id, context) } "Point" -> { updateParam(id, access, SpawningShape.Point) + successText(access, "Point", id, context) } } - - successText(access, access::class.simpleName ?: "UNKNOWN", id, context) } fun pairVec3fArg(access: KProperty1, diff --git a/src/main/kotlin/com/bytedice/bde_particles/particles/ParticleEmitter.kt b/src/main/kotlin/com/bytedice/bde_particles/particles/ParticleEmitter.kt index e662291..0f60dc3 100644 --- a/src/main/kotlin/com/bytedice/bde_particles/particles/ParticleEmitter.kt +++ b/src/main/kotlin/com/bytedice/bde_particles/particles/ParticleEmitter.kt @@ -115,7 +115,20 @@ class ParticleEmitter( } else if (params.spawnDuration is ParamClasses.Duration.InfiniteLoop) { - return + val loopDur = (params.spawnDuration as ParamClasses.Duration.InfiniteLoop).loopDur + val loopDelay = (params.spawnDuration as ParamClasses.Duration.InfiniteLoop).loopDelay + + if (timePaused >= loopDelay) { + isPaused = false + timePaused = 0 + } + if (timeAlive >= loopDur && loopDelay > 0) { + isPaused = true + timeAlive = 0 + } + + if (!isPaused) { timeAlive += 1 } + else { timePaused += 1 } } } diff --git a/src/main/kotlin/com/bytedice/bde_particles/particles/Shapes.kt b/src/main/kotlin/com/bytedice/bde_particles/particles/Shapes.kt index c9c0710..31e657d 100644 --- a/src/main/kotlin/com/bytedice/bde_particles/particles/Shapes.kt +++ b/src/main/kotlin/com/bytedice/bde_particles/particles/Shapes.kt @@ -23,7 +23,7 @@ sealed class SpawningShape() { } } - class Rect(private val size: Vector2f, val spawnOnEdge: Boolean) : SpawningShape() { + class Rect(val size: Vector2f, val spawnOnEdge: Boolean) : SpawningShape() { fun randomWithin(): Vector3f { return Vector3f(randomFloatBetween(0.0f, size.x), 0.0f, randomFloatBetween(0.0f, size.y)) } @@ -41,7 +41,7 @@ sealed class SpawningShape() { } } - class Cube(private val size: Vector3f, val spawnOnEdge: Boolean) : SpawningShape() { + class Cube(val size: Vector3f, val spawnOnEdge: Boolean) : SpawningShape() { fun randomWithin(): Vector3f { return Vector3f( randomFloatBetween(0.0f, size.x), @@ -108,8 +108,8 @@ sealed class SpawningShape() { return when (shape) { is Circle -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() } is Sphere -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() } - is Rect -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() } - is Cube -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() } + is Rect -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }.sub(Vector3f(shape.size.x, 0.0f, shape.size.y).div(2.0f)) + is Cube -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }.sub(Vector3f(shape.size.x, shape.size.y, shape.size.z).div(2.0f)) is Point -> Vector3f(0.0f, 0.0f, 0.0f) } }